Direct Charge

Our standard payment process is known as Direct Charge. Direct Charge is what Developers gets to use.

In Direct charge, you would be redirected to our page with certain parameters. you would then be given a payment reference that you can use, then you would set an amount that you want to charge.

How it works:

  • Use your server to invoke our create payment endpoint and provide the payment particulars.

  • Once the payment is initiated, we will send you a link to a payment page. You can direct your customer to this page to complete the payment process.

  • After the payment is made, we will redirect the customer back to you.

The first step involves gathering all the necessary information.

To begin, you will have to gather the necessary payment information.

First, you need to assemble the payment details. Here are the details you'll need:

  • tx_ref: A unique reference code that you will create to distinguish this transaction from others.

  • amount: specify the amount to be charged to the customer and the currency in which the payment will be made. If you do not indicate a currency, we will assume that the payment will be made in NGN.

  • currency: specify the amount to be charged to the customer and the currency in which the payment will be made. If you do not indicate a currency, we will assume that the payment will be made in "NGN"

  • redirect_url: After the payment is completed, you'll need to provide the URL where the customer should be redirected.

  • customer: You'll need to supply a customer object that includes their email address; you can also include their name and phone number if you wish.

  • customizations (optional): If you want to customize the payment modal's appearance, you can use a customizations object to specify a title, logo, and description. This is optional.

To initiate the payment process, you'll need to use our API to send the payment details you've collected. Don't forget to authenticate with your secret key.

Example Request:

curl --location -g '{{base_url}}/api/d1/pay/direct-charge'
--data-raw '{
    "reference": "aargb2537489",
    "amount": 6700,
    "customer": {
        "email": "benjamin8@gmail.com",
        "name": "Mike Jeff",
        "phone": "+2348090089324"
    },
    "customizations": {
        "title": "Merry Square",
        "description": "Seamless Service Payments",
        "logo": "https://merrysquare.com/assets/icon.png"
    },
    "redirect_url": "https://merrysquare.com"
}'

In response, we'll provide you with a payment link which can be utilized by you to redirect your customers for making payments.

Example Response:

{
  "success": true,
  "link": "https://onionpay.com/pay/charge/v13V07v01v13v01R03v01B19D11v13n03n03v01"
}

Finally, after the payment is completed, four things will happen:

  1. Once the payment is completed, we will direct you to your specified redirect_url and include query parameters such as status, tx_ref, and transaction_id.

  2. If you have enabled webhooks, we will send you one. You can find additional information on webhooks and view examples by clicking here.

  3. If the payment is successful, we will send an email receipt to your customer, unless you have chosen to disable that option.

  4. Unless you have disabled it, we will send you an email notification.

On your server, you should handle the redirect and always verify the final state of the transaction.

Last updated