[PR #6957] [CLOSED] feat(stripe): more flexible subscription cancellation and termination management #23890

Closed
opened 2026-04-15 22:02:39 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6957
Author: @bytaesu
Created: 12/23/2025
Status: Closed

Base: canaryHead: 2025-12-24/fix/stripe-subscription-status


📝 Commits (8)

  • 5f74311 feat: add Paystack plugin to community plugins list (#6782)
  • 33a451f feat(stripe): add cancelAt, canceledAt and endedAt fields
  • 6aebb75 add utils to manage subscription status easily
  • 4190208 update to use new fields and utils
  • 9e069f8 test: add test cases for subscription cancellation and termination
  • 0d6421e docs: revert 3rd party plugin docs
  • f31053c Merge branch 'canary' into 2025-12-24/fix/stripe-subscription-status
  • 28cacaf Merge branch 'canary' into 2025-12-24/fix/stripe-subscription-status

📊 Changes

7 files changed (+10043 additions, -77 deletions)

View changed files

bun.lock (+9176 -0)
📝 packages/stripe/src/hooks.ts (+43 -10)
📝 packages/stripe/src/routes.ts (+89 -65)
📝 packages/stripe/src/schema.ts (+12 -0)
📝 packages/stripe/src/stripe.test.ts (+680 -0)
📝 packages/stripe/src/types.ts (+18 -1)
📝 packages/stripe/src/utils.ts (+25 -1)

📄 Description

This PR improves https://github.com/better-auth/better-auth/pull/5487, which was implemented by @GautamBytes


This PR includes the following changes:

  • Add cancelAt, canceledAt, and endedAt fields (breaking change)
  • Add internal utilities for subscription status management
  • Improve handling of subscription cancellation in hooks and routes
  • Add tests related to cancellation and termination
  • Update Stripe plugin docs content

Closes https://github.com/better-auth/better-auth/issues/5388
Closes https://github.com/better-auth/better-auth/issues/5535
Closes https://github.com/better-auth/better-auth/issues/5780

To-do

  • Test with actual app
  • Update documentation

Summary by cubic

Adds flexible cancellation and termination tracking for Stripe subscriptions. Introduces new fields and smarter sync logic so scheduled and immediate cancels are handled reliably.

  • New Features

    • New subscription fields: cancelAt, canceledAt, endedAt; captured across checkout, updates, and deletion.
    • Helpers to standardize state checks: isActiveOrTrialing, isPendingCancel, isStripePendingCancel; used in hooks and routes.
    • Better cancellation flow: detect new cancellations, update DB, and support restoring by clearing cancel_at or cancel_at_period_end based on Stripe state.
    • Fallback sync when a cancel is already scheduled on Stripe but a webhook was missed.
  • Migration

    • Add cancelAt, canceledAt, endedAt to the subscription schema.
    • If you check cancelAtPeriodEnd, also consider cancelAt or use isPendingCancel.
    • Update any code that reads subscription fields to handle the new properties.

Written for commit 28cacaf9a2. Summary will update automatically 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/6957 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 12/23/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `2025-12-24/fix/stripe-subscription-status` --- ### 📝 Commits (8) - [`5f74311`](https://github.com/better-auth/better-auth/commit/5f743118c52fb1809922eae3130cee334f78e3a0) feat: add Paystack plugin to community plugins list (#6782) - [`33a451f`](https://github.com/better-auth/better-auth/commit/33a451fb6d0baf7169980f845061daef469d6834) feat(stripe): add cancelAt, canceledAt and endedAt fields - [`6aebb75`](https://github.com/better-auth/better-auth/commit/6aebb75d868c27cd75e732ed7866b2bf3c4f3b60) add utils to manage subscription status easily - [`4190208`](https://github.com/better-auth/better-auth/commit/4190208a84ae00dfd25cdd6126200ad4173ad5a9) update to use new fields and utils - [`9e069f8`](https://github.com/better-auth/better-auth/commit/9e069f87f7d1d9919bddffe59942b1faa01845e5) test: add test cases for subscription cancellation and termination - [`0d6421e`](https://github.com/better-auth/better-auth/commit/0d6421e67b90c9938077391cf920fdbd6f767c6b) docs: revert 3rd party plugin docs - [`f31053c`](https://github.com/better-auth/better-auth/commit/f31053cb9d7124beedeb87f33459d3bfb43dc1db) Merge branch 'canary' into 2025-12-24/fix/stripe-subscription-status - [`28cacaf`](https://github.com/better-auth/better-auth/commit/28cacaf9a2f0d6edc3e4dd310d2e9c1af17d6a7e) Merge branch 'canary' into 2025-12-24/fix/stripe-subscription-status ### 📊 Changes **7 files changed** (+10043 additions, -77 deletions) <details> <summary>View changed files</summary> ➕ `bun.lock` (+9176 -0) 📝 `packages/stripe/src/hooks.ts` (+43 -10) 📝 `packages/stripe/src/routes.ts` (+89 -65) 📝 `packages/stripe/src/schema.ts` (+12 -0) 📝 `packages/stripe/src/stripe.test.ts` (+680 -0) 📝 `packages/stripe/src/types.ts` (+18 -1) 📝 `packages/stripe/src/utils.ts` (+25 -1) </details> ### 📄 Description > This PR improves https://github.com/better-auth/better-auth/pull/5487, which was implemented by @GautamBytes --- This PR includes the following changes: - Add `cancelAt`, `canceledAt`, and `endedAt` fields (**_breaking change_**) - Add internal utilities for subscription status management - Improve handling of subscription cancellation in hooks and routes - Add tests related to cancellation and termination - Update Stripe plugin docs content Closes https://github.com/better-auth/better-auth/issues/5388 Closes https://github.com/better-auth/better-auth/issues/5535 Closes https://github.com/better-auth/better-auth/issues/5780 ### To-do - [x] Test with actual app - [ ] Update documentation <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds flexible cancellation and termination tracking for Stripe subscriptions. Introduces new fields and smarter sync logic so scheduled and immediate cancels are handled reliably. - **New Features** - New subscription fields: cancelAt, canceledAt, endedAt; captured across checkout, updates, and deletion. - Helpers to standardize state checks: isActiveOrTrialing, isPendingCancel, isStripePendingCancel; used in hooks and routes. - Better cancellation flow: detect new cancellations, update DB, and support restoring by clearing cancel_at or cancel_at_period_end based on Stripe state. - Fallback sync when a cancel is already scheduled on Stripe but a webhook was missed. - **Migration** - Add cancelAt, canceledAt, endedAt to the subscription schema. - If you check cancelAtPeriodEnd, also consider cancelAt or use isPendingCancel. - Update any code that reads subscription fields to handle the new properties. <sup>Written for commit 28cacaf9a2f0d6edc3e4dd310d2e9c1af17d6a7e. Summary will update automatically 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-15 22:02:39 -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#23890