chore: support allow promotion code in price config

This commit is contained in:
javayhu 2025-06-24 23:00:42 +08:00
parent cfbfa409b0
commit bd67ac3517
4 changed files with 6 additions and 2 deletions

View File

@ -119,6 +119,7 @@ export const websiteConfig: WebsiteConfig = {
priceId: process.env.NEXT_PUBLIC_STRIPE_PRICE_LIFETIME!,
amount: 19900,
currency: 'USD',
allowPromotionCode: true,
},
],
isFree: false,

View File

@ -227,6 +227,7 @@ export class StripeProvider implements PaymentProvider {
success_url: successUrl ?? '',
cancel_url: cancelUrl ?? '',
metadata: customMetadata,
allow_promotion_codes: price.allowPromotionCode ?? false,
};
// Add customer to checkout session

View File

@ -46,16 +46,17 @@ export interface Price {
currency: string; // Currency code (e.g., USD)
interval?: PlanInterval; // Billing interval for recurring payments
trialPeriodDays?: number; // Free trial period in days
allowPromotionCode?: boolean; // Whether to allow promotion code for this price
disabled?: boolean; // Whether to disable this price in UI
}
/**
* Price plan definition
*
*
* 1. When to set the plan disabled?
* When the plan is not available anymore, but you should keep it for existing users
* who have already purchased it, otherwise they can not see the plan in the Billing page.
*
*
* 2. When to set the price disabled?
* When the price is not available anymore, but you should keep it for existing users
* who have already purchased it, otherwise they can not see the price in the Billing page.

View File

@ -1,4 +1,5 @@
import type { ReactNode } from 'react';
import type { PricePlan } from '@/payment/types';
/**
* website config, without translations