Validate Bank Account Checkout

Bank Account checkout Validation APIs allow your application to validate bank charge requests that deduct money from a customer's bank account. These APIs are currently only available in Nigeria on MasterCard and Verve cards.

Jump to:


How do I initiate an OTP Validation request? [Go Top]

You can initiate an OTP Validation request by sending a HTTP POST request to: https://payments.africastalking.com/bank/checkout/validate.

The following headers will be required for all requests

Header Description
apikey
String
Required
This is your Africa's Talking API Key

The body of the request should be a JSON object containing the following fields:

Field Description Sample Request
username
String
Required
This is your Africa's Talking username

{
  "username": "MyUsername"
  "transactionId": "ATPid_SampleTxnId1",
  "otp": "1234"
}
transactionId
String
Required
This value identifies the transaction that your application wants to validate. This value is contained in the response to the charge request.
otp
String
Required
This contains the One Time Password that the bank sent to the client that owns the bank account that is being charged

How does the API respond to a validation request? [Go Top]

The API responds to a validation request with a JSON response containing the fields shown below.

Field Description Sample Response
status
String
Mandatory
This corresponds to the FINAL status of this request. Possible values are:
  • Success: This means that the request has been accepted and the funds have been credited to your Payment Wallet.
  • Failed: Thie means that the checkout request has failed for some other reason. The description field will have more details on the reason.

{
  "status": "Success",
  "description": "Payment completed successfully"
}
description
String
Mandatory
This provides a detailed description of the request status


Sample code [Go Top]

You need your AfricasTalking username and APIKey for any request to our API. If you don't have an APIKey, please click here to get one.
For sandbox APIKey, click here

Bank Checkout Validtion in PHP

The PHP code snippet below shows how to initiate a Bank Checkout Validation request using our API

The code uses our PHP gateway class: AfricasTalkingGateway.php [ Download]

Also, please ensure that you have the php_curl module enabled. To enable it uncomment the line: ;extension=php_curl.dll in php.ini and restart apache

<?php
require_once "AfricasTalkingGateway.php";

//Specify your credentials
$username = "my-apps-username";
$apikey   = "my-apps-apikey";
		
//Create an instance of our awesome gateway class and pass your credentials
$gateway = new AfricasTalkingGateway($username, $apikey);
// NOTE: If connecting to the sandbox, please add the sandbox flag to the constructor:
// $gateway = new AfricasTalkingGateway($username, $apiKey, "sandbox");

// Provide the transacitonId that was returned by the charge request
$transactionId = "ATPid_7444b64859882dca9ee9621276fc7c7f";
// Provide the OTP that the bank sent to the owner of the bank account
$otp           = "1234";

try {
  // Initiate the checkout. If successful, you will get back a transactionId
  $gateway->bankPaymentCheckoutValidation($transactionId,
					  $otp);
  echo "The transaction was completed successfully";
}
catch(AfricasTalkingGatewayException $e){
  echo "Received error response: ".$e->getMessage();
}
    

Bank Checkout Validtion in Python

The PHP code snippet below shows how to send a checkout charge request using our API

The code uses our Python gateway class: AfricasTalkingGateway.py [ Download]

# Import the helper gateway class
from AfricasTalkingGateway import AfricasTalkingGateway, AfricasTalkingGatewayException

#Specify your credentials
username = "MyAfricasTalkingUsername"
apiKey   = "MyAfricasTalkingApiKey"

#Create an instance of our awesome gateway class and pass your credentials
gateway = AfricasTalkingGateway(username, apiKey, "sandbox")

#*************************************************************************************
#  NOTE: If connecting to the sandbox:
#
#  1. Use "sandbox" as the username
#  2. Use the apiKey generated from your sandbox application
#     https://account.africastalking.com/apps/sandbox/settings/key
#  3. Add the "sandbox" flag to the constructor
#
#  gateway = AfricasTalkingGateway(username, apiKey, "sandbox");
#**************************************************************************************

try:
    # Initiate the request with the transacitonId that was returned
    # by the charge request. If there are no exceptions, that means
    # the transaction was completed successfully
    gateway.bankPaymentCheckoutValidation(
        transactionId_ = 'ATPid_14963d9d924c7f200421a47d4f79e94c',
        otp_           = "1234"
        )
    print 'The transaction was completed successfully'
    
except AfricasTalkingGatewayException, e:
    print 'Encountered an error while sending: %s' % str(e)