curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/portal \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"returnUrl": "https://yourapp.com/settings/billing"
}'
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/portal', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
returnUrl: 'https://yourapp.com/settings/billing'
})
});
const data = await response.json();
// Redirect user to Stripe portal
window.location.href = data.url;
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/portal',
headers={
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
json={
'returnUrl': 'https://yourapp.com/settings/billing'
}
)
data = response.json()
print(f"Redirect to: {data['url']}")
{
"url": "https://billing.stripe.com/p/session/test_a1b2c3d4..."
}
Abonnements
Portail de facturation
Crée une session du portail client Stripe pour gérer l’abonnement et les moyens de paiement.
POST
/
subscriptions
/
portal
curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/portal \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"returnUrl": "https://yourapp.com/settings/billing"
}'
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/portal', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
returnUrl: 'https://yourapp.com/settings/billing'
})
});
const data = await response.json();
// Redirect user to Stripe portal
window.location.href = data.url;
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/portal',
headers={
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
json={
'returnUrl': 'https://yourapp.com/settings/billing'
}
)
data = response.json()
print(f"Redirect to: {data['url']}")
{
"url": "https://billing.stripe.com/p/session/test_a1b2c3d4..."
}
Vue d’ensemble
Crée une session du portail client Stripe où l’utilisateur peut :- mettre à jour ses moyens de paiement
- consulter l’historique de facturation
- modifier sa formule d’abonnement
- télécharger les factures
- résilier son abonnement
Pour les intégrations tierces : utilisez
POST /subscriptions/portal/api avec authentification par clé d’API.Authentification
string
requis
Jeton d’accès JWT. Format :
Bearer YOUR_ACCESS_TOKENCorps de la requête
string
URL de retour à la sortie du portail. Par défaut : tableau de bord de l’application.
curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/portal \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"returnUrl": "https://yourapp.com/settings/billing"
}'
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/portal', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
returnUrl: 'https://yourapp.com/settings/billing'
})
});
const data = await response.json();
// Redirect user to Stripe portal
window.location.href = data.url;
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/portal',
headers={
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
json={
'returnUrl': 'https://yourapp.com/settings/billing'
}
)
data = response.json()
print(f"Redirect to: {data['url']}")
{
"url": "https://billing.stripe.com/p/session/test_a1b2c3d4..."
}
Champs de réponse
string
URL de redirection vers le portail de facturation hébergé par Stripe.
Fonctionnalités du portail
Le portail client Stripe permet notamment :| Fonctionnalité | Description |
|---|---|
| Moyens de paiement | Ajouter, mettre à jour ou supprimer des cartes |
| Factures | Consulter et télécharger les factures passées |
| Changement de formule | Passer à une offre supérieure ou inférieure |
| Résiliation | Résilier l’abonnement |
| Historique | Voir toutes les transactions |
Réponses d’erreur
Requête incorrecte : aucun compte de facturation trouvé. Un achat préalable est nécessaire.
Non autorisé : jeton manquant ou invalide.
Le portail n’est disponible que pour les utilisateurs ayant déjà effectué un achat ou disposant d’un abonnement actif. Les nouveaux utilisateurs doivent passer par le checkout.
POST /subscriptions/portal/api
Crée une session du portail client Stripe avec authentification par clé d’API. Adapté aux intégrations tierces.Authentification
Authentification par clé d’API obligatoire. Indiquez votre clé dans l’en-têteAuthorization :
Authorization: Bearer llmgen_your_api_key_here
Corps de la requête
Identique à/subscriptions/portal ci-dessus.
Réponse
Identique à/subscriptions/portal ci-dessus.
curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/portal/api \
-H "Authorization: Bearer llmgen_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"returnUrl": "https://yourapp.com/settings/billing"
}'
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/portal/api', {
method: 'POST',
headers: {
'Authorization': 'Bearer llmgen_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
returnUrl: 'https://yourapp.com/settings/billing'
})
});
const data = await response.json();
// Redirect user to Stripe portal
window.location.href = data.url;
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/portal/api',
headers={
'Authorization': 'Bearer llmgen_your_api_key_here',
'Content-Type': 'application/json'
},
json={
'returnUrl': 'https://yourapp.com/settings/billing'
}
)
data = response.json()
print(f"Redirect to: {data['url']}")
Bonnes pratiques
- Lien dans les paramètres : ajouter un bouton « Gérer la facturation » dans les réglages
- Après le checkout : proposer le portail juste après un achat
- Support : offrir un accès en libre-service pour les questions de facturation
Cette page vous a-t-elle été utile ?
⌘I