💸POST: Sasa Pay Payment

This endpoint is used to collect funds to your payments wallet using Sasa Pay.

Sasapay enables your customers to pay you using MPESA, Airtel Money, T-Kash and PesaLink. In this documentation, we will show you how to initiate payments from the above channels using Sasapay.

API Method

This endpoint enables you to get paid Via Sasapay to your payments wallet.

POST https://backend.payhero.co.ke/api/v2/payments

Headers

NameTypeDescription

Authorization:*

String

Basic basicAuthToken

Request Body

NameTypeDescription

amount*

Integer

Amount you want to get paid eg: 10

phone_number*

String

Customer phone number to make the payment eg: 0787655535

provider*

String

Value: sasapay

network_code*

String

A unique digit code used for identifying the various mobile money providers

63902 (MPesa)

63903 (AirtelMoney)

63907 (T-Kash)

01 (PesaLink)

external_reference

String

Your unique reference to track this transaction Eg: INV-009

callback_url

String

Your endpoint URL that we will use to send payment status response eg: https://example.com/callback.php

{
    "success": true,
    "status": "QUEUED",
    "reference": "TX97JU3E1K",
    "CheckoutRequestID": "60122767-bce3-4749-8129-a7bba7726dc8",
    "manual_instructions": "1. GO TO 'LIPA NA MPESA' 2. SELECT 'PAY BILL' 3. ENTER BUSINESS NUMBER: 756756  4. ENTER ACCOUNT NUMBER: PR5161667  5. ENTER AMOUNT:10 6. ENTER YOUR MPESA PIN AND PRESS OK"
}

Sample Code

This represents PHP Curl example of how to make the request, you can implement this in your specific language of choice

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://backend.payhero.co.ke/api/v2/payments',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "amount": 10,
    "phone_number": "0798988787",
    "provider": "sasapay", 
    "network_code":"63902",
    "external_reference": "INV-99992",
    "callback_url": "https://example.com/callback.php"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Basic 3A6anVoWFZrRk5qSVl0MGNMOERGMlR3dlhrQ0VWUWJHNDVVVnNaMEdDSw=='
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Callback URL Response Sample

This represents the JSON that will be sent to your request callback_url, NOTE: it contains the ExternalReference that you provided in the request and CheckoutRequestID that was returned in the request response, you can use those to track and update your payments in your system/app

{
  "forward_url": "",
  "response": {
    "Amount": 10,
    "CheckoutRequestID": "d12c6aeb-ce42-45c6-af02-ce4b8d3596f0",
    "ExternalReference": "INV-99992",
    "MerchantRequestID": "7ZBNDZFT6T",
    "MpesaReceiptNumber": "SAF24HOLGA",
    "Phone": "254798988787",
    "ResultCode": 0,
    "ResultDesc": "Transaction processed successfully.",
    "Status": "Success"
  },
  "status": true
}

Last updated