Add Stripe Customer Portal session API for account billing #35

Merged
westfarn merged 1 commits from feature/stripe-customer-portal into master 2026-07-31 03:54:28 -07:00
Owner

Summary

  • Companion to chat_web_app#33 (Account billing + Customer Portal)
  • Follow-on from finance MVP #21: add authenticated POST /api/finance/portal/ that creates a Stripe Billing Portal session and returns portal_url
  • Resolve Stripe customer from the user's latest Invoice.stripe_customer_id; return 400 when missing (user must complete Checkout first)
  • Document STRIPE_PORTAL_RETURN_URL (default {FRONTEND_BASE_URL}/account/) in settings + env examples

Test plan

  • manage.py test finance.tests.test_portal finance.tests.test_checkout
  • Authenticated portal create with invoice that has stripe_customer_id201 + portal_url
  • No customer / unpaid user → 400 with clear detail
  • Missing STRIPE_SECRET_KEY503
  • Unauthenticated → 401
  • Custom return_url in body overrides default portal return URL
## Summary - Companion to [chat_web_app#33](https://git.aimloperations.com/ai_ml_operations/chat_web_app/issues/33) (Account billing + Customer Portal) - Follow-on from finance MVP [#21](https://git.aimloperations.com/ai_ml_operations/chat_backend/issues/21): add authenticated `POST /api/finance/portal/` that creates a Stripe Billing Portal session and returns `portal_url` - Resolve Stripe customer from the user's latest `Invoice.stripe_customer_id`; return `400` when missing (user must complete Checkout first) - Document `STRIPE_PORTAL_RETURN_URL` (default `{FRONTEND_BASE_URL}/account/`) in settings + env examples ## Test plan - [ ] `manage.py test finance.tests.test_portal finance.tests.test_checkout` - [ ] Authenticated portal create with invoice that has `stripe_customer_id` → `201` + `portal_url` - [ ] No customer / unpaid user → `400` with clear detail - [ ] Missing `STRIPE_SECRET_KEY` → `503` - [ ] Unauthenticated → `401` - [ ] Custom `return_url` in body overrides default portal return URL
westfarn added 1 commit 2026-07-31 03:48:35 -07:00
Add Stripe Customer Portal session API for account billing.
CI / test (pull_request) Successful in 10s
Unit Tests / test (pull_request) Successful in 9s
ac59af8b3e
Expose POST /api/finance/portal/ so authenticated users can open Stripe's hosted portal for plan changes, payment methods, and cancellations (chat_web_app#33 companion).
westfarn merged commit 67f16565e9 into master 2026-07-31 03:54:28 -07:00
westfarn deleted branch feature/stripe-customer-portal 2026-07-31 03:54:29 -07:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ai_ml_operations/chat_backend#35