Verify payment

Verify transactions after payments using Shoket verify API

How to verify payments

You do this by making a GET request to the Verify Transaction endpoint from your server using your transaction reference.

Authentication

Authenticate your API calls by including your secret key in the Authorization header of every request you make.

Shoket private key can be obtained here. Learn more about authentication here.

Make a request

Here's a code sample for verifying transactions:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.shoket.co/v1/verify/OB3J177Lqnp6Rg6wHqr3q',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_POSTFIELDS =>'{
    "provider_name": "Vodacom",
    "provider_code": "MPESA"
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer sk_test_mfpgBhidcAlPYEWbYR',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

After making a GET request Shoket will return a JSON data with transaction data.

NOTICE: The returned transaction data does not mean that the transaction was made successfully, you have to verify that the status of the transaction is Success (this identifies that the transaction was completed). Please read down the table of Status and their meaning.

Here is the sample of returned JSON data.

{
    "Status": "Ok" ,
    "customer" {
        "email": "user@user.com",
        "customer_name": "John",
        "id": 64043
    },
    "data": {
        "amount": 64000,
        "channel": "Halotel",
        "currency": "TSH",
        "number_used": "0663803078",
        "status": "Success",
        "transaction_date": "2021-06-27 15:08:59.917691"
    },
    "message": "Transaction is completed",
    "reference": "adz49dS428b7kbDTdG4MN"
}

HTTP Status

Shoket returns a HTTP status for every request made. Refer here to understand meaning of every status returned.

Last updated