feat(billing): implement robust in-app subscription cancellation & fix CI/CD socket port typo
This commit is contained in:
@@ -16,12 +16,22 @@ export function resolvePriceId(tier: BillingTier, interval: BillingInterval): st
|
||||
};
|
||||
const priceId = map[tier][interval];
|
||||
if (!priceId) {
|
||||
const isMock = !process.env.STRIPE_SECRET_KEY || process.env.STRIPE_SECRET_KEY === 'sk_test_placeholder';
|
||||
if (isMock && process.env.NODE_ENV !== 'test') {
|
||||
return `price_mock_${tier.toLowerCase()}_${interval}`;
|
||||
}
|
||||
throw new Error(`No Stripe price ID configured for ${tier}/${interval}`);
|
||||
}
|
||||
return priceId;
|
||||
}
|
||||
|
||||
export function priceIdToTier(priceId: string): SubscriptionTier | null {
|
||||
if (priceId && priceId.startsWith('price_mock_')) {
|
||||
if (priceId.includes('pro')) return 'PRO';
|
||||
if (priceId.includes('business')) return 'BUSINESS';
|
||||
return 'BASIC';
|
||||
}
|
||||
|
||||
const entries: Array<[string | undefined, SubscriptionTier]> = [
|
||||
[process.env.STRIPE_PRICE_PRO_MONTHLY, 'PRO'],
|
||||
[process.env.STRIPE_PRICE_PRO_ANNUAL, 'PRO'],
|
||||
|
||||
Reference in New Issue
Block a user