Callbacks
In the Checkout SDK, callback functions are essential for delivering real-time updates on the status of payment transactions. These callbacks improve the user experience by facilitating smooth and effective management of different payment scenarios, including errors, successful transactions, and cancellations.
The errorCallback
is a callback function triggered when issues occur during a payment process. Properly handling these errors is essential for maintaining a smooth user experience.
To set up the errorCallback
function, use the data-error
attribute on the Checkout script tag to designate a global function that will manage errors. If an error arises during a payment, the errorCallback
function will be called, receiving a JSONObject
with a data.status
value indicating an error.
Params Available in data
JSONObject
for errorCallback
message
mandatoryform_of_payment
mandatorystatus
mandatorychallenge_occurred
optionalsession_id
optionalorder_no
optionalreference_number
optional
The cancelCallback
is a callback function in the Checkout SDK that is activated when a payment is canceled.
To configure the cancelCallback
function, you can use the data-cancel
attribute on the Checkout script tag to specify a global function that will handle cancellations. If a payment is canceled by a customer, the cancelCallback
function will be called, and it will receive a JSONObject
containing a data.status
value of "canceled".
Params Available in data
JSONObject
for cancelCallback
message
mandatoryform_of_payment
mandatorychallenge_occurred
optionalsession_id
optionalstatus
mandatoryorder_no
optionalreference_number
optionalpayment_gateway_info
optional
In both cancelCallback
and errorCallback
, the SDK must be reinitialized, either on the same session or on a new session.
The successCallback
is a function that is triggered when the payment process is successfully completed. This callback receives a JSONObject
containing a data.status
value of "success."
Params Available in data
JSONObject
for successCallback
message
mandatoryform_of_payment
mandatorychallenge_occurred
optionalsession_id
optionalstatus
mandatoryorder_no
optionalreference_number
optionalredirect_url
optionalpayment_gateway_info
optional
The successCallback
function is defined and assigned by setting the data-success
attribute on the Checkout script tag. This attribute specifies a global function that will be invoked when the payment process successfully completes.
Last updated