Initialize payment
This action allows you to initiate a payment request to your customers
Making the API calls
Identification informations:
All requests to the Payunit REST API must be authenticated. payunit supports two forms of authentication, both using HTTP basic authentication, which use the following username/password schemes:
- API USER and API PASSWORD
- Application token
BASE_URL : https://gateway.payunit.net (opens in a new tab)
Http headers : HTTP header specifications for all API calls.
HTTP Header | Description |
---|---|
Content-Type | Content type supported is : application/json |
Authorization | Http basic Auth encoded in Base 64 and formatted as follow : Basic Base64(api_user:api_password) |
x-api-key | Your application token |
mode | live or test. The current mode of your application |
Request to initialize a transaction on Payunit
curl --location --request POST '{{base_url}}/api/gateway/initialize' \
--header 'x-api-key: live_xxxxxxxxxxxxxxx' \
--header 'mode: live' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic xxxxxxxxxx' \
--data-raw '{
"total_amount" : 10000,
"currency" : "XAF",
"transaction_id" : "puXXXXXX",
"return_url" : "https://webhook.site/d457b2f3-dd71-4f04-9af5-e2fcf3be8f34",
"notify_url":"https://webhook.site/d457b2f3-dd71-4f04-9af5-e2fcf3be8f34"
"payment_country":"CM"
}'
End point: {BASE_URL}/api/gateway/initialize
Request method: POST
⚠️
All URLs must utilize HTTPS protocol { return_url, notify_url }; otherwise, the requests will not be successful.
Request body :
Parameter | Mandatory | Description |
---|---|---|
total_amount | Yes | The amount to be paid by the user |
transaction_id | Yes | The unique identifier that identifies the transaction in your system, example SDK4587295,special characters will cause an issue with orange money payments |
currency | Yes | The currency you want to use: XAF |
return_url | Yes | The url or the endpoint where the customer will be redirected at the end of the payment if you use hostedpage |
notify_url | No | Notification webhook of the payment result to your server by payunit |
payment_country | No | Alpha country code used to display only providers of that country. eg: CM |
Response body:
{
"status": "SUCCESS",
"statusCode": 200,
"message": "Transaction created!",
"data": {
"t_id": "N2M0NTk2ZDk3ZTBiMTdhZGY0NDAzOWRl",
"t_sum": "MzkwMA==",
"t_url": "xxxxWJkOGI3ZGUxZDdlZjE0YmQ5MGQxM2EzNjFmYTk3YWM1Nzc1MDRiZGE=",
"transaction_id": "pu-xxxxx-xxxx",
"transaction_url": "http://<url>/#/hostedPayment/payment?t_id=N2MxxRiZGE=",
"providers": [
{
"shortcode": "CM_ORANGE",
"name": "ORANGE MONEY",
"logo": "https://<bucket_image_url>/resources/flags/orange.png",
"status": "ACTIVE",
"country": {
"country_name": "Cameroon",
"country_code": "CM"
}
}
]
}
}
Parameter | Description |
---|---|
t_id | The identifier of the transaction that was encrypted. |
t_sum | The amount to be collected that has been encrypted |
t_url | The return url that has been encrypted. |
transaction_url | The return url that leads the user to the hostedpages payment platform. |
Providers | the list of all subscribed providers |
Last updated on December 1, 2024