Commit 3dc7cab
feat(dev-plans): charge full price on tier upgrade
Replace prorated tier-change billing with a full-charge, fresh-cycle
model for DevPass and Chat plan upgrades.
On an upgrade we now update the Stripe subscription with
`billing_cycle_anchor: "now"` + `proration_behavior: "none"` +
`payment_behavior: "error_if_incomplete"`, so Stripe immediately charges
the full new-tier price, starts a fresh billing period, and applies no
proration. Credits reset to the new tier's full allowance with usage
zeroed. This removes the custom prorated-invoice + manual-rollback dance
and the prorated credit-delta math.
Downgrades are unchanged (DevPass deferred to renewal; Chat immediate).
- dev-plans: full-charge upgrade, full-reset credits, keep per-cycle
claim as a double-charge guard; preview returns full price + full
new-tier credits.
- stripe webhook: tier-change invoice (subscription_update) now full-
resets to the new tier (read from subscription metadata), idempotent
via unique stripeInvoiceId; add a chat-subscription skip branch so a
chat subscription_update invoice never flips the org to Pro.
- chat-plans: mirror the upgrade model; record the invoice id.
- remove now-unused getProratedCreditDelta; update tests + UI copy.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 31b25ce commit 3dc7cab
9 files changed
Lines changed: 511 additions & 1020 deletions
File tree
- apps
- api/src
- routes
- code/src/app/dashboard/components
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
| 434 | + | |
| 435 | + | |
434 | 436 | | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
445 | 453 | | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
453 | 472 | | |
454 | | - | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
455 | 492 | | |
456 | | - | |
457 | | - | |
| 493 | + | |
458 | 494 | | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
471 | 502 | | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | 503 | | |
487 | 504 | | |
488 | 505 | | |
| |||
0 commit comments