Several changes have been made in this commit. Firstly, updates have been made to the site-header-account-section and the pricing-table components to enhance UI aesthetics. Secondly, billing services have been significantly improved. A new method for retrieving plan information by an ID has been introduced. This method is available for all strategy services, including Stripe and Lemon-Squeezy. Furthermore, the way context and logging are handled during the billing process has been streamlined for better readability and efficiency.
62 lines
1.4 KiB
TypeScript
62 lines
1.4 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
import {
|
|
CancelSubscriptionParamsSchema,
|
|
CreateBillingCheckoutSchema,
|
|
CreateBillingPortalSessionSchema,
|
|
ReportBillingUsageSchema,
|
|
RetrieveCheckoutSessionSchema,
|
|
UpdateSubscriptionParamsSchema,
|
|
} from '../schema';
|
|
|
|
export abstract class BillingStrategyProviderService {
|
|
abstract createBillingPortalSession(
|
|
params: z.infer<typeof CreateBillingPortalSessionSchema>,
|
|
): Promise<{
|
|
url: string;
|
|
}>;
|
|
|
|
abstract retrieveCheckoutSession(
|
|
params: z.infer<typeof RetrieveCheckoutSessionSchema>,
|
|
): Promise<{
|
|
checkoutToken: string | null;
|
|
status: 'complete' | 'expired' | 'open';
|
|
isSessionOpen: boolean;
|
|
|
|
customer: {
|
|
email: string | null;
|
|
};
|
|
}>;
|
|
|
|
abstract createCheckoutSession(
|
|
params: z.infer<typeof CreateBillingCheckoutSchema>,
|
|
): Promise<{
|
|
checkoutToken: string;
|
|
}>;
|
|
|
|
abstract cancelSubscription(
|
|
params: z.infer<typeof CancelSubscriptionParamsSchema>,
|
|
): Promise<{
|
|
success: boolean;
|
|
}>;
|
|
|
|
abstract reportUsage(
|
|
params: z.infer<typeof ReportBillingUsageSchema>,
|
|
): Promise<{
|
|
success: boolean;
|
|
}>;
|
|
|
|
abstract updateSubscription(
|
|
params: z.infer<typeof UpdateSubscriptionParamsSchema>,
|
|
): Promise<{
|
|
success: boolean;
|
|
}>;
|
|
|
|
abstract getPlanById(planId: string): Promise<{
|
|
id: string;
|
|
name: string;
|
|
interval: string;
|
|
amount: number;
|
|
}>;
|
|
}
|