Refactor API code and simplify billing display
The code in the webhook API has been refactored to move the DatabaseWebhookHandlerService instance out of the POST function scope. Furthermore, the display of renewal plan details on the billing page has been simplified and certain parts deemed superfluous have been removed. Numerous types and interfaces in the database.types.ts file have also been corrected and formatted for consistency and improved readability.
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { Database } from '@kit/supabase/database';
|
||||
|
||||
type SubscriptionObject = Database['public']['Tables']['subscriptions'];
|
||||
|
||||
type SubscriptionUpdateParams = SubscriptionObject['Update'];
|
||||
type UpsertSubscriptionParams =
|
||||
Database['public']['Functions']['upsert_subscription']['Args'];
|
||||
|
||||
/**
|
||||
* Represents an abstract class for handling billing webhook events.
|
||||
@@ -14,12 +13,13 @@ export abstract class BillingWebhookHandlerService {
|
||||
event: unknown,
|
||||
params: {
|
||||
onCheckoutSessionCompleted: (
|
||||
subscription: SubscriptionObject['Row'],
|
||||
subscription: UpsertSubscriptionParams,
|
||||
customerId: string,
|
||||
) => Promise<unknown>;
|
||||
|
||||
onSubscriptionUpdated: (
|
||||
subscription: SubscriptionUpdateParams,
|
||||
subscription: UpsertSubscriptionParams,
|
||||
customerId: string,
|
||||
) => Promise<unknown>;
|
||||
|
||||
onSubscriptionDeleted: (subscriptionId: string) => Promise<unknown>;
|
||||
|
||||
Reference in New Issue
Block a user