fix: new billing subscription

This commit is contained in:
John Yeo
2026-03-05 19:18:46 +00:00
parent 3d73d0eccb
commit d2f3907d9e
4 changed files with 10 additions and 15 deletions

View File

@@ -117,7 +117,7 @@ export const setupAttachBillingContext = async ({
targetCustomerProduct: currentCustomerProduct,
contextOverride,
params,
// paramDiscounts: params.discounts,
newBillingSubscription: shouldForceNewSubscription,
});
const featureQuantities = setupFeatureQuantitiesContext({
@@ -231,7 +231,7 @@ export const setupAttachBillingContext = async ({
externalId: params.subscription_id,
skipBillingChanges:
params.no_billing_changes ??
params.no_billing_changes === true ||
params.processor_subscription_id !== undefined,
};
};

View File

@@ -22,20 +22,16 @@ export const fetchStripeSubscriptionForBilling = async ({
product,
targetCusProductId,
params,
// newBillingSubscription,
newBillingSubscription,
}: {
ctx: AutumnContext;
fullCus: FullCustomer;
product?: Product;
targetCusProductId?: string;
// newBillingSubscription?: boolean;
newBillingSubscription?: boolean;
params?: AttachParamsV1 | MultiAttachParamsV0 | UpdateSubscriptionV1Params;
}): Promise<StripeSubscriptionWithDiscounts | undefined> => {
if (
params &&
"new_billing_subscription" in params &&
params.new_billing_subscription
) {
if (newBillingSubscription) {
return undefined;
}

View File

@@ -19,18 +19,16 @@ export const setupStripeBillingContext = async ({
product,
targetCustomerProduct,
contextOverride = {},
// paramDiscounts,
params,
// newBillingSubscription,
newBillingSubscription,
}: {
ctx: AutumnContext;
fullCustomer: FullCustomer;
product?: Product;
targetCustomerProduct?: FullCusProduct;
contextOverride?: BillingContextOverride;
// paramDiscounts?: AttachDiscount[];
params?: AttachParamsV1 | MultiAttachParamsV0 | UpdateSubscriptionV1Params;
// newBillingSubscription?: boolean;
newBillingSubscription?: boolean;
}) => {
const { stripeBillingContext } = contextOverride;
@@ -52,6 +50,7 @@ export const setupStripeBillingContext = async ({
product,
targetCusProductId: targetCustomerProduct?.id,
params,
newBillingSubscription,
});
const stripeSubscriptionSchedule = targetCustomerProduct

View File

@@ -249,7 +249,7 @@ test.concurrent(`${chalk.yellowBright("new-billing-sub 3: entities get separate
customer: entity2Final,
productId: premium.id,
});
}, 120000);
});
// =============================================================================
// TEST 4: Upgrade ignores new_billing_subscription
@@ -451,7 +451,7 @@ test.concurrent(`${chalk.yellowBright("new-billing-sub 6: customer upgrade doesn
customer: entityAfter,
productId: premium.id,
});
}, 120000);
});
// =============================================================================
// TEST 7: Free -> paid main with existing paid cycle honors new_billing_subscription