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.

Callback Description
onSuccess Invoked 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.
onFailure Invoked when the payment has failed.
onCancel Invoked when the payment has been rejected.
onClosed Invoked when the pop-up window has been closed by the user before approving or rejecting the payment.

Examples

Copy
Copied
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
  }
});
2024 Copyright © Tyro Health and Tyro Payments 2024. All right reserved.