Get Transactions by User ID
curl --request GET \
--url https://sandbox.fapshi.com/transaction/{userId} \
--header 'apikey: <api-key>' \
--header 'apiuser: <api-key>'const options = {method: 'GET', headers: {apiuser: '<api-key>', apikey: '<api-key>'}};
fetch('https://sandbox.fapshi.com/transaction/{userId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.fapshi.com/transaction/{userId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"apikey: <api-key>",
"apiuser: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}import requests
url = "https://sandbox.fapshi.com/transaction/{userId}"
headers = {
"apiuser": "<api-key>",
"apikey": "<api-key>"
}
response = requests.get(url, headers=headers)
print(response.text)HttpResponse<String> response = Unirest.get("https://sandbox.fapshi.com/transaction/{userId}")
.header("apiuser", "<api-key>")
.header("apikey", "<api-key>")
.asString();package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://sandbox.fapshi.com/transaction/{userId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("apiuser", "<api-key>")
req.Header.Add("apikey", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}[
{
"transId": "<string>",
"status": "CREATED",
"medium": "mobile money",
"serviceName": "<string>",
"transType": "Collection",
"amount": 123,
"revenue": 123,
"payerName": "<string>",
"email": "jsmith@example.com",
"redirectUrl": "<string>",
"externalId": "<string>",
"userId": "<string>",
"webhook": "<string>",
"reason": "<string>",
"financialTransId": "<string>",
"dateInitiated": "2023-12-25",
"dateConfirmed": "2023-12-25"
}
]{
"message": "<string>"
}Endpoints
Get Transactions by User ID
Retrieve all transactions associated with a specific user ID.
GET
/
transaction
/
{userId}
Get Transactions by User ID
curl --request GET \
--url https://sandbox.fapshi.com/transaction/{userId} \
--header 'apikey: <api-key>' \
--header 'apiuser: <api-key>'const options = {method: 'GET', headers: {apiuser: '<api-key>', apikey: '<api-key>'}};
fetch('https://sandbox.fapshi.com/transaction/{userId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.fapshi.com/transaction/{userId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"apikey: <api-key>",
"apiuser: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}import requests
url = "https://sandbox.fapshi.com/transaction/{userId}"
headers = {
"apiuser": "<api-key>",
"apikey": "<api-key>"
}
response = requests.get(url, headers=headers)
print(response.text)HttpResponse<String> response = Unirest.get("https://sandbox.fapshi.com/transaction/{userId}")
.header("apiuser", "<api-key>")
.header("apikey", "<api-key>")
.asString();package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://sandbox.fapshi.com/transaction/{userId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("apiuser", "<api-key>")
req.Header.Add("apikey", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}[
{
"transId": "<string>",
"status": "CREATED",
"medium": "mobile money",
"serviceName": "<string>",
"transType": "Collection",
"amount": 123,
"revenue": 123,
"payerName": "<string>",
"email": "jsmith@example.com",
"redirectUrl": "<string>",
"externalId": "<string>",
"userId": "<string>",
"webhook": "<string>",
"reason": "<string>",
"financialTransId": "<string>",
"dateInitiated": "2023-12-25",
"dateConfirmed": "2023-12-25"
}
]{
"message": "<string>"
}Endpoint
GET /transaction/:userId
Retrieve all transactions associated with a specific user ID.
- Returns an array of transaction objects related to the specified user.
- A transaction appears here as soon as it is created (status
CREATED), with no delay. This includes Direct Pay transactions and payment links, even if your application never received the original API response.
Using this endpoint for reconciliation
Because Fapshi does not support idempotency keys, this endpoint is the recommended way to recover a transaction when a creation request times out or its response is lost:- Call
GET /transaction/{userId}with theuserIdyou sent when creating the transaction. - Find the entry whose
externalIdmatches the one you sent. - If it exists, save its
transIdand track it; do not create a new transaction. - If it does not exist, the transaction was never created and you can safely retry.
This only works if you send a
userId (and a unique externalId) when creating transactions. See Transaction Handling.Path Parameters
User ID to retrieve transactions for.
Pattern:
^[a-zA-Z0-9\-_]{1,100}$Response
List of transactions
Transaction ID of the payment.
Transaction status
Available options:
CREATED, PENDING, SUCCESSFUL, FAILED, EXPIRED Payment method
Available options:
mobile money, orange money, fapshi Name of the service in use
Type of transaction
Available options:
Collection, Payout Transaction amount
Amount received when Fapshi fees (3% of amount) have been deducted
Client name
Client email
URL to redirect after payment
The transaction ID on your application
ID of the client on your application
The webhook you defined for your service
Typically appears when a payout via fapshi fails
Transaction ID with the payment operator
Date when the payment was initiated
Date when the payment was made