POST: Pay Hero Wallet- Withdraw To Mobile
This end point is used to withdraw funds from your payments wallet to Mobile wallet eg: MPESA or Airtel Money
Request Method
Endpoint enables you to withdraw funds to MPESA
POST
https://backend.payhero.co.ke/api/v2/withdraw
Headers
Authorization:*
String
Basic basicAuthToken
Request Body
external_reference
String
Your unique reference to track this transaction Eg: INV-009
amount*
Integer
Eg: 100
phone_number*
String
Eg: 254787677676, Note: must start with country code.
network_code*
String
A unique digit code used for identifying the various mobile money providers:
63902 (MPesa)
63903 (Airtel Money)
callback_url
String
Your endpoint URL that we will use to send payment status response eg: https://example.com/callback.php
channel*
String
Value: mobile
channel_id
Integer
Enter your Payment Wallet Channel ID
payment_service
String
Value: b2c
{
"status": "QUEUED",
"merchant_reference": "W5ZBQBHJOS",
"checkout_request_id": "553125-97e66f37-200d-47ef-84bb-eb9b64ab8ad5",
"response_code": "0",
"conversation_id": "97e66f37-200d-47ef-84bb-eb9b64ab8ad5"
}
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/withdraw',
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 =>'{
"external_reference": "mpesa101",
"amount": 100,
"phone_number": "254787877676",
"network_code": "63902",
"callback_url": "https://example.com",
"channel": "mobile",
"channel_id": 12345,
"payment_service":"b2c"
}
',
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
{
"forward_url": "",
"response": {
"Amount": 50,
"CheckoutRequestID": "cbb768d1-7803-4436-b793-f9df65e716a2",
"ExternalReference": "TX1234ABCre55",
"MerchantRequestID": "3F7CORFVG3",
"RecipientAccountNumber": "254778766767",
"ResultCode": 0,
"ResultDesc": "Transaction processed successfully.",
"Status": "Success",
"TransactionID": "SAJ1I2SQ43"
},
"status": true
}
Last updated
Was this helpful?