Commit cd3cde1
authored
fix(billing): restore plan after dunning recovery (#3627)
* fix(billing): restore plan after dunning recovery in invoice.payment_succeeded
V8 audit C1: when markUnpaid downgrades a sub to plan=free and the user later
pays the overdue invoice, re-fetch the live Stripe subscription and write the
correct plan back alongside pastDueSince=null + status=active. Prevents paid
customers being permanently stuck on free plan if customer.subscription.updated
is dead-lettered. Falls back gracefully (warn log, no plan field) on Stripe
re-fetch error.
* fix(billing): guard getStripe() null + update JSDoc in invoice.payment_succeeded
/critical-review medium: add explicit `if (!stripe) throw` so the fallback warn
log is meaningful ("Stripe not configured") rather than a cryptic TypeError.
/critical-review low: update JSDoc @description to document V8 C1 plan-restore
behavior and the non-fatal Stripe re-fetch fallback contract.1 parent 998e302 commit cd3cde1
2 files changed
Lines changed: 101 additions & 3 deletions
File tree
- modules/billing
- services
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
538 | 538 | | |
539 | 539 | | |
540 | 540 | | |
541 | | - | |
| 541 | + | |
542 | 542 | | |
543 | 543 | | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
544 | 548 | | |
545 | 549 | | |
546 | 550 | | |
| |||
561 | 565 | | |
562 | 566 | | |
563 | 567 | | |
| 568 | + | |
| 569 | + | |
564 | 570 | | |
565 | 571 | | |
566 | 572 | | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
567 | 591 | | |
568 | 592 | | |
569 | 593 | | |
| |||
573 | 597 | | |
574 | 598 | | |
575 | 599 | | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
576 | 605 | | |
577 | 606 | | |
578 | 607 | | |
| |||
Lines changed: 71 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
68 | 77 | | |
69 | 78 | | |
70 | 79 | | |
| |||
441 | 450 | | |
442 | 451 | | |
443 | 452 | | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
444 | 456 | | |
445 | 457 | | |
446 | 458 | | |
447 | 459 | | |
448 | 460 | | |
449 | 461 | | |
450 | 462 | | |
451 | | - | |
| 463 | + | |
452 | 464 | | |
453 | 465 | | |
454 | 466 | | |
| |||
485 | 497 | | |
486 | 498 | | |
487 | 499 | | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
488 | 503 | | |
489 | 504 | | |
490 | 505 | | |
491 | 506 | | |
492 | 507 | | |
493 | 508 | | |
494 | 509 | | |
495 | | - | |
| 510 | + | |
496 | 511 | | |
497 | 512 | | |
498 | 513 | | |
| |||
520 | 535 | | |
521 | 536 | | |
522 | 537 | | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
523 | 541 | | |
524 | 542 | | |
525 | 543 | | |
| |||
531 | 549 | | |
532 | 550 | | |
533 | 551 | | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
534 | 603 | | |
535 | 604 | | |
536 | 605 | | |
| |||
0 commit comments