[PR #3239] [CLOSED] fix(stripe): update priceId on subscription upgrade and webhook sync #4715

Closed
opened 2026-03-13 11:57:07 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3239
Author: @tinkerer-shubh
Created: 7/1/2025
Status: Closed

Base: mainHead: fix/price-id-sync-upgrade


📝 Commits (1)

  • 109319d fix(stripe): update priceId on subscription upgrade and webhook sync

📊 Changes

3 files changed (+7 additions, -1 deletions)

View changed files

📝 packages/stripe/src/hooks.ts (+2 -0)
📝 packages/stripe/src/index.ts (+1 -1)
📝 packages/stripe/src/schema.ts (+4 -0)

📄 Description

related issue: https://github.com/better-auth/better-auth/issues/3235

1. File: packages/stripe/src/hooks.ts

  • On Checkout Session Completion and Subscription Update:
    • The priceId is now included when updating the subscription object in the database.
    • This ensures the correct Stripe price ID is stored whenever a subscription is completed or updated, supporting better synchronization.

2. File: packages/stripe/src/index.ts

  • Subscription Object Construction:
    • When constructing the subscription object, priceId is now set to sub.priceId if it exists, otherwise it falls back to plan?.priceId.
    • Previously, it always took plan?.priceId. This makes the assignment more robust by preferring the subscription's own price ID, which is important after upgrades or webhook syncs.

3. File: packages/stripe/src/schema.ts

  • Subscription Schema Update:
    • The subscriptions schema now includes priceId as a (non-required) string field.
    • This update allows the priceId to be stored in the database alongside other subscription details, supporting the changes above.

🔄 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/3239 **Author:** [@tinkerer-shubh](https://github.com/tinkerer-shubh) **Created:** 7/1/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/price-id-sync-upgrade` --- ### 📝 Commits (1) - [`109319d`](https://github.com/better-auth/better-auth/commit/109319d356e0c473286bdcda7c6af88577a81120) fix(stripe): update priceId on subscription upgrade and webhook sync ### 📊 Changes **3 files changed** (+7 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/stripe/src/hooks.ts` (+2 -0) 📝 `packages/stripe/src/index.ts` (+1 -1) 📝 `packages/stripe/src/schema.ts` (+4 -0) </details> ### 📄 Description related issue: https://github.com/better-auth/better-auth/issues/3235 ### 1. File: `packages/stripe/src/hooks.ts` - **On Checkout Session Completion and Subscription Update:** - The `priceId` is now included when updating the subscription object in the database. - This ensures the correct Stripe price ID is stored whenever a subscription is completed or updated, supporting better synchronization. ### 2. File: `packages/stripe/src/index.ts` - **Subscription Object Construction:** - When constructing the subscription object, `priceId` is now set to `sub.priceId` if it exists, otherwise it falls back to `plan?.priceId`. - Previously, it always took `plan?.priceId`. This makes the assignment more robust by preferring the subscription's own price ID, which is important after upgrades or webhook syncs. ### 3. File: `packages/stripe/src/schema.ts` - **Subscription Schema Update:** - The `subscriptions` schema now includes `priceId` as a (non-required) string field. - This update allows the `priceId` to be stored in the database alongside other subscription details, supporting the changes above. --- <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 11:57:07 -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#4715