trial-codes

Redeem With Cancel

Redeem a trial code for an existing paying customer.

TECH-657: Cancels the Stripe subscription (triggers prorated credit), then applies the trial with the target plan.

Transaction Safety (order prevents data loss):

  1. Validate code
  2. Record redemption (marks code as used)
  3. Update subscription to trial with target plan
  4. Clear Stripe IDs in DB
  5. COMMIT DB FIRST (ensures trial is active before touching Stripe)
  6. Cancel Stripe subscription (external call, may fail)

Why commit before Stripe cancel:

  • If DB commit fails: Customer keeps Stripe subscription (safe rollback)
  • If Stripe cancel fails after commit: Customer has trial + Stripe sub (recoverable via manual cancellation, customer is not left without access)
  • Previous approach risk: If Stripe succeeds but commit fails, customer loses Stripe sub AND doesn't get trial (unrecoverable data loss)
post/api/v1/billing/trial-codes/redeem-with-cancel

Request

  • Base URL: http://localhost:8000
  • URL: http://localhost:8000/api/v1/billing/trial-codes/redeem-with-cancel
  • Auth: none declared

Headers

Authorizationstring

Request body

codestring required

Trial code to redeem

Response

Successful Response

successboolean required
dataunknown
messagestring nullable
errorstring nullable
metaobject nullable

Changes

No recorded changes to this operation across all 1 revision of this API.