// This function is called when the payment is completed
function handlePaymentResponse(data) {
console.log(‘Payment completed!’, data);
// Merchant logic to handle payment response can be added here
}
// This function is called when the user navigates away from the checkout page
function handlePaymentCancellation() {
console.log(‘Payment Cancelled!’);
// Merchant logic to handle payment cancellation can be added here
}
// Initialize and open the BoxPayCheckout iframe with the provided token and callbacks
// `handlePaymentResponse` will handle successful payments or errors
// `handlePaymentCancellation` will handle the case where the user cancels the payment
BoxPayCheckout.open(‘https://test-checkout.boxpay.tech?token=’ + new URLSearchParams(window.location.search).get(‘token’), handlePaymentResponse, handlePaymentCancellation);