Accept Payment

Charge your customer direct from your web or app.

With Shoket, you can collect payments from customers using any of these payment methods: Mobile money, Card.

Your API requests are authenticated using API keys. Any request that doesn't include an API key will return an error.

You can generate an API key from your Dashboard at any time. Shoket private key can be obtained here.

Collect customer information

To make a transaction you will need to pass customer information such as (number used, amount, channel, email, customer name). The request must be made with Shoket private key which can be obtained here. Here are full list of parameters and their meaning.

Make a payment request

Here is an example of a POST request to charge a customer.

var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'api.shoket.co',
  'path': '/v1/charge/',
  'headers': {
    'Authorization': 'Bearer sk_mpBicAlPYEWbYR',
    'Content-Type': 'application/json'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({
  "amount": "5000",
  "customer_name": "John Doe",
  "email": "john@user.com",
  "number_used": "255612345678",
  "channel": "Tigo"
});

req.write(postData);

req.end();

After making a POST request Shoket will return a JSON data with transaction data. Also this request will pop up a USSD push to the customer's phone number which you provided

NOTICE: The returned transaction data does not mean that the transaction was made successfully, you have to verify that the status of 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": "success" ,
    "customer" {
        "customer_name": "376FcD3gbidW",
        "email": "user@user.com",
        "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"
}

Charge a customer

POST https://api.shoket.co/v1/charge/

Headers

Request Body

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

Last updated