Generate a Payment Link
curl --request POST \
--url https://sandbox.fapshi.com/initiate-pay \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--header 'apiuser: <api-key>' \
--data '
{
"amount": 101,
"email": "jsmith@example.com",
"redirectUrl": "<string>",
"userId": "<string>",
"externalId": "<string>",
"message": "<string>"
}
'const options = {
method: 'POST',
headers: {apiuser: '<api-key>', apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 101,
email: 'jsmith@example.com',
redirectUrl: '<string>',
userId: '<string>',
externalId: '<string>',
message: '<string>'
})
};
fetch('https://sandbox.fapshi.com/initiate-pay', 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/initiate-pay",
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([
'amount' => 101,
'email' => 'jsmith@example.com',
'redirectUrl' => '<string>',
'userId' => '<string>',
'externalId' => '<string>',
'message' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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/initiate-pay"
payload = {
"amount": 101,
"email": "jsmith@example.com",
"redirectUrl": "<string>",
"userId": "<string>",
"externalId": "<string>",
"message": "<string>"
}
headers = {
"apiuser": "<api-key>",
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)HttpResponse<String> response = Unirest.post("https://sandbox.fapshi.com/initiate-pay")
.header("apiuser", "<api-key>")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 101,\n \"email\": \"jsmith@example.com\",\n \"redirectUrl\": \"<string>\",\n \"userId\": \"<string>\",\n \"externalId\": \"<string>\",\n \"message\": \"<string>\"\n}")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.fapshi.com/initiate-pay"
payload := strings.NewReader("{\n \"amount\": 101,\n \"email\": \"jsmith@example.com\",\n \"redirectUrl\": \"<string>\",\n \"userId\": \"<string>\",\n \"externalId\": \"<string>\",\n \"message\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apiuser", "<api-key>")
req.Header.Add("apikey", "<api-key>")
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))
}{
"message": "<string>",
"link": "<string>",
"transId": "<string>",
"dateInitiated": "2023-12-25"
}{
"message": "<string>"
}Endpoints
Generate a Payment Link
Create a payment link to redirect users to a Fapshi-hosted checkout page.
POST
/
initiate-pay
Generate a Payment Link
curl --request POST \
--url https://sandbox.fapshi.com/initiate-pay \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--header 'apiuser: <api-key>' \
--data '
{
"amount": 101,
"email": "jsmith@example.com",
"redirectUrl": "<string>",
"userId": "<string>",
"externalId": "<string>",
"message": "<string>"
}
'const options = {
method: 'POST',
headers: {apiuser: '<api-key>', apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 101,
email: 'jsmith@example.com',
redirectUrl: '<string>',
userId: '<string>',
externalId: '<string>',
message: '<string>'
})
};
fetch('https://sandbox.fapshi.com/initiate-pay', 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/initiate-pay",
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([
'amount' => 101,
'email' => 'jsmith@example.com',
'redirectUrl' => '<string>',
'userId' => '<string>',
'externalId' => '<string>',
'message' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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/initiate-pay"
payload = {
"amount": 101,
"email": "jsmith@example.com",
"redirectUrl": "<string>",
"userId": "<string>",
"externalId": "<string>",
"message": "<string>"
}
headers = {
"apiuser": "<api-key>",
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)HttpResponse<String> response = Unirest.post("https://sandbox.fapshi.com/initiate-pay")
.header("apiuser", "<api-key>")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 101,\n \"email\": \"jsmith@example.com\",\n \"redirectUrl\": \"<string>\",\n \"userId\": \"<string>\",\n \"externalId\": \"<string>\",\n \"message\": \"<string>\"\n}")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.fapshi.com/initiate-pay"
payload := strings.NewReader("{\n \"amount\": 101,\n \"email\": \"jsmith@example.com\",\n \"redirectUrl\": \"<string>\",\n \"userId\": \"<string>\",\n \"externalId\": \"<string>\",\n \"message\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apiuser", "<api-key>")
req.Header.Add("apikey", "<api-key>")
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))
}{
"message": "<string>",
"link": "<string>",
"transId": "<string>",
"dateInitiated": "2023-12-25"
}{
"message": "<string>"
}Endpoint
POST /initiate-pay
Generate a payment link where users complete payment on a prebuilt Fapshi checkout page.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
| amount | Yes | integer | Amount to be paid (minimum 100 XAF). |
| No | string | If set, the user won’t have to provide an email during payment. | |
| redirectUrl | No | string | URL to redirect the user after payment. |
| userId | No | string | Your internal user ID (1-100 chars; a-z, A-Z, 0-9, -, _). |
| externalId | No | string | Transaction/order ID for reconciliation (1-100 chars; a-z, A-Z, 0-9, -, _). |
| message | No | string | Reason for payment. |
Response
-
200 OKwith JSON body containing:message: success messagelink: URL for user paymenttransId: transaction ID to track payment statusdateInitiated: date when the payment was initiated
- Errors return 4XX with a message explaining the failure.
Payment links expire after 24 hours and cannot be used afterward.
Body
application/json
Amount to be paid (minimum 100 XAF).
Required range:
x >= 100Optional user email to skip during payment.
URL to redirect after payment.
Internal user ID (1-100 chars; a-z, A-Z, 0-9, -, _).
Pattern:
^[a-zA-Z0-9\-_]{1,100}$Transaction/order ID for reconciliation (1-100 chars; a-z, A-Z, 0-9, -, _).
Pattern:
^[a-zA-Z0-9\-_]{1,100}$Reason for payment.