Custom Events
All responses from the Client SDK are provided back to the merchant as custom events. To use this, merchants need to subscribe to an observer, letting the Client SDK know that the merchant wants to be provided responses for the events being subscribed to.
It is recommended to pass this through the callback parameter in the ChargeRequest object on initiation of the Client SDK.
Event all
Event is called when any of the events below have been triggered.
window.Datamesh.on('all', (response) => {
// various responses, use response.type to determine the event and object returned
})
Event frame_created
Event is called when the iframe is created.
window.Datamesh.on('frame_created', (response) => {
// merchant logic
})
Event error
Event is called when the Charge SDK throws an error
window.Datamesh.on('error', (response) => {
// response:
// {
// type: "ERROR",
// data: {
// error: "Something went wrong",
// error_info: {}
// }
}
})
Event height_changed
Event is called when the iFrame height changes.
window.Datamesh.on('height_changed', (response) => {
// response:
// {
// data: {
// height: 544
// }
//}
})
Event Initiated
Event is called when Charge SDK Front-end is initiated.
window.Datamesh.on('initiated', (response) => {
})
Event order_created
Event is called when an order is created.
:notepad_spiral: This event only applies to One-step Payment flow.
window.Datamesh.on('order.created', (response) => {
// response: // { // "ChargeId":"UUID" // } })
Event payment_pending_authorization
Event is called when payment is pending authorisation and should be authorised soon. This event only applies to Payment flow.
window.Datamesh.on('payment.pending_authorization', (response) => {
// response = {"type": "STATUS",
"status": {"status": "payment.pending_authorization"}}
})
Event payment_authorized
Event is called when payment has been authorized and should be completed soon. This event only applies to Payment flow.
window.Datamesh.on('payment.authorized', (response) => {
// response = {"type": "STATUS", "status": {"status": "payment.authorized"}}
})
Event payment_completed
Event is called when payment has been successful, merchant to show success messaging. This event only applies to Payment flow.
window.Datamesh.on('payment.completed', (response) => {
// response = {"type": "STATUS", "status": {"status": "payment.completed"}}
})
Event payment_failed
Event is called when payment has failed to complete. This event only applies to Payment flow.
window.Datamesh.on('payment.failed', (response) => {
// response = {"type": "STATUS", "status": {"status":"payment.failed}}
})
Event payment_encrypted
Event is called when a payment method has been successfully encrypted and available for merchant to fetch. This event only applies to Encryption flow.
window.Datamesh.on('payment.encrypted', (response) => { // response = {"type": "STATUS", "status": {"status":"payment.encrypted}, } "data" => { /*encrypted payload*/ }})