The whole integration is two server-side requests and a redirect. The samples on the right run the full flow in PHP (Guzzle), cURL and Node.js — pick one and swap in your own values.
A complete working integration is on GitHub: QRPay-Gateway-Example.
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
// 1. Get an access token (expires in 600s)
$response = $client->request('POST',
'{{base_url}}/authentication/token', [
'json' => [
'client_id' => '{{client_id}}',
'secret_id' => '{{secret_id}}',
],
'headers' => [
'accept' => 'application/json',
'content-type' => 'application/json',
],
]);
$accessToken = json_decode(
$response->getBody(), true
)['data']['access_token'];
// 2. Create the payment — amount is a string
$response = $client->request('POST',
'{{base_url}}/payment/create', [
'json' => [
'amount' => '100.00',
'currency' => 'USD',
'return_url' => 'https://example.com/order/done',
'cancel_url' => 'https://example.com/order/cancel',
],
'headers' => [
'Authorization' => 'Bearer ' . $accessToken,
'accept' => 'application/json',
'content-type' => 'application/json',
],
]);
$data = json_decode($response->getBody(), true)['data'];
// 3. Store $data['token'] against your order,
// then redirect to the hosted checkout
header('Location: ' . $data['payment_url']);
exit;# 1. Get an access token (expires in 600s)
curl -X POST '{{base_url}}/authentication/token' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"client_id": "{{client_id}}",
"secret_id": "{{secret_id}}"
}'
# 2. Create the payment — amount is a string
curl -X POST '{{base_url}}/payment/create' \
-H 'Authorization: Bearer {{access_token}}' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"amount": "100.00",
"currency": "USD",
"return_url": "https://example.com/order/done",
"cancel_url": "https://example.com/order/cancel"
}'
# 3. Open data.payment_url in the browserconst BASE_URL = '{{base_url}}';
// 1. Get an access token (expires in 600s)
const tokenRes = await fetch(
`${BASE_URL}/authentication/token`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
client_id: '{{client_id}}',
secret_id: '{{secret_id}}',
}),
});
const { data: { access_token } } = await tokenRes.json();
// 2. Create the payment — amount is a string
const payRes = await fetch(`${BASE_URL}/payment/create`, {
method: 'POST',
headers: {
Authorization: `Bearer ${access_token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
amount: '100.00',
currency: 'USD',
return_url: 'https://example.com/order/done',
cancel_url: 'https://example.com/order/cancel',
}),
});
const { data } = await payRes.json();
// 3. Store data.token against your order,
// then redirect the customer
// res.redirect(data.payment_url);{
"token": "2zMRmT3KeYT2BWMAyGhqEfuw4tOYOfGX...",
"trx_id": "BP2c7sAvw75MTlrP",
"payer": {
"username": "testuser",
"email": "user@appdevs.net"
}
}