Skip to content

Callback functions

Callbacks are functions that you can provide to a method in the SDK which will give you feedback when an event occurs.

They can be useful when you want to record data & attributes at a particular stage of a transaction.

CallbackDescription
onSuccessInvoked when the transaction, claim (when applicable) & payment is successful.Warning: This callback will not be invoked if the user closes the modal before a successful transaction. You can use the invoiceCompleted Webhook to track the transaction outcome.
onFailureInvoked when the payment has failed.
onCancelInvoked when the payment has been rejected.
onClosedInvoked when the pop-up window has been closed by the user before approving or rejecting the payment.
  • When using the checkout SDK, users will need to pass a callbackOrigin(The URL of the booking website).
  • When using the SDK, do not pass through any callbackURLs as the SDK will fire callbacks at completion to your website.

Examples

import medipassCheckoutSDK from '@medipass/checkout-sdk';
// or: const medipassCheckoutSDK = require('@medipass/checkout-sdk');

medipassCheckoutSDK.init({
  env: 'stg',
  onSuccess: ({ transactionId }) => {
      // handle success
  },
  onFailure: ({ transactionId }) => {
      // handle failure
  },
  onCancel: ({ transactionId }) => {
      // handle cancel
  },
  onClose: () => {
      // handle close
  }
});