Rest API
Initialize payment

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 HeaderDescription
Content-TypeContent type supported is : application/json
AuthorizationHttp basic Auth encoded in Base 64 and formatted as follow : Basic Base64(api_user:api_password)
x-api-keyYour application token
modelive 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 :

ParameterMandatoryDescription
total_amountYesThe amount to be paid by the user
transaction_idYesThe unique identifier that identifies the transaction in your system, example SDK4587295,special characters will cause an issue with orange money payments
currencyYesThe currency you want to use: XAF
return_urlYesThe url or the endpoint where the customer will be redirected at the end of the payment if you use hostedpage
notify_urlNoNotification webhook of the payment result to your server by payunit
payment_countryNoAlpha 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"
				}
			}
		]
	}
}
ParameterDescription
t_idThe identifier of the transaction that was encrypted.
t_sumThe amount to be collected that has been encrypted
t_urlThe return url that has been encrypted.
transaction_urlThe return url that leads the user to the hostedpages payment platform.
Providersthe list of all subscribed providers
Last updated on December 1, 2024