Bank Checkout Validate

Below is an illustration on how the bank checkout validate service works

BANK CHECKOUT VALIDATE

Bank checkout validation APIs allow your application to validate bank checkout charge requests. Initiate a bank checkout validate request by making a HTTP POST request to one of the following endpoint:

Endpoints

Live:https://payments.africastalking.com/bank/checkout/validate
Sandbox:https://payments.sandbox.africastalking.com/bank/checkout/validate

Please note: These APIs are currently only available in Nigeria on MasterCard and Verve cards.

Request Parameters

In addition to the standard request header, the body of the request should be a JSON object containing the following fields:

Parameter Description
username
String
Required
Africa's Talking application username.
transactionId
String
Required
The id of the transaction that your application wants to validate. This value is contained in the response to a bank checkout charge request.
opt
String
Required
The One Time Password that the bank sent to the client that owns the bank account being charged.
{
    "username": "MY-APPS-USERNAME",
    "transactionId": "ATPid_SampleTxnId123",
    "otp": "1234"
}

Bank Checkout Validate Response

The body of the response will be a JSON object containing the following fields:

Parameter Description
status
String
The final status of this request. Possible values are:
  • Success: The request has been accepted and the funds have been credited to your applications payment wallet.
  • Failed: The request failed for some other reason. The description filed will contain more information.
description
String
A detailed description of the request status.
{
    "status": "Success",
    "description": "Payment completed successfully"
}

Bank Checkout Validation Sample code

The PHP code snippet below shows how to initiate a bank checkout validate request.

The code uses our PHP SDK.

<?php
require 'vendor/autoload.php';
use AfricasTalking\SDK\AfricasTalking;

// Set your app credentials
$username   = "MyAppsUsername";
$apikey     = "MyAppAPIKey";

// Initialize the SDK
$AT         = new AfricasTalking($username, $apiKey);

// Get the payments service
$payments   = $AT->payments();

// Set the transactionId you got from the
// bank checkout charge request
$transactionId = "someTransactionId";

// Set the OTP given to you by the user you're charging
$otp           = "1234",

try {
    // That's it, hit send and we'll take care of the rest
    $result = $payments->bankCheckoutValidate([
        "transactionId" => $transactionId,
        "otp"           => $otp
    ]);

    print_r($result);
} catch (Exception $e) {
    echo "Error: ".$e->getMessage();
}

The Java code snippet below shows how to initiate a bank checkout validation request using our API

The code uses our Java SDK.

/* Import SDK classes */
import com.africastalking.Callback;
import com.africastalking.AfricasTalking;
import com.africastalking.PaymentService;
import com.africastalking.payment.response.CheckoutResponse;
import com.africastalking.payment.response.CheckoutValidateResponse;

import java.util.HashMap;
import java.util.List;
import java.io.IOException;

public class TestBankCheckoutValidate
{
    public static void main(String[] args)
    {
		/* Your app credentials */
		String USERNAME = "sandbox";
		String API_KEY = "";

		/* Initialize SDK */
		AfricasTalking.initialize(USERNAME, API_KEY);

		/* Get the payments service */
		PaymentService payment = AfricasTalking.getService(AfricasTalking.SERVICE_PAYMENT);

        /* Set the transactionId you got from the bank checkout charge request */
        String transactionId = "someTransacionsId";

		/* Set the OTP given to you by the user you're charging */
		String otp = "some_otp_from_user";

		/* That's it, hit send and we'll take care of the rest */
		try {
            CheckoutValidateResponse validation = payment.bankCheckoutValidate(transactionId, otp);
            System.out.println(validation.toString());
		} catch(Exception ex) {
			ex.printStackTrace();
		}
   	}
}

Bank Checkout Validtion in Python

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

The code uses our Python SDK.

# works with both python 2 and 3
from __future__ import print_function

import africastalking

class BANK:
    def __init__(self):
		# Set your app credentials
        self.username = "YOUR_USERNAME"
        self.api_key = "YOUR_API_KEY"
		# Initialize the SDK
        africastalking.initialize(self.username, self.api_key)
		# Get the payments service
        self.payment = africastalking.Payment

    def validate(self):
        try:
			# Set the transaction_id is from bank checkout charge request
			transaction_id='ATId_3829u492SQSW383u423u'
			# Set the OTP given to you by the user you're charging
			otp = "1234"
			# That's it, hit send and we'll take care of the rest
            res = self.payment.validate_bank_checkout(transaction_id, otp)
            print (res)
        except Exception as e:
            print ("Received error response:%s" %str(e))

if __name__ == '__main__':
    BANK().validate()

The Ruby code snippet below shows how to initiate a bank checkout validation request using our API

The code uses our Ruby SDK.

require 'AfricasTalking'

# Set your app credentials
username = 'MyAppUsername'
apikey   = 'MyAppAPIKey'

# Initialize the SDK
AT=AfricasTalking::Initialize.new username, apikey

# Get the payments service
payments = AT.payments

# Set the transactionId you got from the bank checkout charge request
transactionId = "ATPid_7444b64859882dca9ee9621276fc7c7f"

# Set the OTP given to you by the user you're charging
otp = "1234"

options = {
    "otp"           => otp,
    "transactionId" => transactionId
}
begin
    # That's it, hit send and we'll take care of the rest
    transaction = payments.bankCheckoutValidate options
    puts transaction.to_yaml
rescue Exception => ex
    puts "Encountered an error: " + ex.message
end

The JavaScript code snippet below shows how to initiate a bank checkout validation request using our API

The code uses our Node SDK.

// Set your app credentials
const credentials = {
    apiKey: 'MyAppAPIkey',
    username: 'MyAppUsername'
}

// Initialize the SDK
const AfricasTalking = require('africastalking')(credentials);

// Get the payments service
const payments = AfricasTalking.PAYMENTS;

function validateCheckout() {

    const options = {
        // Set the transactionId you got from the bank checkout charge request
        transacitonId: 'ATPid_7444b64859882dca9ee9621276fc7c7f',
        // Set the OTP given to you by the user you're charging
        otp: 'OTPSentToCustomer'
    }

    // That's it, hit send and we'll take care of the rest
    payments.bankCheckoutValidate(options)
        .then(response => {
            console.log(response);
        }).catch(error => {
            console.log(error);
        });
}

validateCheckout();