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
messagemandatoryform_of_paymentmandatorystatusmandatorychallenge_occurredoptionalsession_idoptionalorder_nooptionalreference_numberoptional
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
messagemandatoryform_of_paymentmandatorychallenge_occurredoptionalsession_idoptionalstatusmandatoryorder_nooptionalreference_numberoptionalpayment_gateway_infooptional
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
messagemandatoryform_of_paymentmandatorychallenge_occurredoptionalsession_idoptionalstatusmandatoryorder_nooptionalreference_numberoptionalredirect_urloptionalpayment_gateway_infooptional
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