Charge a purchase using a saved token.
https://gate.qorepay.com/api/v1/purchases/{id}/charge
Charge a purchase using a recurring_token
provided in the request body. Its value should be an id of a Purchase that has is_recurring_token
== true
. This purchase will be paid using the same method (e.g. same card) as the one used to pay therecurring_token
purchase.
If this operation takes too long to be processed on the acquirer side - you will get a response with status code 200
and a Purchase object having status
= pending_charge
in body (you will receive a corresponding Webhook callback too for a purchase.pending_charge
event). To be notified of a successful operation completion, please subscribe to purchase.paid callback event - it will deliver an updated Purchase with status = paid. Alternatively, if charge fails, you will receive a purchase.payment_failure
callback event.
If recurring charge fails due to payment processing error, you will receive HTTP response code 400
with error codepurchase_charge_error
. In this case, to get more details about the error, you should perform a GET
/purchase/
request for the Purchase you tried to charge. In transaction_data.attempts[]
array (newest element first) you'll find the corresponding attempt with error code and description in .error
parameter.
HEADER PARAMS
authorization
String
required
Set value to
BEARER SECRET_KEY
content-type
String
required
Set value to
JSON
PATH PARAMS
id
string
required
ID associated with the payment. This is usually returned when you call the
POST
/purchases
endpoint to register or initialize a payment.
REQUEST BODY
recurring_token
string
ID of a recurring token (Purchase having
is_recurring_token
==true
) to use.
RESPONSES
200
OK
400
Invalid data submitted or request processing error
404
No such object
Query
Javascript
const options = {
method: 'POST',
headers: {
accept: 'application/json'
},
body: JSON.stringify({
recurring_token: 'token'
})
};
fetch('https://gate.qorepay.com/api/v1/purchases/id/charge', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
Sample Response
JSON
const options = {
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json'
},
body: JSON.stringify({
client: {
email: '[email protected]',
phone: '+2349053693367',
full_name: 'Felix Qorepay',
street_address: '20 Kigali road.',
country: 'NG',
city: 'Yaba'
},
purchase: {
products: [
{
quantity: '2',
name: 'Dog food',
price: 230000
}
],
},
send_receipt: true,
brand_id: '4343434344334343434',
success_redirect: 'https://www.qore.test',
failure_redirect: 'https://www.qore.test.fail'
})
};
fetch('https://gate.qorepay.com/api/v1/purchases/', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));