Send To Bank
Introduction
The "Send To Bank" feature allows users to transfer money to a bank account by making an HTTP POST request to our API. This documentation provides details on how to send money to a bank and includes code examples in various programming languages.
Sending Money To Bank
To send money to a bank, users need to make an HTTP POST request to the specified endpoint with the required parameters.
Endpoint
https://api.mypayd.app/api/v2/withdrawal
Authorization
Users need to include basic authentication credentials in the request headers.
The Token Object
{
"account_id": "4c0f6ad5-92bf-4fd1-ba93-8c89c9d23616",
"phone_number": "+254718686209",
"amount": 100,
"narration": "Withdrawal request",
"callback_url": "https://example.com/callback",
"bank_code": "1234",
"bank_name": "Example Bank",
"bank_account_name": "Recipient Name",
"bank_account_number": "9876543210"
}
Code Examples
Below are code examples in different programming languages demonstrating how to send money to a mobile number using HTTP POST requests.
- Curl
- Go
- Nodejs
- Python
- PHP
curl --location 'https://api.mypayd.app/api/v2/withdrawal' \
--data-raw '{
"account_id": "4c0f6ad5-92bf-4fd1-ba93-8c89c9d23616",
"phone_number": "+254718686209",
"amount": 100,
"narration": "Withdrawal request",
"callback_url": "https://example.com/callback",
"bank_code": "1234",
"bank_name": "Example Bank",
"bank_account_name": "Recipient Name",
"bank_account_number": "9876543210"
}
'
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.mypayd.app/api/v2/withdrawal"
method := "POST"
payload := strings.NewReader(`{
"account_id": "4c0f6ad5-92bf-4fd1-ba93-8c89c9d23616",
"phone_number": "+254718686209",
"amount": 100,
"narration": "Withdrawal request",
"callback_url": "https://example.com/callback",
"bank_code": "1234",
"bank_name": "Example Bank",
"bank_account_name": "Recipient Name",
"bank_account_number": "9876543210"
}
`)
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 "amount": 100.0,\n "narration": "Transfer for goods",\n "email": "recipient@example.com",\n "account_id": "123456789",\n "phone": "123-456-7890",\n "bank_code": "1234",\n "bank_name": "Example Bank",\n "bank_account_name": "Recipient Name",\n "bank_account_number": "9876543210",\n "callback_url": "https://example.com/callback"\n}\n';
var config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api.mypayd.app/api/v2/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/v2/withdrawal"
payload = "{
"account_id": "4c0f6ad5-92bf-4fd1-ba93-8c89c9d23616",
"phone_number": "+254718686209",
"amount": 100,
"narration": "Withdrawal request",
"callback_url": "https://example.com/callback",
"bank_code": "1234",
"bank_name": "Example Bank",
"bank_account_name": "Recipient Name",
"bank_account_number": "9876543210"
}"
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/v2/withdrawal');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setBody('{\n "account_id": 4c0f6ad5-92bf-4fd1-ba93-8c89c9d23616,\n "phone_number": "+254718686209",\n "amount": "100",\n "narration": "Withdrawal request",\n "callback_url": "https://example.com/callback",\n "bank_code": "1234",\n "bank_name": "Example Bank",\n "bank_account_name": "Recipient Name",\n "bank_account_number": "9876543210",\n}\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 "Send To Bank" feature provides a convenient way for users to transfer money to a bank account securely. By following the instructions outlined in this documentation, users can easily integrate money transfers to banks into their applications or services.