fix: new billing subscription
This commit is contained in:
@@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user