Callback Reference
onSuccess(orderData)
Called when the order is successfully completed by the customer.
Parameters:
orderData(Object): Contains details of the completed order.backd_order_id(String) – Backd's unique identifier for the order. This will be used in subsequent API calls for post order management. Ensure that this gets stored on your DB.merchant_order_id(String) – This is the unique identifier that the merchant shared at the start the order on initialization.
Example:
onSuccess: function (orderData) {
console.log("Order completed:", orderData);
}
onClose(closeData)
Called when the customer closes the widget before completing the order.
This function is triggered if the user manually exits the payment or order process before completion. It provides information about the reason for closure, allowing for custom handling, such as displaying a confirmation prompt or logging user behavior.
Parameters:
closeData(Object): Provides additional details.message(String) – Description of the reason for closure.
Example:
onClose: function (closeData) {
console.log("Widget closed:", closeData.message);
}
onFail(errorData)
Called when a critical error occurs, preventing order completion. This callback will be utilized mostly in the integration sandbox.
This function is executed when an unrecoverable error happens during the order process. It helps in identifying issues such as network failures, invalid API key, or other unexpected failures, ensuring proper error handling and user notification.
Parameters:
errorData(Object): Contains error details.message(String) – Description of the error.
Example:
onFail: function (errorData) {
console.error("Order failed:", errorData.message);
}