[PR #8070] [MERGED] feat(stripe): track subscription schedule ID for pending plan changes #33326

Closed
opened 2026-04-17 23:57:35 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

Base: canaryHead: 2026-02-20/feat/stripe-handle-schedule


📝 Commits (5)

  • c3e6d07 feat(stripe): track subscription schedule ID for pending plan changes
  • 95bd354 fix: check schedule status on restore endpoint
  • 8cd06ff docs: add missing billingInterval field, update scheduleAtPeriodEnd related content
  • 87ed3a8 fix: spell
  • 14a5a0a fix: more spell

📊 Changes

7 files changed (+491 additions, -22 deletions)

View changed files

📝 docs/content/docs/plugins/stripe.mdx (+23 -14)
📝 packages/stripe/src/error-codes.ts (+5 -0)
📝 packages/stripe/src/hooks.ts (+6 -0)
📝 packages/stripe/src/routes.ts (+86 -4)
📝 packages/stripe/src/schema.ts (+4 -0)
📝 packages/stripe/src/types.ts (+5 -0)
📝 packages/stripe/test/stripe.test.ts (+362 -4)

📄 Description

This involves a schema change.

It won’t affect existing stripe customers, but a DB migration is needed to add the new fields.


Summary by cubic

Tracks and stores Stripe subscription schedule IDs so clients can detect pending plan changes and restore them safely. Webhooks sync billingInterval and stripeScheduleId, and restore handles both pending cancellations and scheduled changes with clearer errors.

  • New Features

    • Store schedule ID when scheduling a plan change; clear it on schedule release, upgrade, restore, or subscription deletion.
    • Webhooks sync stripeScheduleId and billingInterval on subscription updated; clear stripeScheduleId on subscription deleted.
    • Restore endpoint releases active schedules (checks status before release) and clears stripeScheduleId; falls back to cancel restore when only a pending cancel exists; uses SUBSCRIPTION_NOT_PENDING_CHANGE when nothing is pending.
    • Upgrade flow releases existing schedules created by this plugin and clears stripeScheduleId.
  • Migration

    • Add an optional stripeScheduleId column/field to the subscription model.
    • Update clients to read stripeScheduleId to detect pending plan changes.
    • Handle the new SUBSCRIPTION_NOT_PENDING_CHANGE error in restore flows.

Written for commit 14a5a0aec3. 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/8070 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 2/19/2026 **Status:** ✅ Merged **Merged:** 2/20/2026 **Merged by:** [@bytaesu](https://github.com/bytaesu) **Base:** `canary` ← **Head:** `2026-02-20/feat/stripe-handle-schedule` --- ### 📝 Commits (5) - [`c3e6d07`](https://github.com/better-auth/better-auth/commit/c3e6d0796e10182236d39c2107b77d7aa3eba1cc) feat(stripe): track subscription schedule ID for pending plan changes - [`95bd354`](https://github.com/better-auth/better-auth/commit/95bd354342d9473eac25ff1451a37f7211bfcb14) fix: check schedule status on restore endpoint - [`8cd06ff`](https://github.com/better-auth/better-auth/commit/8cd06ffeb37bb6c9c3783de1f05f711293c4ca81) docs: add missing billingInterval field, update scheduleAtPeriodEnd related content - [`87ed3a8`](https://github.com/better-auth/better-auth/commit/87ed3a835a9100f3f6b9174959cada7b129b1cc6) fix: spell - [`14a5a0a`](https://github.com/better-auth/better-auth/commit/14a5a0aec3654c33a0fc80ee0907adab11d65259) fix: more spell ### 📊 Changes **7 files changed** (+491 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/stripe.mdx` (+23 -14) 📝 `packages/stripe/src/error-codes.ts` (+5 -0) 📝 `packages/stripe/src/hooks.ts` (+6 -0) 📝 `packages/stripe/src/routes.ts` (+86 -4) 📝 `packages/stripe/src/schema.ts` (+4 -0) 📝 `packages/stripe/src/types.ts` (+5 -0) 📝 `packages/stripe/test/stripe.test.ts` (+362 -4) </details> ### 📄 Description This involves a schema change. It won’t affect existing stripe customers, but a DB migration is needed to add the new fields. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Tracks and stores Stripe subscription schedule IDs so clients can detect pending plan changes and restore them safely. Webhooks sync billingInterval and stripeScheduleId, and restore handles both pending cancellations and scheduled changes with clearer errors. - **New Features** - Store schedule ID when scheduling a plan change; clear it on schedule release, upgrade, restore, or subscription deletion. - Webhooks sync stripeScheduleId and billingInterval on subscription updated; clear stripeScheduleId on subscription deleted. - Restore endpoint releases active schedules (checks status before release) and clears stripeScheduleId; falls back to cancel restore when only a pending cancel exists; uses SUBSCRIPTION_NOT_PENDING_CHANGE when nothing is pending. - Upgrade flow releases existing schedules created by this plugin and clears stripeScheduleId. - **Migration** - Add an optional stripeScheduleId column/field to the subscription model. - Update clients to read stripeScheduleId to detect pending plan changes. - Handle the new SUBSCRIPTION_NOT_PENDING_CHANGE error in restore flows. <sup>Written for commit 14a5a0aec3654c33a0fc80ee0907adab11d65259. 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-17 23:57:35 -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#33326