Subscription & Payment
A family head subscribes to a doctor's plan through Stripe Checkout, with payment confirmation converging idempotently and the doctor gating activation.
- 1Family head calls POST /subscriptions/create/; a guard chain validates the plan, profile completeness and the three-doctor cap, then prices the plan server-side in the caller's detected currency
- 2Backend opens a Stripe Checkout session with the subscription id bound as client_reference_id and metadata at session and payment-intent level, returning the checkout URL
- 3Payment confirms through three converging paths — signed webhook, authenticated status poll, and unauthenticated confirm — all funnelling into one idempotent activator guarded by a global ProcessedStripeEvent ledger
- 4A new subscription lands PENDING (payment held, refundable) and notifies the doctor to accept or reject
- 5On accept, per-member message and video-call quota trackers are created and the subscription goes ACTIVE; on reject, Stripe issues an automatic refund



