Web Payment Integration
Web Payment Integration
This document describes how to initiate a payment request and process the payment notification
after the payment has been executed by the payer.
Environment URLs
The payment link is a URL that displays the web payment page. The base URL to invoke for
process payment depends of environment used.
Below is an example of a URL that allows you to start a payment by your customer :
https://pay.centralbill.app/?applicationId=fbab3ccc-719e-11ed-93ad-
02420a0003c1&invoice[id]=1&invoice[customerId]=johndoe%40example.com&invoice[tot
alAmount][amount]=100&invoice[totalAmount][currency]=XOF&invoice[issuedAt]=2022-
12-12T00%3A00%3A00%2B00%3A00&invoice[dueDate]=1970-01-
01T00%3A00%3A00%2B00%3A00&description=ACME+-
+Facture+%23107285&signature=9407f193b8a53f68e6184ef28cffc7a7524cff81d6e6dd7
6a4c624b990a3e1cf&callbackUrl=https%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Facme.net%2Fmodules%2Fgateway
s%2Fcallback%2Fcentralbill.php&redirectUrl=https%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Facme.net%2Fviewinvoic
e.php%3Fid%3D1
invoice[totalAmount]
float The total amount to be paid for the invoice.
[amount]
The date on which the invoice was issued. The date must
invoice[issuedAt] string
be in ISO 8601 format.
The date on which the invoice will be due. The date must
invoice[dueDate] string
be in ISO 8601 format.
callbackUrl
string The callback URL where the payment notification is sent.
(Optional)
redirectUrl
string The URL where the customer is redirected after payment.
(Optional)
To generate a payment signature you must combine the following payment informations:
application.id , invoice.id , invoice.customerId , invoice.totalAmount.amount ,
The identifier and secret of the application can be retrieved from your administration console.
$applicationId = 'fbab3ccc-719e-11ed-93ad-02420a0003c1';
$applicationSecret = 'app!secret';
$invoiceId = '1';
$invoiceCustomerId = '[email protected]';
$invoiceTotalAmountAmount = 1000;
$invoiceTotalAmountCurrency = 'XOF';
$signature = hash('sha256', sprintf(
'%s,%s,%s,%s,%s,%s',
$applicationId,
$invoiceId,
$invoiceCustomerId,
$invoiceTotalAmountAmount,
$currency,
$applicationSecret
));
A payment notification is sent after each payment to a callback url configured either in your
dashboard or defined in the payment link.
Response codes
Success
Code Reason
Error
Code Reason
403 - Forbidden Policy does not allow current user to do this operation.
Request parameters
Content-Type header string Set the MIME type for the request.
Transaction status
Name Description
-H 'Signature: keyId="fbab3ccc-719e-11ed-93ad-02420a0003c1",algorithm="hmac-
sha256",headers="(request-target) content-type date
digest",signature="fiFBCK8NWWhvk6fJul8ezzpVXSh9q30VRO8qn3XGxTQ="' \
-H 'Authorization: Signature keyId="2bc56634-673c-11ed-acf4-
"payment": {
"id": "63a368858622d5ded108e4b2",
"type": "full",
"application": {
"id": "b3695b9c-816b-11ed-8083-32706358435f",
"name": "banking"
},
"invoice": {
"id": "1",
"customerId": "1",
"totalAmount": {
"amount": 1000,
"currency": "XOF"
},
"issuedAt": "2022-12-21T20:11:49+00:00"
},
"extras": [],
"totalAmountAlreadyPaid": {
"amount": 1000,
"currency": "XOF"
}
},
"invoice": {
"id": "1",
"customerId": "1",
"totalAmount": {
"amount": 1000,
"currency": "XOF"
},
"issuedAt": "2022-12-21T20:11:49+00:00"
},
"paymentFee": {
"amount": 0,
"currency": "XOF"
},
"result": {
"origin": "processor",
"status": "COMPLETED"
}'
The Instant Payment Notification (IPN) request is secured from HTTP Signature Authentication.
Below is an example code in PHP to handle payment notification request :
// Fetch application secret configuration parameters.
$applicationSecret = 'app!secret';
$transactionStatus = $body['result']['status'];
$invoiceId = $body['invoice']['id'];
$invoiceTotalAmount = $body['invoice']['totalAmount']['amount'];
$paymentFee = $body['paymentFee']['amount'];
/**
$components = [];
continue;
die('Payment failed');
$signature = [];
}
if (false === hash_equals(base64_encode(hash_hmac('sha256', implode(\PHP_EOL,
die('Payment failed');
}
/**
*/
if ('COMPLETED' !== transactionStatus) {
die('Payment failed');
}
Transaction Status
Value Description