API ReferenceIntegrationsKnowledge Base

Custom Web Integration - Create Async Payment

Since the createPayment method has to be called synchronously within user initiated action, the aforementioned method doesn't work if the pop up blocker is enabled. If you need to perform any asynchronous operation such as sending an AJAX request before starting payment, you can decouple popup opening and payment creation.

Copyrp.createPayment(data, { paused: true, message: 'Confirming order..' });

Now you can make AJAX requests. Once it is done, you can emit resume or cancel event:

Copyif(ajax_success) { rp.emit('payment.resume'); } else { rp.emit('payment.cancel'); }

Format of data object, and success/error handlers remain the same as before.

payment.resume
Event initiates the usual payment process and emits payment.success or payment.error events according to result of payment.
payment.cancel
Razorpay will not initiate the payment.
×