POST: B2C
Send money to customer MPESA phone number
This API enables you to send money to customer MPESA wallet from your Pay Hero mobile payments wallet.
B2C Payment
POST
https://payherokenya.com/intasend/b2c
B2C payment
Body
Name | Type | Description |
---|---|---|
| string | Your pay hero API Key username |
| string | Customer phone no eg 0789877878 |
| int | amount, min: 50 |
| string | Your reference |
| string | callback URL to receive response of payment |
Response
{
"file_id": "0444E50",
"tracking_id": "3d94c15f-89d6-4b95-9268",
"batch_reference": null,
"status": "Confirming balance",
"status_code": "BP104",
"transactions": [
{
"transaction_id": "0L5PJMK",
"status": "Pending",
"status_code": "TP101",
"request_reference_id": "edbe40be-7dd8-4de7-99c4",
"provider": "MPESA-B2C",
"bank_code": null,
"name": null,
"account": "254708344101",
"account_type": null,
"account_reference": null,
"provider_reference": null,
"provider_account_name": null,
"amount": "50.00",
"charge": "10.00",
"narrative": null,
"file_id": "0444E50",
"currency": "KES",
"created_at": "2024-09-05T19:51:56.559481+03:00",
"updated_at": "2024-09-05T19:51:56.569866+03:00"
}
],
"actual_charges": "0.0",
"paid_amount": "0.0",
"failed_amount": 0,
"wallet": {
"wallet_id": "12345",
"label": "YOUR NAME",
"can_disburse": true,
"currency": "KES",
"wallet_type": "WORKING",
"current_balance": 1000.41,
"available_balance": 1000.41,
"updated_at": "2024-09-05T19:44:08.054205+03:00"
},
"charge_estimate": 10,
"total_amount_estimate": 60,
"total_amount": 50,
"transactions_count": 1,
"created_at": "2024-09-05T19:51:56.488273+03:00",
"updated_at": "2024-09-05T19:51:57.374411+03:00"
}
{
"error": 1,
"error_message": "Invalid API username provided"
}
Call Back Response Sample
{
"file_id": "0444E50",
"tracking_id": "3d94c15f-89d6-4b95-9268",
"batch_reference": null,
"status": "Completed",
"status_code": "BC100",
"transactions": [
{
"transaction_id": "0L5PJMK",
"status": "Successful",
"status_code": "TS100",
"request_reference_id": "edbe40be-7dd8-4de7-99c4",
"provider": "MPESA-B2C",
"bank_code": null,
"name": null,
"account": "254708344101",
"account_type": null,
"account_reference": null,
"provider_reference": "SI57K4TDSD",
"provider_account_name": " CUSTOMER NAME",
"amount": "50.00",
"charge": "10.00",
"narrative": null,
"file_id": "0444E50",
"currency": "KES",
"created_at": "2024-09-05T19:51:56.559481+03:00",
"updated_at": "2024-09-05T19:52:13.428109+03:00"
}
],
"actual_charges": "10.00",
"paid_amount": "50.00",
"failed_amount": 0,
"wallet": {
"wallet_id": "12345",
"label": "YOUR NAME",
"can_disburse": true,
"currency": "KES",
"wallet_type": "WORKING",
"current_balance": 1057.41,
"available_balance": 1057.41,
"updated_at": "2024-09-05T19:51:58.423464+03:00"
},
"charge_estimate": 10,
"total_amount_estimate": 60,
"total_amount": 50,
"transactions_count": 1,
"created_at": "2024-09-05T19:51:56.488273+03:00",
"updated_at": "2024-09-05T19:53:00.335550+03:00",
"external_reference": "test3636363"
}
Sample Request Code: PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://payherokenya.com/intasend/b2c',
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 =>'{
"api_username":"wweerrttyyuyuuu",
"phone_number":"0708344101",
"amount":"50",
"external_reference":"3333333",
"callback_url":"https://free.beeceptor.com"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Last updated