2. Redirect to payment page.
A link like this can be used to redirect to an individual page:
https://widget.lunupay.com/#/?action=select&cancel=https:%2F%2Fwebsite.com%2Fcancel&success=https:%2F%2Fwebsite.com%2Fsuccess&token=922a2f06-6bec-4eee-a55c-76d549f46262
Variant of the static widget page
Template for generating the URL of a static widget page in PHP:
// $widget_url = 'https://widget.lunupay.com';
$widget_url = 'https://widget.sandbox.lunupay.com'; // a variant of the static widget page, in this example "testing"
$confirmation_token = $payment['confirmation_token'];
$payment_page_url = $widget_url . '/#/?' . http_build_query(array(
'action' => 'select',
'token' => $confirmation_token, // substitute the time token received when creating the payment
'success' => $success_url, // setting the address of the page to which the widget will redirect when the payment is successful
'cancel' => $cancel_url, // setting the address of the page to which the widget will be redirected when it closes without paying
));
Other ways of displaying the payment widget on the page
Use NPM package in your front-end application.
const {
openPaymentWidgetInCurrentWindow,
} = require('lunu-payment');
const removeWidget = openPaymentWidgetInCurrentWindow({
confirmation_token: '8cae7ede-944c-49b8-8a55-2a1116f70631',
callbacks: {
payment_paid: (paymentInfo) => {
// Handling a successful payment event
},
payment_cancel: () => {
// Handling a payment cancellation event
},
payment_close: () => {
// Handling the event of closing the widget window
}
},
});
// Cancel the opening of the widget or remove the widget if it is already open.
// removeWidget();
More about this method here.