fix(stripe): set billing anchor for scheduled plan changes

This commit is contained in:
Taesu
2026-09-19 17:23:40 +09:00
parent 41b7dc15de
commit ee110db735
2 changed files with 9 additions and 3 deletions
+1
View File
@@ -861,6 +861,7 @@ export const upgradeSubscription = (options: StripeOptions) => {
{
items: newPhaseItems,
start_date: currentPhase.end_date,
billing_cycle_anchor: "phase_start",
proration_behavior: "none",
},
],
+8 -3
View File
@@ -2551,7 +2551,10 @@ describe("stripe subscription", () => {
expect(stripeMock.checkout.sessions.create).not.toHaveBeenCalled();
});
test("should schedule plan change at period end when scheduleAtPeriodEnd is true", async ({
/**
* @see https://github.com/better-auth/better-auth/issues/11336
*/
test("should reset the billing cycle anchor for a scheduled plan change", async ({
stripeMock,
memory,
stripeOptions,
@@ -2638,11 +2641,13 @@ describe("stripe subscription", () => {
expect.objectContaining({
metadata: { source: "@better-auth/stripe" },
end_behavior: "release",
phases: expect.arrayContaining([
phases: [
expect.anything(),
expect.objectContaining({
billing_cycle_anchor: "phase_start",
proration_behavior: "none",
}),
]),
],
}),
);
expect(stripeMock.billingPortal.sessions.create).not.toHaveBeenCalled();