Direct Post
Introduction
Direct post integration allows running payments through the custom payment flow.
To accept payments in your applications or websites via QorePay, follow these steps:
Step 1: Initiate Purchase
The first step in accepting card payments is to call the /purchases endpoint below. The return object will include the direct_post_url parameter. This parameter will be used in the next step.
| Request | URL |
|---|---|
POST | https://gate.qorepay.com/api/v1/purchases/ |
- Remember to specify the
success_redirectandfailure_redirecturl in the request body.
JSON
{
brand_id: '409eb80e-3782-4b1d-afa8-b779759266a5'
client: {
email: '[email protected]',
},
purchase: {
currency: 'NGN',
products: [
{
name: 'Dog food Max',
quantity: 1,
price: 9000
}
],
},
failure_redirect: 'http://brand.com/failed-payment',
success_redirect:'http://brand.com/sucess-payment',
}
Step 2: Charge Card
In order to charge the user, we'll need to create a form to accept the card details. The form should be on your website with the method="POST" and the form action pointing to the direct_post_url we got from the previous API call in step 1.
| Request | URL |
|---|---|
POST | https://gate.qorepay.com/p/Insert_direct_post_url/ |
You will also need to fill the form with inputs for the fields with card details. These will be posted directly to our systems, allowing you to focus on customizing the checkout as you wish.
HTML
<!DOCTYPE html>
<html>
<body>
<h2>Card Direct Post</h2>
<form action="https://gate.qorepay.com/p/{{Insert direct_post_url}}/" method="POST">
<label for="fname">Cardholder Name:</label><br>
<input type="text" id="cardholder_name" name="cardholder_name" value="Input"><br><br>
<label for="lname">Card number:</label><br>
<input type="text" id="card_number" name="card_number" value="Input"><br><br>
<label for="lname">Expires:</label><br>
<input type="text" id="expires" name="expires" value="Input"><br><br>
<label for="lname">CVC:</label><br>
<input type="text" id="cvc" name="cvc" value="Input">
<br><br>
<button type="submit">submit </button>
</form>
</body>
</html>
Step 3: Verify Payment
To verify your payment status, do either of these things:
Using
success_callbackParameter:When initializing payment in step 1, add the
success_callbackparameter and a correspondingPOSTurl. When Purchase is paid for successfully, the success_callback URL will receive a POST request with the Purchase object's data in body.Using GET
/purchases/purchase_idrequest:This endpoint retrieves a payment object using the
purchase_idreturned in step 1. Use thestatusparameter to know the state of the payment.Using a webhook
Setup a webhook on your account's developers section or a Webhook API to listen to
purchase.paid, orpurchase.payment_failureevent on your server.