Pay3 Javascript SDK

Event Listeners

9min

Introduction

After completing transactions in Pay3 SDK UI, the Pay3 SDK publishes events to App.

pay3-sdk-transaction-status

This event is fired by Pay3 SDK in following scenario:

  1. On completion of Checkout transaction triggered by pay3.openCheckout()

Payload

data (Type Object): Following keys are present in this object

  1. status (Type string): The status can have one of these values - SUCCESS or ERROR or INITIATED.
  2. message (Type string): User-friendly message returned after completion of the transaction.
  3. orderId (Type string): Pay3 Order ID.
  4. requestId (Type string): Unique id passed by App.

Register callback: pay3Pay.on()

This function registers a callback, which is invoked when the given event type is received from Pay3.

Parameter

  1. eventName (Type string): Name of the event for which we want to register the callback
  2. callbackFn (Type function): Callback function accepting a parameter payload.
index.js


Check if registered: pay3Pay.hasListeners()

This function returns true if the event already has a registered callback.

Parameter

  1. eventName (Type string): Name of the event for which we want to test if the callback is registered.

Return (Type boolean)

JS


Unregister callback: pay3Pay.removeListener()

This function removes a function that is already registered as a callback. Input of this function needs to be the same as that was provided in pay3Pay.on function call.

Parameter

  1. eventName (Type string): Name of the event for which we want to register the callback
  2. callbackFn (Type function): Callback function accepting a parameter payload.
JS


Register callback in React Native using WebView

For React native with Javascript SDK, the Pay3 Payment publishes the events using window.ReactNativeWebView.postMessage(string payload). These events are available via onMessage handler of the WebView

JS

JSON




Updated 26 Jul 2024
Doc contributor
Doc contributor
Did this page help you?