Repository navigation
Ask for a new card, not a new purchase, when a payment is declined - #1098
Merged
Merged
Conversation
A card trial whose first charge is declined has its licence revoked while Stripe keeps retrying the subscription. The app showed "View Plans & Purchase License", and customers bought a second subscription beside the first one. - The licence status reports paymentFailed (with the subscription's billing) for a paid licence stopped while its subscription is past_due or unpaid, ahead of the free trial that ended with it. - The wall shows "Update card", which opens Stripe's add-a-card page; Stripe sets the card on the subscription and pays the open invoice. "I've updated my card" re-verifies the licence. - The billing portal opens for that licence, the licence page's "Update payment method" goes to the same page, and checkout and the card-trial offer are refused meanwhile. - verifyLicense stores the billing the licence site now sends for invalid licences, and the daily re-verification includes them, so a retry that goes through lifts the wall.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A card trial whose first charge is declined has its licence revoked on the licence site while Stripe keeps retrying the subscription (past_due, 8 retries in 7 days). The Cloud wall then showed View Plans & Purchase License, and customers bought a second subscription beside the first. That caused the duplicate subscriptions on 13 and 14 Oct.
What
Backend (
license)getPaymentFailedLicense(org): the latest paid licence that is not active, with billingpast_due/unpaidand not cancelling.GET /api/license/statusreturns it withpaymentFailed: trueandbilling. It takes precedence over a free trial that has run out (a card trial is charged when the free trial ends).createBillingPortalSessionfalls back to that licence. The new flowpayment_method_updateis accepted (DTO + service).checkout-linkand the card-trial eligibility refuse while a declined card is being retried.verifyLicensestoresbillingsent for invalid licences.reverifyPaidLicensesalso re-checks revoked/expired licences whose subscription is still live, so a retry that succeeds lifts the wall within a day.refreshLicensedoes the same, right after the card update.Frontend
payment-failedreason.Depends on
HelpCode-ai/anythingmcp-website#387: the portal
payment_method_updateflow andbillingon invalid licences. It must be deployed first; otherwise the wall never appears (no billing for revoked licences) and the portal opens on its home page.Tests
jest src/license src/ee: 230 passed. New cases cover status, checkout refusal, eligibility, portal fallback,getPaymentFailedLicenseand re-verification.billing-awareness(2 new),neutral-signup-and-billing,card-trial: all pass.tscclean, eslint 0 errors.