Implement updateSubscription feature and refactor billing services
This commit introduces the updateSubscription method to the BillingStrategyProviderService, ensuring that subscriptions can be updated within the billing core. Additionally, a refactor has been applied to the BillingGatewayFactoryService and stripe-billing-strategy.service to improve error handling and the robustness of subscription updates. Logging in the webhook route has been adjusted for clarity and the data model has been enhanced.
This commit is contained in:
@@ -37,6 +37,7 @@ export class DatabaseWebhookHandlerService {
|
||||
const service = new DatabaseWebhookRouterService(client);
|
||||
|
||||
try {
|
||||
// handle the webhook event based on the table
|
||||
await service.handleWebhook(json);
|
||||
|
||||
Logger.info(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { SupabaseClient } from '@supabase/supabase-js';
|
||||
|
||||
import { Logger } from '@kit/shared/logger';
|
||||
import { Database } from '@kit/supabase/database';
|
||||
|
||||
import { RecordChange, Tables } from '../record-change.type';
|
||||
@@ -21,14 +22,14 @@ export class DatabaseWebhookRouterService {
|
||||
return this.handleSubscriptionsWebhook(payload);
|
||||
}
|
||||
|
||||
case 'accounts_memberships': {
|
||||
const payload = body as RecordChange<typeof body.table>;
|
||||
|
||||
return this.handleAccountsMembershipsWebhook(payload);
|
||||
default: {
|
||||
Logger.warn(
|
||||
{
|
||||
table: body.table,
|
||||
},
|
||||
'No handler found for table',
|
||||
);
|
||||
}
|
||||
|
||||
default:
|
||||
throw new Error('No handler for this table');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,12 +53,4 @@ export class DatabaseWebhookRouterService {
|
||||
return service.handleSubscriptionDeletedWebhook(body.old_record);
|
||||
}
|
||||
}
|
||||
|
||||
private handleAccountsMembershipsWebhook(
|
||||
payload: RecordChange<'accounts_memberships'>,
|
||||
) {
|
||||
console.log('Accounts Memberships Webhook', payload);
|
||||
// no-op
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user