[PR #8095] [MERGED] fix(stripe): use CHECKOUT_SESSION_ID for success_url and remove cancel callback #7744

Closed
opened 2026-03-13 13:47:54 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8095
Author: @bytaesu
Created: 2/22/2026
Status: Merged
Merged: 2/22/2026
Merged by: @Bekacru

Base: canaryHead: 2026-02-22/fix/stripe-callback-checkout-session


📝 Commits (2)

  • 9664524 fix(stripe): use CHECKOUT_SESSION_ID for success_url and remove cancel callback
  • b9a60c2 Merge branch 'canary' into 2026-02-22/fix/stripe-callback-checkout-session

📊 Changes

4 files changed (+284 additions, -253 deletions)

View changed files

📝 packages/stripe/src/index.ts (+0 -2)
📝 packages/stripe/src/routes.ts (+39 -120)
📝 packages/stripe/test/stripe-organization.test.ts (+1 -130)
📝 packages/stripe/test/stripe.test.ts (+244 -1)

📄 Description

Note

Stripe attempts to deliver events to your destination for up to three days with an exponential back off in live mode. https://docs.stripe.com/webhooks#automatic-retries

The webhook was already handling all data processing, and Stripe webhooks automatically retry on failure. Handling db logic inside cancel callbacks is not a common pattern, so this has been improved. Since the callback was only used internally as a bridge, this is not a breaking change.


Summary by cubic

Switch the subscription success flow to use Stripe’s {CHECKOUT_SESSION_ID} and remove the cancel callback endpoint. This secures redirects and routes cancel flows through the Billing Portal and webhooks.

  • Refactors

    • Add checkoutSessionId={CHECKOUT_SESSION_ID} to success_url in upgradeSubscription; subscriptionSuccess resolves subscriptionId from checkout session metadata and handles missing/invalid IDs.
    • Remove /subscription/cancel/callback and related logic/tests; billing portal return_url now goes directly to the provided returnUrl.
    • Update types and tests for the new flow.
  • Migration

    • No changes if you use upgradeSubscription; the success_url is set automatically.
    • If you relied on /subscription/cancel/callback or subscriptionId in the success URL, move to the checkoutSessionId-based flow and use Stripe webhooks for cancel updates; the portal returns directly to your returnUrl.

Written for commit b9a60c2a5e. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8095 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 2/22/2026 **Status:** ✅ Merged **Merged:** 2/22/2026 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `2026-02-22/fix/stripe-callback-checkout-session` --- ### 📝 Commits (2) - [`9664524`](https://github.com/better-auth/better-auth/commit/96645249f9d3952a443f0e07d332d9c7d3845b20) fix(stripe): use CHECKOUT_SESSION_ID for success_url and remove cancel callback - [`b9a60c2`](https://github.com/better-auth/better-auth/commit/b9a60c2a5e618f85764515cb99114bc9e5658281) Merge branch 'canary' into 2026-02-22/fix/stripe-callback-checkout-session ### 📊 Changes **4 files changed** (+284 additions, -253 deletions) <details> <summary>View changed files</summary> 📝 `packages/stripe/src/index.ts` (+0 -2) 📝 `packages/stripe/src/routes.ts` (+39 -120) 📝 `packages/stripe/test/stripe-organization.test.ts` (+1 -130) 📝 `packages/stripe/test/stripe.test.ts` (+244 -1) </details> ### 📄 Description > [!NOTE] > Stripe attempts to deliver events to your destination for up to three days with an exponential back off in live mode. https://docs.stripe.com/webhooks#automatic-retries The webhook was already handling all data processing, and Stripe webhooks automatically retry on failure. Handling db logic inside cancel callbacks is not a common pattern, so this has been improved. Since the callback was only used internally as a bridge, this is not a breaking change. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Switch the subscription success flow to use Stripe’s {CHECKOUT_SESSION_ID} and remove the cancel callback endpoint. This secures redirects and routes cancel flows through the Billing Portal and webhooks. - **Refactors** - Add checkoutSessionId={CHECKOUT_SESSION_ID} to success_url in upgradeSubscription; subscriptionSuccess resolves subscriptionId from checkout session metadata and handles missing/invalid IDs. - Remove /subscription/cancel/callback and related logic/tests; billing portal return_url now goes directly to the provided returnUrl. - Update types and tests for the new flow. - **Migration** - No changes if you use upgradeSubscription; the success_url is set automatically. - If you relied on /subscription/cancel/callback or subscriptionId in the success URL, move to the checkoutSessionId-based flow and use Stripe webhooks for cancel updates; the portal returns directly to your returnUrl. <sup>Written for commit b9a60c2a5e618f85764515cb99114bc9e5658281. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:47:54 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7744