ModemPayCheckout()
in detail:
Field | Description | Example |
---|---|---|
amount | The amount to be charged. | 450 (for GMD 450.00) |
currency | The transaction currency (default: GMD). | "GMD" |
payment_methods | Available payment methods (card , wallet , bank ). | "card,wallet,bank" |
title | A short title describing the transaction. | "Course Payment" |
description | Detailed description of the transaction. | "Access to Premium Content" |
customer | A unique identifier for the customer. | "7e1908bb-bd62-4d20-9af7-3463a150fd98" |
customer_email | Customer’s email address. | "customer@example.com" |
customer_name | Full name of the customer. | "John Doe" |
customer_phone | Customer’s phone number. | "7000000" |
metadata | A JSON object for additional payment information. | { "order_id": "98765" } |
return_url | URL to redirect to after successful payment. | "https://yourwebsite.com/success" |
cancel_url | URL to redirect to if the payment is canceled. | "https://yourwebsite.com/cancel" |
callback | Function to handle post-payment actions. | (transaction) => { ... } |
onClose | Function to handle when the modal is closed or payment is canceled. | (cancelled) => { ... } |
callback
and onClose
functions. The callback
function sends a verification request to the backend in the background. Meanwhile, the onClose
function handles the modal closure by displaying a “verifying” message if the background request is still in progress, or a thank-you message if the verification succeeds. If the verification fails, the user is prompted to retry or contact support.
View: https://codepen.io/mercury-sms/embed/EaYNGOv
callback
: Handling Successful Paymentscallback
function allows you to perform actions after a successful payment. For instance, you can verify the transaction, send a confirmation email, or update your database. The transaction
parameter contains essential information about the payment.
redirect_url
takes priority over the callback
. If both are provided, the redirect_url
will be used.callback
function is triggered after the payment is completed, even while the modal remains open. For an enhanced user experience, you can combine the callback
with the onClose
handler.onClose
: Handling Payment CancellationsonClose
function is invoked when the customer cancels the payment by closing the modal. This is particularly useful for logging or notifying users of incomplete transactions.
callback
, return_url
, and onClose
return_url
vs callback
:return_url
will take precedence, and the user will be redirected to the specified URL after the payment instead of executing the callback
function.
cancel_url
vs onClose
:cancel_url
is provided, it overrides the onClose
function, and the user will be redirected to the specified URL upon cancellation.
callback
and onClose
, you gain full control over the payment flow and can provide a seamless experience tailored to your users’ needs.