[PR #8032] [MERGED] fix(stripe): use correct stripeCustomerId on /subscription/cancel/callback endpoint #15945

Closed
opened 2026-04-13 10:19:09 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

Base: canaryHead: 2026-02-18/fix/stripe-cancel-customer-id


📝 Commits (1)

  • c5be5c0 fix(stripe): use correct stripeCustomerId on cancel callback endpoint

📊 Changes

2 files changed (+191 additions, -58 deletions)

View changed files

📝 packages/stripe/src/routes.ts (+61 -57)
📝 packages/stripe/test/stripe-organization.test.ts (+130 -1)

📄 Description

Fix a bug in /subscription/cancel/callback where the correct stripeCustomerId was not being used for organization subscriptions.

The /subscription/cancel/callback route acts as a safeguard in case webhooks are delayed or fail. While this fix is needed, it likely didn't cause issues in practice because the customer.subscription.updated webhook typically arrives first and handles the update correctly. Additionally, even if a webhook is delayed or temporarily fails, Stripe will automatically retry the delivery.


Summary by cubic

Fix cancel callback to use the subscription’s stripeCustomerId instead of the session user’s. This ensures organization subscription cancellations are detected and saved correctly.

  • Bug Fixes
    • Query Stripe using subscription.stripeCustomerId and match the current stripeSubscriptionId.
    • Skip work if the subscription is canceled or pending cancel; otherwise update status/cancel fields and call onSubscriptionCancel.
    • Log errors and always redirect to the provided callbackURL.
    • Added a test that covers the org path and verifies Stripe is called with the org customer ID and DB updates occur.

Written for commit c5be5c07b7. 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/8032 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 2/18/2026 **Status:** ✅ Merged **Merged:** 2/18/2026 **Merged by:** [@bytaesu](https://github.com/bytaesu) **Base:** `canary` ← **Head:** `2026-02-18/fix/stripe-cancel-customer-id` --- ### 📝 Commits (1) - [`c5be5c0`](https://github.com/better-auth/better-auth/commit/c5be5c07b73d68fe6f2cc4f12fd658eee1169d55) fix(stripe): use correct stripeCustomerId on cancel callback endpoint ### 📊 Changes **2 files changed** (+191 additions, -58 deletions) <details> <summary>View changed files</summary> 📝 `packages/stripe/src/routes.ts` (+61 -57) 📝 `packages/stripe/test/stripe-organization.test.ts` (+130 -1) </details> ### 📄 Description Fix a bug in `/subscription/cancel/callback` where the correct `stripeCustomerId` was not being used for organization subscriptions. The `/subscription/cancel/callback` route acts as a safeguard in case webhooks are delayed or fail. While this fix is needed, it likely didn't cause issues in practice because the `customer.subscription.updated` webhook typically arrives first and handles the update correctly. Additionally, even if a webhook is delayed or temporarily fails, Stripe will automatically retry the delivery. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fix cancel callback to use the subscription’s stripeCustomerId instead of the session user’s. This ensures organization subscription cancellations are detected and saved correctly. - **Bug Fixes** - Query Stripe using subscription.stripeCustomerId and match the current stripeSubscriptionId. - Skip work if the subscription is canceled or pending cancel; otherwise update status/cancel fields and call onSubscriptionCancel. - Log errors and always redirect to the provided callbackURL. - Added a test that covers the org path and verifies Stripe is called with the org customer ID and DB updates occur. <sup>Written for commit c5be5c07b73d68fe6f2cc4f12fd658eee1169d55. 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-04-13 10:19:09 -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#15945