rubis/bruno/09-Billing/03 Open portal.bru
ordinarthur 3bad1451a9
All checks were successful
Build & Deploy Web / build-and-deploy (push) Successful in 19s
docs(bruno): collection Billing + endpoints check-in in-app
Nouveau dossier `09-Billing/` avec :
  - folder.bru (overview : plans + flows upgrade/cancel/reactivate)
  - 01 Get subscription : state du plan, caps, grace period, cancel flag
  - 02 Start checkout   : crée une Checkout Session Stripe (Pro/Business
                          × monthly/yearly)
  - 03 Open portal      : Customer Portal pour gérer CB/annulation
  - 04 Reactivate       : annule l'annulation programmée (sans paiement
                          immédiat) — gère le conflit Stripe
                          cancel_at vs cancel_at_period_end

Aussi documenté les endpoints in-app check-in qui manquaient dans Bruno :
  - 03 In-app pending           : liste des factures awaiting_user_confirmation
  - 04 In-app respond paid      : équivalent du lien email "C'est payé"
  - 05 In-app respond pending   : équivalent "Toujours en attente"

README mis à jour avec le parcours étendu (signup → … → billing).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 17:25:55 +02:00

51 lines
1.3 KiB
Plaintext

meta {
name: 03 Open portal
type: http
seq: 3
}
post {
url: {{baseUrl}}/api/v1/billing/portal
body: none
auth: bearer
}
auth:bearer {
token: {{token}}
}
tests {
test("200 OK", function () {
expect(res.getStatus()).to.equal(200);
});
test("URL Stripe Billing Portal retournée", function () {
expect(res.getBody().data.url).to.match(/^https:\/\/billing\.stripe\.com\//);
});
}
docs {
POST /api/v1/billing/portal — auth requise
Crée une Stripe Billing Portal Session pour que l'user gère lui-même
sa souscription (changement de CB, factures Stripe, annulation).
Précondition : l'org doit avoir un `stripeCustomerId` (= avoir déjà
passé un checkout au moins une fois). Sinon → 400 `no_stripe_customer`.
Réponse :
```json
{ "data": { "url": "https://billing.stripe.com/p/session/..." } }
```
Le SPA fait `window.location.href = url`. L'user fait ce qu'il veut
côté Stripe Portal, puis le redirect retourne vers
`${WEB_URL}/parametres/abonnement`.
## Annulation via portail
Quand l'user clique "Cancel plan" + confirme, Stripe pose `cancel_at`
(timestamp = period_end) et fire `customer.subscription.updated`. Notre
webhook détecte les 2 mécaniques (`cancel_at_period_end` ET `cancel_at`)
et les unifie en `org.cancel_at_period_end = true`.
}