Générer un Lien de Paiement
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>"
}Points de terminaison
Générer un lien de paiement
Créez un lien de paiement pour rediriger les utilisateurs vers une page de paiement hébergée par Fapshi.
POST
/
initiate-pay
Générer un Lien de Paiement
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
Générez un lien de paiement où les utilisateurs pourront compléter leur paiement sur une page de paiement préconstruite par Fapshi.
Paramètres
| Nom | Obligatoire | Type | Description |
|---|---|---|---|
| amount | Oui | entier | Montant à payer (minimum 100 XAF). |
| Non | chaîne | Si renseigné, l’utilisateur n’aura pas à fournir son email lors du paiement. | |
| redirectUrl | Non | chaîne | URL vers laquelle l’utilisateur sera redirigé après le paiement. |
| userId | Non | chaîne | ID utilisateur interne (1-100 caractères ; a-z, A-Z, 0-9, -, _). Recommandé : il permet de retrouver la transaction si la réponse est perdue. |
| externalId | Non | chaîne | ID de transaction/commande pour réconciliation (1-100 caractères ; a-z, A-Z, 0-9, -, _). N’a pas besoin d’être unique : Fapshi ne rejette ni ne dédoublonne les valeurs répétées. |
| message | Non | chaîne | Raison du paiement. |
Pas d’idempotence. Fapshi ne prend pas en charge les clés d’idempotence et n’impose pas l’unicité de
externalId. Chaque requête crée un nouveau lien de paiement. Si une requête expire, vérifiez si le lien a été créé avec GET /transaction/{userId} avant de réessayer. Voir Gestion des transactions.Réponse
-
200 OKavec un corps JSON contenant :message: message de succèslink: URL où l’utilisateur doit effectuer le paiementtransId: ID de la transaction pour suivre le statut du paiementdateInitiated: date de début du paiement
- En cas d’erreur, retournera un code 4XX avec un message expliquant l’échec.
Les liens de paiement expirent au bout de 24 heures et ne peuvent plus être utilisés après cette période.
Corps
application/json