Mobile Payout Requests
Introduction
The Mobile Payouts API allows you to send funds directly to a recipient's mobile wallet (e.g., M-PESA) through a single, unified endpoint.
Making Payment Requests
To make payment requests, users need to send an HTTP POST request to the specified endpoint with the required parameters.
Endpoint
https:api.mypayd.app//api/v3/withdrawal
Authorization
Users need to include basic authentication credentials in the request headers.
Authorization: Basic <base64-encoded-username:password>
Content-Type: application/json
X-Payd-Merchant-ID: <your_merchant_id>
Request Body
This payload allows you to make mobile payments using the Payd API. The request body must include the following structure:
json
{
"username": "paydconsultants",
"network_code": "7ea6df5c-6bba-46b2-a7e6-f511959e7edb",
"account_name": "momo",
"account_number": "+254712345678",
"amount": 150,
"phone_number": "254712345678",
"channel_id": "c2b2eeda-d4ca-49fd-ba21-0781ffa7714b",
"narration": "Payment for goods",
"currency": "KES",
"callback_url": "https://payd-test.free.beeceptor.com",
"transaction_channel": "mobile",
"channel": "mobile",
"provider_name": "Mobile Wallet (M-PESA)",
"provider_code": "M PESA" // can be used as channel code (from bulk api)
}
Below are code examples in different programming languages demonstrating how to make card payments using HTTP POST requests.
- Curl
- Go
- Nodejs
- Python
- PHP
curl --location 'https:api.mypayd.app//api/v3/withdrawal' \
--data-raw '{
"username": "paydconsultants",
"network_code": "7ea6df5c-6bba-46b2-a7e6-f511959e7edb",
"account_name": "momo",
"account_number": "+254712345678",
"amount": 150,
"phone_number": "254712345678",
"channel_id": "c2b2eeda-d4ca-49fd-ba21-0781ffa7714b",
"narration": "Payment for goods",
"currency": "KES",
"callback_url": "https://payd-test.free.beeceptor.com",
"transaction_channel": "mobile",
"channel": "mobile",
"provider_name": "Mobile Wallet (M-PESA)",
"provider_code": "M PESA" // can be used as channel code (from bulk api)
}`
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https:api.mypayd.app/api/v3/withdrawal
"
method := "POST"
payload := strings.NewReader(`curl --location 'https:api.mypayd.app/api/v3/withdrawal' \
--data-raw '{
"username": "paydconsultants",
"network_code": "7ea6df5c-6bba-46b2-a7e6-f511959e7edb",
"account_name": "momo",
"account_number": "+254712345678",
"amount": 150,
"phone_number": "254712345678",
"channel_id": "c2b2eeda-d4ca-49fd-ba21-0781ffa7714b",
"narration": "Payment for goods",
"currency": "KES",
"callback_url": "https://payd-test.free.beeceptor.com",
"transaction_channel": "mobile",
"channel": "mobile",
"provider_name": "Mobile Wallet (M-PESA)",
"provider_code": "M PESA" // can be used as channel code (from bulk api)
}'
)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
var axios = require('axios');
var data = "{\\n\\\"username\\\": \\\"paydconsultants\\\",\\n\\\"network_code\\\": \\\"7ea6df5c-6bba-46b2-a7e6-f511959e7edb\\\",\\n\\\"account_name\\\": \\\"momo\\\",\\n\\\"account_number\\\": \\\"+254712345678\\\",\\n\\\"amount\\\": 150,\\n\\\"phone_number\\\": \\\"254712345678\\\",\\n\\\"channel_id\\\": \\\"c2b2eeda-d4ca-49fd-ba21-0781ffa7714b\\\",\\n\\\"narration\\\": \\\"Payment for goods\\\",\\n\\\"currency\\\": \\\"KES\\\",\\n\\\"callback_url\\\": \\\"https://payd-test.free.beeceptor.com\\\",\\n\\\"transaction_channel\\\": \\\"mobile\\\",\\n\\\"channel\\\": \\\"mobile\\\",\\n\\\"provider_name\\\": \\\"Mobile Wallet (M-PESA)\\\",\\n\\\"provider_code\\\": \\\"M PESA\\\"\\n}";
var config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https:api.mypayd.app/api/v3/withdrawal',
headers: { },
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
url = "https:api.mypayd.app/api/v3/withdrawal"
payload = "{\\n\\\"username\\\": \\\"paydconsultants\\\",\\n\\\"network_code\\\": \\\"7ea6df5c-6bba-46b2-a7e6-f511959e7edb\\\",\\n\\\"account_name\\\": \\\"momo\\\",\\n\\\"account_number\\\": \\\"+254712345678\\\",\\n\\\"amount\\\": 150,\\n\\\"phone_number\\\": \\\"254712345678\\\",\\n\\\"channel_id\\\": \\\"c2b2eeda-d4ca-49fd-ba21-0781ffa7714b\\\",\\n\\\"narration\\\": \\\"Payment for goods\\\",\\n\\\"currency\\\": \\\"KES\\\",\\n\\\"callback_url\\\": \\\"https://payd-test.free.beeceptor.com\\\",\\n\\\"transaction_channel\\\": \\\"mobile\\\",\\n\\\"channel\\\": \\\"mobile\\\",\\n\\\"provider_name\\\": \\\"Mobile Wallet (M-PESA)\\\",\\n\\\"provider_code\\\": \\\"M PESA\\\"\\n}"
headers = {}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https:api.mypayd.app/api/v3/withdrawal');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setBody("{\n\"username\": \"paydconsultants\",\n\"network_code\": \"7ea6df5c-6bba-46b2-a7e6-f511959e7edb\",\n\"account_name\": \"momo\",\n\"account_number\": \"+254712345678\",\n\"amount\": 150,\n\"phone_number\": \"254712345678\",\n\"channel_id\": \"c2b2eeda-d4ca-49fd-ba21-0781ffa7714b\",\n\"narration\": \"Payment for goods\",\n\"currency\": \"KES\",\n\"callback_url\": \"https://payd-test.free.beeceptor.com\",\n\"transaction_channel\": \"mobile\",\n\"channel\": \"mobile\",\n\"provider_name\": \"Mobile Wallet (M-PESA)\",\n\"provider_code\": \"M PESA\"\n}");
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
Example of a successful response
{
"success": true,
"correlator_id": "12345abcd",
"message": "Payout processed successfully",
"status": "completed"
}
### Conclusion
The Mobile Payouts endpoint enables seamless and secure withdrawalof money from your wallet through mobile channels such as M-PESA