Payd-to-Payd
Introduction
The P2P(Payd-to-Payd) feature allows users to send money to other Payd users.
Sending Money with P2P
To send money using P2P, users need to make an HTTP POST request to the specified endpoint with the required parameters.
Endpoint
https://api.mypayd.app/api/v2/p2p
Authorization
Users need to include basic authentication credentials in the request headers.
Request Body (Token Object)
The request body should include the necessary parameters for the transaction, such as the AccountID, Narration, ReceiverUsername, Amount, PhoneNumber
{
"accountID": your_account_id,
"receiver_username": "johndoe",
"amount": "1000",
"narration": "Family breakfast",
"phone_number": "25470000000"
}
Code Examples
Below are code examples in different programming languages demonstrating how to make P2P payments using HTTP POST requests.
- Curl
- Go
- Nodejs
- Python
- PHP
curl --location 'https://api.mypayd.app/api/v2/p2p' \
--data-raw '{
"accountID": your_account_id,
"receiver_username": "johndoe",
"amount": "1000",
"narration": "Family breakfast",
"phone_number": "25470000000"
}'
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.mypayd.app/api/v2/p2p"
method := "POST"
payload := strings.NewReader(`{
"accountID": your_account_id,
"receiver_username": "johndoe",
"amount": "1000",
"narration": "Family breakfast",
"phone_number": "25470000000"
}`)
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 "accountID":your_account_id \n "receiver_username:"johndoe", \n "amount": 1000,\n "narration": "Family breakfast",\n "phone_number": "25470000000"\n}';
var config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api.mypayd.app/api/v2/p2p',
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/p2p"
payload = "{\n "accountID":your_account_id \n "receiver_username:"johndoe", \n "amount": 1000,\n "narration": "Family breakfast",\n "phone_number": "25470000000"\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/v2/p2p');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setBody('{ \n "accountID":your_account_id \n "receiver_username:"johndoe", \n "amount": 1000,\n "narration": "Family breakfast", \n "phone_number": "25470000000"}');
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
{
"status_code": "0",
"merchant_reference": "",
"transaction_type": "remittance",
"success": true,
"message": "Transaction request sent successfully",
"transaction_request_id": "b5114833-b85e-47dc-957b-6793af497497",
"transaction_reference": "NEB114557904",
"channel": "",
"payment_gateway": ""
}
Conclusion
The P2P feature provides a convenient way for users to send money securely to other Payd Users. By following the instructions outlined in this documentation, users can easily integrate P2P payments into their applications or services.