Standard Payment Flow
Introduction
QorePay's standard payment flow empowers merchants to utilize a hosted and secure payments page. Merchants can seamlessly guide their customers to initiate and complete payments through this purpose-built interface.
Initiate and Capture Payment
To create a Purchase specify the Brand ID and API key. You can find both in the Developers section of your account.
- To get started, make a
/POST
request to/purchases
. This registers the payment and returns the checkout linkcheckout_url
. - Redirect the customer to the
checkout_url
to enter their card details for processing. - After the payment is processed, the system will redirect the customer back to your website (take note of success_redirect, failure_redirect).
See example below:
Javascript
1const options = {
2 method: 'POST',
3 headers: {
4 accept: 'application/json',
5 'content-type': 'application/json',
6 authorization; 'Bearer your token'
7 },
8 body: JSON.stringify({
9 client: {
10 email: '[email protected]',
11 },
12 purchase: {
13 currency: 'NGN',
14 products: [{name: 'Dog food Max', quantity: 1, price: 9000}],
15 },
16 brand_id: '409eb80e-3782-4b1d-afa8-b779759266a5'
17 failure_redirect: 'http://brand.com/failed-payment',
18 success_redirect:'http://brand.com/sucess-payment',
19 })
20};
21
22fetch('https://gate.qorepay.com/api/v1/purchases/', options)
23 .then(response => response.json())
24 .then(response => console.log(response))
25 .catch(err => console.error(err));
26
Verify Payment
The callback method is triggered when the transaction is completed. You have three options to check payment status:
- Use the
success_callback
parameter of the Purchase object. - Use GET
/purchases/purchase_id
request. - Set up a Webhook using your account's Developers section or Webhook API to listen to
purchase.paid
, orpurchase.payment_failure
event on your server.
See example below:
Javascript
1const options = {
2 method: 'GET',
3 headers: {
4 accept: 'application/json',
5 authorization; 'Bearer your token'
6 },
7};
8
9fetch('https://gate.qorepay.com/api/v1/purchases/1234-5678-2328', options)
10 .then(response => response.json())
11 .then(response => console.log(response))
12 .catch(err => console.error(err));
13