Initier une Demande de Paiement Direct
curl --request POST \
--url https://sandbox.fapshi.com/direct-pay \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--header 'apiuser: <api-key>' \
--data '
{
"amount": 101,
"phone": "<string>",
"name": "<string>",
"email": "jsmith@example.com",
"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,
phone: '<string>',
name: '<string>',
email: 'jsmith@example.com',
userId: '<string>',
externalId: '<string>',
message: '<string>'
})
};
fetch('https://sandbox.fapshi.com/direct-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/direct-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,
'phone' => '<string>',
'name' => '<string>',
'email' => 'jsmith@example.com',
'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/direct-pay"
payload = {
"amount": 101,
"phone": "<string>",
"name": "<string>",
"email": "jsmith@example.com",
"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/direct-pay")
.header("apiuser", "<api-key>")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 101,\n \"phone\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"jsmith@example.com\",\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/direct-pay"
payload := strings.NewReader("{\n \"amount\": 101,\n \"phone\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"jsmith@example.com\",\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>",
"transId": "<string>",
"dateInitiated": "2023-12-25"
}{
"message": "<string>"
}Points de terminaison
Initier une demande de paiement direct
Envoyez une demande de paiement directement sur le mobile d’un utilisateur.
POST
/
direct-pay
Initier une Demande de Paiement Direct
curl --request POST \
--url https://sandbox.fapshi.com/direct-pay \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--header 'apiuser: <api-key>' \
--data '
{
"amount": 101,
"phone": "<string>",
"name": "<string>",
"email": "jsmith@example.com",
"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,
phone: '<string>',
name: '<string>',
email: 'jsmith@example.com',
userId: '<string>',
externalId: '<string>',
message: '<string>'
})
};
fetch('https://sandbox.fapshi.com/direct-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/direct-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,
'phone' => '<string>',
'name' => '<string>',
'email' => 'jsmith@example.com',
'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/direct-pay"
payload = {
"amount": 101,
"phone": "<string>",
"name": "<string>",
"email": "jsmith@example.com",
"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/direct-pay")
.header("apiuser", "<api-key>")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 101,\n \"phone\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"jsmith@example.com\",\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/direct-pay"
payload := strings.NewReader("{\n \"amount\": 101,\n \"phone\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"jsmith@example.com\",\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>",
"transId": "<string>",
"dateInitiated": "2023-12-25"
}{
"message": "<string>"
}Le paiement direct est désactivé par défaut dans l’environnement Live. Suivez les
étapes du guide Activer le paiement direct sur votre API Fapshi en mode Live
pour activer le paiement direct en mode live.
Endpoint
POST /direct-pay
Envoyez une demande de paiement directement sur le mobile d’un utilisateur. Vous êtes responsable de la création de votre propre formulaire de paiement et de la vérification du statut du paiement.
Les transactions de paiement direct ne peuvent et ne s’expirent pas. Par
conséquent, leur état final est soit SUCCESSFUL soit FAILED.
Manipulez ce point de terminaison avec précaution ; toute mauvaise utilisation
peut entraîner la suspension de votre compte.
Direct Pay n’est pas disponible pour les agrégateurs de paiement (plateformes qui fournissent un checkout à plusieurs marchands). L’activation en mode live est examinée au cas par cas.
Pas d’idempotence. Fapshi ne prend pas en charge les clés d’idempotence et n’impose pas l’unicité de
externalId. Envoyer la même requête deux fois crée deux transactions et envoie deux demandes de paiement au client. Si une requête expire ou si sa réponse est perdue, ne la renvoyez pas aveuglément ; vérifiez d’abord avec GET /transaction/{userId}. Voir Gestion des transactions.Paramètres
| Nom | Obligatoire | Type | Description |
|---|---|---|---|
| amount | Oui | entier | Montant à payer (minimum 100 XAF). |
| phone | Oui | chaîne | Numéro de téléphone pour la demande de paiement (exemple : 67XXXXXXX). |
| medium | Non | chaîne | "mobile money" ou "orange money". À omettre pour détection automatique. |
| name | Non | chaîne | Nom du payeur. |
| Non | chaîne | Email du payeur pour recevoir le reçu. | |
| userId | Non | chaîne | ID utilisateur dans votre système (1–100 caractères; a–z, A–Z, 0–9, -, _ autorisés). Fortement recommandé : il permet de retrouver la transaction si la réponse est perdue. |
| externalId | Non | chaîne | ID de transaction ou commande pour rapprochement (1–100 caractères; mêmes règles). N’a pas besoin d’être unique : Fapshi ne rejette ni ne dédoublonne les valeurs répétées. |
| message | Non | chaîne | Motif du paiement. |
Réponse
-
200 OKavec un corps JSON contenant :message: message de succèstransId: ID de la transaction pour suivre le paiementdateInitiated: date de l’initiation du paiement
- En cas d’erreur, un code 4XX avec un message d’échec est retourné.
Une réponse
200 signifie que la demande de paiement a été envoyée, pas que le client a payé. Suivez le statut final avec les webhooks ou GET /payment-status/{transId}. Si le statut est FAILED, la raison (solde insuffisant, refus, demande ignorée, etc.) n’est pas fournie ; voir Transactions échouées.Corps
application/json