Creates a new payment session and returns a payment URL to redirect your customer to.
{{base_url}}/payment/create
payment_url and a token.payment_url.return_url or cancel_url.| Parameter | Type | Required | Description |
|---|---|---|---|
amount |
decimal | Required | Payment amount, rounded to 2 decimal places (e.g. 5000.00) |
currency |
string | Required | ISO 4217 currency code in UPPERCASE (e.g. XAF, USD, EUR) |
return_url |
string | Required | Full HTTPS URL to redirect after successful payment |
cancel_url |
string | Optional | Full HTTPS URL to redirect if the customer cancels |
custom |
string | Optional | Your internal order/transaction ID for reconciliation |
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', '{{base_url}}/payment/create', [
'json' => [
'amount' => '5000.00',
'currency' => 'XAF',
'return_url' => 'https://yoursite.com/payment/success',
'cancel_url' => 'https://yoursite.com/payment/cancel',
'custom' => 'ORDER-20240101-001',
],
'headers' => [
'Authorization' => 'Bearer {{access_token}}',
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
]);
$result = json_decode($response->getBody(), true);
// Redirect customer to payment page
header('Location: ' . $result['data']['payment_url']);
exit;
// Works with Node.js, Next.js (API routes), browser fetch
const initiatePayment = async () => {
const response = await fetch('{{base_url}}/payment/create', {
method: 'POST',
headers: {
'Authorization': 'Bearer {{access_token}}',
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
amount: '5000.00',
currency: 'XAF',
return_url: 'https://yoursite.com/payment/success',
cancel_url: 'https://yoursite.com/payment/cancel',
custom: 'ORDER-20240101-001',
}),
});
const data = await response.json();
// Redirect customer to the payment page
window.location.href = data.data.payment_url;
};
// Next.js API route example (pages/api/checkout.js):
// export default async function handler(req, res) {
// const data = await initiatePayment(req.body);
// res.json({ payment_url: data.data.payment_url });
// }
import requests
url = "{{base_url}}/payment/create"
payload = {
"amount": "5000.00",
"currency": "XAF",
"return_url": "https://yoursite.com/payment/success",
"cancel_url": "https://yoursite.com/payment/cancel",
"custom": "ORDER-20240101-001",
}
headers = {
"Authorization": "Bearer {{access_token}}",
"Accept": "application/json",
"Content-Type": "application/json",
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
# Redirect the customer (Flask/Django example)
payment_url = data["data"]["payment_url"]
# return redirect(payment_url) # Flask
# return HttpResponseRedirect(payment_url) # Django
print("Redirect to:", payment_url)
curl -X POST "{{base_url}}/payment/create" \
-H "Authorization: Bearer {{access_token}}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"amount": "5000.00",
"currency": "XAF",
"return_url": "https://yoursite.com/payment/success",
"cancel_url": "https://yoursite.com/payment/cancel",
"custom": "ORDER-20240101-001"
}'
200 OK Success
{
"message": {
"code": 200,
"success": ["CREATED"]
},
"data": {
"token": "2zMRmT3KeYT2BWMAyGhq...",
"payment_url": "https://quatapay.com/pay/v1/form/2zMRmT3KeYT2BWMAyGhq..."
},
"type": "success"
}
403 Forbidden Error
{
"message": {
"code": 403,
"error": [
"Requested with invalid token!"
]
},
"data": [],
"type": "error"
}