• Create an account on Payunit as a merchant. Click to create an account (opens in a new tab).
  • Get the merchant Api user, merchant API key and merchant API password from the merchant dashboard under Settings > Security.


pip install payunit


Now, proceed to creating a payment instance with payUnit().

from  payUnit import payUnit
from flask import Flask,render_template,request
app = Flask(__name__)
payment = payUnit({
    "return_url": "",
    "mode": "",
    "name": "",
    "description": "",
    "purchaseRef": "",
    "currency": "",
   "transaction_id":  ""
# main driver function
if __name__ == '__main__':

That set, payments can now be done by using makePayment() method, with the transaction amount as parameter.




To test Visa/Master Card in the Sandbox environment use the following Card Number
4242 4224 2424 2424 or 2223 0000 4840 0011
To test PayPal in the Sandbox environment use the following credential :
Email[email protected] password: ehQ5\_)dA

api_usernameMerchant Api Username gotten from merchant dashboard under credentials sectionyes
api_passwordMerchant Api Password  gotten from merchant dashboard under credentials sectionyes
api_keyMerchant Api Key gotten from merchant dashboard under credentials sectionyes
modeThe current mode operation. Can either be "test" when testing in sandbox or "live" when ready for production.yes
return_urlThe url or endpoint to be called upon payment completionyes
notify_urlThe url or endpoint to submit a transaction response to.
purchaseRefA reference which you can give from your end to a particular transactionno
total_amountThe amount or price of the product/products to be paid for.yes
descriptionA description you can give to this type of  transactionno
nameName of the merchantyes
currencyCan be XAF, USD or any currently supported currencyyes
transactionIdid that uniquely identifies the transaction and I must be unique for a transaction. This id should be alpha numeric and less than 20 charactersyes

If everything is put in place, a call to the PayUnit API will be made and if the request turns out successful, you will be redirected to the PayUnit payment interface. The interface is shown below.


For security concerns, make sure you read your API key, API password and API user from a config file.

Consider saving your API credentials in environment variables for an extra layer of security. You can find a Flask demo app using payunit on gitlab (opens in a new tab)

Last updated on March 21, 2023