Créer un abonnement
curl --request POST \
--url https://api.example.com/v1/billing/subscriptionsimport requests
url = "https://api.example.com/v1/billing/subscriptions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/v1/billing/subscriptions', 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.example.com/v1/billing/subscriptions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/billing/subscriptions"
req, _ := http.NewRequest("POST", url, nil)
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.example.com/v1/billing/subscriptions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/billing/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyAbonnements
Créer un abonnement
Abonner un client à un plan
POST
/
v1
/
billing
/
subscriptions
Créer un abonnement
curl --request POST \
--url https://api.example.com/v1/billing/subscriptionsimport requests
url = "https://api.example.com/v1/billing/subscriptions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/v1/billing/subscriptions', 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.example.com/v1/billing/subscriptions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/billing/subscriptions"
req, _ := http.NewRequest("POST", url, nil)
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.example.com/v1/billing/subscriptions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/billing/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyCréer un abonnement
Les helpers
subscriptions.create() / createWithPayment() des SDKs appellent encore /v1/subscriptions,
qui n’existe pas. Utilisez les appels HTTP ci-dessous.Avec premier lien de paiement (recommandé)
POST /v1/billing/subscriptions/with-payment
| Paramètre | Type | Requis | Description |
|---|---|---|---|
plan_id | string | ✅ | Plan actif |
customer_phone | string | ✅ | Téléphone du client |
redirect_url | string | Retour après paiement | |
metadata | object | Données libres, copiées sur la facture |
INCOMPLETE et devient ACTIVE après le premier paiement.
curl -X POST https://api.sahelpay.ml/v1/billing/subscriptions/with-payment \
-H "Authorization: Bearer sk_test_xxx" \
-H "Content-Type: application/json" \
-d '{ "plan_id": "PLAN_ID", "customer_phone": "+22370123456" }'
{
"success": true,
"data": {
"subscription": {
"id": "...",
"plan_id": "PLAN_ID",
"plan_name": "Premium Mensuel",
"plan_amount": 10000,
"customer_phone": "+22370123456",
"status": "INCOMPLETE",
"next_billing_date": "2026-10-03T10:00:00.000Z",
"created_at": "2026-10-03T10:00:00.000Z"
},
"invoice": { "id": "...", "invoice_number": "...", "status": "OPEN", "total": 10000, "amount_due": 10000 },
"payment_link": { "id": "...", "url": "https://pay.sahelpay.ml/<slug>", "amount": 10000 }
}
}
Sans paiement immédiat
POST /v1/billing/subscriptions
| Paramètre | Type | Requis | Description |
|---|---|---|---|
plan_id | string | ✅ | Plan actif |
customer_phone | string | ✅ | Téléphone du client |
start_date | string | Date ISO de première échéance (défaut : maintenant) |
ACTIVE. Réponse : id, plan_id, plan_name, customer_phone, status, next_billing_date, created_at.
Erreurs
400 « Plan not found » ou « Plan inactive ».