Request M-Pesa reversal
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({transactionId: 'txn_01j7b6f9p5y9h', narration: 'Customer refund'})
};
fetch('https://api.fingopay.io/v1/mpesa/reverse', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.fingopay.io/v1/mpesa/reverse"
payload = {
"transactionId": "txn_01j7b6f9p5y9h",
"narration": "Customer refund"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api.fingopay.io/v1/mpesa/reverse \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"transactionId": "txn_01j7b6f9p5y9h",
"narration": "Customer refund"
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fingopay.io/v1/mpesa/reverse"
payload := strings.NewReader("{\n \"transactionId\": \"txn_01j7b6f9p5y9h\",\n \"narration\": \"Customer refund\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.fingopay.io/v1/mpesa/reverse")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"transactionId\": \"txn_01j7b6f9p5y9h\",\n \"narration\": \"Customer refund\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fingopay.io/v1/mpesa/reverse",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'transactionId' => 'txn_01j7b6f9p5y9h',
'narration' => 'Customer refund'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}using RestSharp;
var options = new RestClientOptions("https://api.fingopay.io/v1/mpesa/reverse");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"transactionId\": \"txn_01j7b6f9p5y9h\",\n \"narration\": \"Customer refund\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
{
"status": "success",
"message": "Reversal initiated successfully",
"data": {
"transactionId": "txn_01j7refund"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"requestId": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"requestId": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"requestId": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"requestId": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"requestId": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"requestId": "<string>"
}
}Request M-Pesa reversal
Initiate a reversal for a previously completed M-Pesa C2B transaction. The reversal will be processed asynchronously.
POST
/
v1
/
mpesa
/
reverse
Request M-Pesa reversal
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({transactionId: 'txn_01j7b6f9p5y9h', narration: 'Customer refund'})
};
fetch('https://api.fingopay.io/v1/mpesa/reverse', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.fingopay.io/v1/mpesa/reverse"
payload = {
"transactionId": "txn_01j7b6f9p5y9h",
"narration": "Customer refund"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api.fingopay.io/v1/mpesa/reverse \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"transactionId": "txn_01j7b6f9p5y9h",
"narration": "Customer refund"
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fingopay.io/v1/mpesa/reverse"
payload := strings.NewReader("{\n \"transactionId\": \"txn_01j7b6f9p5y9h\",\n \"narration\": \"Customer refund\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.fingopay.io/v1/mpesa/reverse")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"transactionId\": \"txn_01j7b6f9p5y9h\",\n \"narration\": \"Customer refund\"\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fingopay.io/v1/mpesa/reverse",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'transactionId' => 'txn_01j7b6f9p5y9h',
'narration' => 'Customer refund'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}using RestSharp;
var options = new RestClientOptions("https://api.fingopay.io/v1/mpesa/reverse");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"transactionId\": \"txn_01j7b6f9p5y9h\",\n \"narration\": \"Customer refund\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
{
"status": "success",
"message": "Reversal initiated successfully",
"data": {
"transactionId": "txn_01j7refund"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"requestId": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"requestId": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"requestId": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"requestId": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"requestId": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"requestId": "<string>"
}
}Authorizations
Use your API key as a Bearer token. Example: Authorization: Bearer sk_live_...
Headers
Unique key to safely retry POST without duplicates. Required in live environment.
Body
application/json
Was this page helpful?
⌘I