Stripe: `onSubscriptionUpdate` passes old subscription data
When the
For example, if a user switches from one plan to another, the passed
Relevant code:
My opinion is that it would be helpful if the callback included both the old subscription and the newly updated one, but I believe it should at last pass the new one.
onSubscriptionUpdate callback is fired, it passes the subscription data grabbed from the DB. However, this is the data before the updated properties are applied.For example, if a user switches from one plan to another, the passed
subscription object contains the old plan, not the new one.Relevant code:
- Subscription is fetched from DB: https://github.com/better-auth/better-auth/blob/main/packages/stripe/src/hooks.ts#L100-L125
- Subscription is updated in DB: https://github.com/better-auth/better-auth/blob/main/packages/stripe/src/hooks.ts#L128-L151
- Old subscription (from step 1) is passed to callback: https://github.com/better-auth/better-auth/blob/main/packages/stripe/src/hooks.ts#L165-L168
My opinion is that it would be helpful if the callback included both the old subscription and the newly updated one, but I believe it should at last pass the new one.