Integrations Guides
Accept Payment

Accept Payment

This document covers payment transaction and its establishment with the help of our API, Javascript library, Popup Js or our SDKs.

When accepting a payment, a transaction is established and following every transaction carries out a complete payment method.

Collecting Customer Information

Before carrying out the transaction, a user must provide required information such as full name, email address, the amount to transfer, etc. Below you will find a list of parameter needed:

ParameterDescription
amountThe amount you will be charging your customer.
phone_number Required For Risky Businesses The customer's phone number

Phone number is not required, but if you pass phone_number, it must be 10 digits, so it should be in 09xxxxxxxx or 07xxxxxxxx format.

Initialize the Transaction and Get a payment link

Once all the information needed to proceed with the transaction is retrieved, the action taken further would be to associate the following information into the javascript function(chosen language) which will innately display the checkout.

Endpoint https://api.chapa.co/v1/transaction/initialize

Method POST

  • Authorization : Pass your secret key as a bearer token in the request header to authorize this call.
import requests    import json          url = "https://api.chapa.co/v1/transaction/initialize"    payload = {    "amount": "10",    "currency": "ETB",    "email": "abebech_bekele@gmail.com",    "first_name": "Bilen",    "last_name": "Gizachew",    "phone_number": "0912345678",    "tx_ref": "chewatatest-6669",    "callback_url": "https://webhook.site/077164d6-29cb-40df-ba29-8a00e59a7e60",    "return_url": "https://www.google.com/",    "customization": {    "title": "Payment for my favourite merchant",    "description": "I love online payments"    }    }    headers = {    'Authorization': 'Bearer CHASECK-xxxxxxxxxxxxxxxx',    'Content-Type': 'application/json'    }          response = requests.post(url, json=payload, headers=headers)    data = response.text    print(data)

ℹ️
Refer to our Error Codes page for all responses for this request.

Redirect the user to the payment link

Now all you need to do is redirect your customer to the link returned in data.checkout_url, and we'll display our checkout modal for them to complete the payment.

Hello

After the payment

Four things will happen when payment is done (successful):

  1. We'll redirect to your set return_url if set.
  2. The callback_url will return status, and tx_ref after payment is complete.
  3. We'll send you a webhook if you have that enabled. You can find more information on Webhooks here.
  4. We'll send you an email notification (unless you've disabled that).

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

Verify Transaction

It is important to verify the transaction and confirm its status. Here is how you can Verify a Transaction.

Webhook

Chapa has event listeners that will send a message whenever a payment is successful. You can find more information on Webhooks here.

Redirection

The Initialization transaction API is used for redirection. When users go for check out, it generates a link that redirects them to the payment page. Once the payment has been made the users are redirected back to the website.