Payer une facture / Recharger
curl --request POST \
--url https://api-m.dexchange.sn/api/v1/billing/pay \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"serviceCode": "SENELEC_SN_BILL",
"reference_client": "210278816",
"amount": 104500,
"reference_facture": "<string>",
"externalTransactionId": "INV-001",
"callBackURL": "<string>",
"customData": "<string>"
}
'import requests
url = "https://api-m.dexchange.sn/api/v1/billing/pay"
payload = {
"serviceCode": "SENELEC_SN_BILL",
"reference_client": "210278816",
"amount": 104500,
"reference_facture": "<string>",
"externalTransactionId": "INV-001",
"callBackURL": "<string>",
"customData": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
serviceCode: 'SENELEC_SN_BILL',
reference_client: '210278816',
amount: 104500,
reference_facture: '<string>',
externalTransactionId: 'INV-001',
callBackURL: '<string>',
customData: '<string>'
})
};
fetch('https://api-m.dexchange.sn/api/v1/billing/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://api-m.dexchange.sn/api/v1/billing/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([
'serviceCode' => 'SENELEC_SN_BILL',
'reference_client' => '210278816',
'amount' => 104500,
'reference_facture' => '<string>',
'externalTransactionId' => 'INV-001',
'callBackURL' => '<string>',
'customData' => '<string>'
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-m.dexchange.sn/api/v1/billing/pay"
payload := strings.NewReader("{\n \"serviceCode\": \"SENELEC_SN_BILL\",\n \"reference_client\": \"210278816\",\n \"amount\": 104500,\n \"reference_facture\": \"<string>\",\n \"externalTransactionId\": \"INV-001\",\n \"callBackURL\": \"<string>\",\n \"customData\": \"<string>\"\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-m.dexchange.sn/api/v1/billing/pay")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"serviceCode\": \"SENELEC_SN_BILL\",\n \"reference_client\": \"210278816\",\n \"amount\": 104500,\n \"reference_facture\": \"<string>\",\n \"externalTransactionId\": \"INV-001\",\n \"callBackURL\": \"<string>\",\n \"customData\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-m.dexchange.sn/api/v1/billing/pay")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"serviceCode\": \"SENELEC_SN_BILL\",\n \"reference_client\": \"210278816\",\n \"amount\": 104500,\n \"reference_facture\": \"<string>\",\n \"externalTransactionId\": \"INV-001\",\n \"callBackURL\": \"<string>\",\n \"customData\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message": "Bill paid successfully",
"transaction": {
"success": true,
"transactionId": "TID123456789",
"externalTransactionId": "INV-001",
"transactionType": "BILL",
"amount": 104500,
"transactionFee": 1045,
"number": "210278816",
"referenceFacture": "8000000680",
"token": "1283930093209223",
"Status": "SUCCESS",
"previousBalance": 500000,
"currentBalance": 394455,
"message": "<string>"
}
}{
"message": [
"<string>"
],
"success": true
}Factures & Recharges
Payer une facture / Recharger
Payer une facture (SenEau, Senelec) ou recharger un compteur prépayé (Woyofal)
POST
/
api
/
v1
/
billing
/
pay
Payer une facture / Recharger
curl --request POST \
--url https://api-m.dexchange.sn/api/v1/billing/pay \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"serviceCode": "SENELEC_SN_BILL",
"reference_client": "210278816",
"amount": 104500,
"reference_facture": "<string>",
"externalTransactionId": "INV-001",
"callBackURL": "<string>",
"customData": "<string>"
}
'import requests
url = "https://api-m.dexchange.sn/api/v1/billing/pay"
payload = {
"serviceCode": "SENELEC_SN_BILL",
"reference_client": "210278816",
"amount": 104500,
"reference_facture": "<string>",
"externalTransactionId": "INV-001",
"callBackURL": "<string>",
"customData": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
serviceCode: 'SENELEC_SN_BILL',
reference_client: '210278816',
amount: 104500,
reference_facture: '<string>',
externalTransactionId: 'INV-001',
callBackURL: '<string>',
customData: '<string>'
})
};
fetch('https://api-m.dexchange.sn/api/v1/billing/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://api-m.dexchange.sn/api/v1/billing/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([
'serviceCode' => 'SENELEC_SN_BILL',
'reference_client' => '210278816',
'amount' => 104500,
'reference_facture' => '<string>',
'externalTransactionId' => 'INV-001',
'callBackURL' => '<string>',
'customData' => '<string>'
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-m.dexchange.sn/api/v1/billing/pay"
payload := strings.NewReader("{\n \"serviceCode\": \"SENELEC_SN_BILL\",\n \"reference_client\": \"210278816\",\n \"amount\": 104500,\n \"reference_facture\": \"<string>\",\n \"externalTransactionId\": \"INV-001\",\n \"callBackURL\": \"<string>\",\n \"customData\": \"<string>\"\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-m.dexchange.sn/api/v1/billing/pay")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"serviceCode\": \"SENELEC_SN_BILL\",\n \"reference_client\": \"210278816\",\n \"amount\": 104500,\n \"reference_facture\": \"<string>\",\n \"externalTransactionId\": \"INV-001\",\n \"callBackURL\": \"<string>\",\n \"customData\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-m.dexchange.sn/api/v1/billing/pay")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"serviceCode\": \"SENELEC_SN_BILL\",\n \"reference_client\": \"210278816\",\n \"amount\": 104500,\n \"reference_facture\": \"<string>\",\n \"externalTransactionId\": \"INV-001\",\n \"callBackURL\": \"<string>\",\n \"customData\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message": "Bill paid successfully",
"transaction": {
"success": true,
"transactionId": "TID123456789",
"externalTransactionId": "INV-001",
"transactionType": "BILL",
"amount": 104500,
"transactionFee": 1045,
"number": "210278816",
"referenceFacture": "8000000680",
"token": "1283930093209223",
"Status": "SUCCESS",
"previousBalance": 500000,
"currentBalance": 394455,
"message": "<string>"
}
}{
"message": [
"<string>"
],
"success": true
}Payer une facture / Recharger
Règle une facture (SenEau, Senelec) ou effectue une recharge prépayée (Woyofal). Le montant est débité du solde de votre compte (montant de la facture + vos frais de serviceFEE).
Le débit n’a lieu qu’après acceptation par le provider. En cas d’échec, aucun débit n’est effectué (ou un remboursement automatique est appliqué pour les recharges asynchrones).
Endpoint
POST /api/v1/billing/pay
Headers
| Nom | Type | Requis | Description |
|---|---|---|---|
| Authorization | string | Oui | Bearer YOUR_API_KEY |
| Content-Type | string | Oui | application/json |
Corps de la Requête
{
"serviceCode": string, // Code du biller
"reference_client": string, // Numéro de compteur / référence client
"amount": number, // Requis pour Woyofal (montant libre)
"reference_facture": string, // Optionnel : facture ciblée
"externalTransactionId": string, // Optionnel : votre référence unique
"callBackURL": string, // Optionnel : URL de notification
"customData": string // Optionnel
}
Paramètres
| Paramètre | Type | Requis | Description |
|---|---|---|---|
| serviceCode | string | Oui | SENEAU_SN_BILL, SENELEC_SN_BILL ou WOYOFAL_SN_BILL |
| reference_client | string | Oui | Numéro de compteur / police / référence client |
| amount | number | Woyofal | Montant à recharger. Requis pour Woyofal ; ignoré pour SenEau/Senelec (montant imposé par la facture) |
| reference_facture | string | Non | Cible une facture précise. Sinon, la 1ʳᵉ facture impayée est réglée |
| externalTransactionId | string | Non | Votre identifiant unique (idempotence) |
| callBackURL | string | Non | URL pour les notifications webhook |
| customData | string | Non | Donnée libre renvoyée dans le callback |
Montant : pour SenEau et Senelec, le montant est imposé par la facture (le champ
amount est ignoré). Pour Woyofal (recharge prépayée), le client choisit le montant via amount.Réponse
Facture payée (SenEau / Senelec — synchrone)
{
"message": "Bill paid successfully",
"transaction": {
"success": true,
"transactionId": "TID123456789",
"externalTransactionId": "INV-001",
"transactionType": "BILL",
"amount": 104500,
"transactionFee": 1045,
"number": "210278816",
"referenceFacture": "8000000680",
"Status": "SUCCESS",
"previousBalance": 500000,
"currentBalance": 394455
}
}
Recharge réussie (Woyofal — token immédiat)
{
"message": "Bill paid successfully",
"transaction": {
"success": true,
"transactionId": "TID987654321",
"transactionType": "BILL",
"amount": 1000,
"transactionFee": 10,
"number": "07061270877",
"token": "1283930093209223",
"Status": "SUCCESS",
"currentBalance": 498990
}
}
token = code de recharge à saisir sur le compteur. Présent uniquement pour les recharges prépayées (Woyofal).Recharge en cours (Woyofal — asynchrone)
Si le provider ne confirme pas immédiatement, la transaction passe enPROCESSING. Le token est livré dès résolution (consultable via le webhook / l’historique de transaction).
{
"message": "Bill paid successfully",
"transaction": {
"success": true,
"transactionId": "TID987654321",
"transactionType": "BILL",
"amount": 1000,
"Status": "PROCESSING",
"message": "Recharge en cours — token disponible sous peu"
}
}
Pour une recharge
PROCESSING qui échoue finalement, le montant débité (montant + frais) est automatiquement remboursé sur votre solde et un callback FAILED est envoyé.Réponse d’Erreur
{
"message": "Failed to pay bill",
"transaction": {
"success": false,
"Status": "FAILED",
"message": "Insufficient balance"
}
}
Codes d’Erreur
| Code HTTP | Description |
|---|---|
| 400 | Paramètres invalides, solde insuffisant, facture déjà payée |
| 401 | Clé API invalide |
| 403 | API en maintenance |
| 409 | externalTransactionId déjà utilisé |
Exemples de Requête
Payer une facture Senelec
curl -X POST https://api-m.dexchange.sn/api/v1/billing/pay \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"serviceCode": "SENELEC_SN_BILL",
"reference_client": "210278816",
"externalTransactionId": "INV-001",
"callBackURL": "https://your-domain.com/callback"
}'
Recharger un compteur Woyofal
curl -X POST https://api-m.dexchange.sn/api/v1/billing/pay \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"serviceCode": "WOYOFAL_SN_BILL",
"reference_client": "07061270877",
"amount": 1000,
"externalTransactionId": "RCH-001",
"callBackURL": "https://your-domain.com/callback"
}'
Webhook de Notification
Comme pour les transactions classiques, un webhook est envoyé àcallBackURL lors du changement de statut (SUCCESS / FAILED) :
{
"id": "TID123456789",
"externalTransactionId": "INV-001",
"transactionType": "BILL",
"AMOUNT": 104500,
"FEE": 1045,
"PHONE_NUMBER": "210278816",
"STATUS": "SUCCESS",
"COMPLETED_AT": "2024-03-20T10:35:00Z",
"PREVIOUS_BALANCE": 500000,
"CURRENT_BALANCE": 394455
}
Authorizations
Entrez votre clé API comme: Bearer <API_KEY>
Body
application/json
Détails du paiement
Code du biller
Available options:
SENEAU_SN_BILL, SENELEC_SN_BILL, WOYOFAL_SN_BILL Example:
"SENELEC_SN_BILL"
Numéro de compteur / police / référence client
Example:
"210278816"
Montant à recharger. Requis pour Woyofal ; ignoré pour SenEau/Senelec (montant imposé).
Example:
104500
Optionnel : cible une facture précise. Sinon la 1re impayée est réglée.
Optionnel : votre référence unique (idempotence)
Example:
"INV-001"
Optionnel : URL de notification webhook
Optionnel