prmbr-image-mksaas/src/credits/types.ts
javayhu 04f7f891a4 feat: update credit expiration handling and configuration
- Added expireDays property to credit packages and related configurations in website.tsx for better management of credit expiration.
- Modified addCredits function to handle expireDays more flexibly, allowing for undefined values.
- Updated functions for adding register gift and monthly free credits to utilize the new expireDays configuration.
- Enhanced type definitions for credits to include optional expireDays for improved clarity.
- Removed obsolete creditExpireDays from the credits configuration to streamline the codebase.
2025-07-10 01:12:11 +08:00

31 lines
1.3 KiB
TypeScript

/**
* Credit transaction type enum
*/
export enum CREDIT_TRANSACTION_TYPE {
MONTHLY_REFRESH = 'MONTHLY_REFRESH', // Credits earned by monthly refresh
REGISTER_GIFT = 'REGISTER_GIFT', // Credits earned by register gift
PURCHASE = 'PURCHASE', // Credits earned by purchase
USAGE = 'USAGE', // Credits spent by usage
EXPIRE = 'EXPIRE', // Credits expired
}
export interface CreditPackagePrice {
priceId: string; // Stripe price ID (not product id)
amount: number; // Price amount in currency units (dollars, euros, etc.)
currency: string; // Currency code (e.g., USD)
allowPromotionCode?: boolean; // Whether to allow promotion code for this price
}
/**
* Credit package
*/
export interface CreditPackage {
id: string; // Unique identifier for the package
credits: number; // Number of credits in the package
price: CreditPackagePrice; // Price of the package
popular: boolean; // Whether the package is popular
name?: string; // Display name of the package
description?: string; // Description of the package
expireDays?: number; // Number of days to expire the credits, undefined means no expire
}