Improve and update billing flow

This commit updates various components in the billing flow due to a new schema that supports multiple line items per plan. The added flexibility rendered 'line-items-mapper.ts' redundant, which has been removed. Additionally, webhooks have been created for handling account membership insertions and deletions, as well as handling subscription deletions when an account is deleted. This message also introduces a new service to handle sending out invitation emails. Lastly, the validation of the billing provider has been improved for increased security and stability.
This commit is contained in:
giancarlo
2024-03-30 14:51:16 +08:00
parent f93af31009
commit e158ff28d8
30 changed files with 670 additions and 465 deletions

View File

@@ -2,7 +2,6 @@ import { SupabaseClient } from '@supabase/supabase-js';
import 'server-only';
import { AccountBillingService } from '@kit/billing-gateway';
import { Logger } from '@kit/shared/logger';
import { Database } from '@kit/supabase/database';
@@ -34,21 +33,7 @@ export class DeleteTeamAccountService {
`Requested team account deletion. Processing...`,
);
Logger.info(
{
name: this.namespace,
accountId: params.accountId,
userId: params.userId,
},
`Deleting all account subscriptions...`,
);
// First - we want to cancel all Stripe active subscriptions
const billingService = new AccountBillingService(adminClient);
await billingService.cancelAllAccountSubscriptions(params);
// now we can use the admin client to delete the account.
// we can use the admin client to delete the account.
const { error } = await adminClient
.from('accounts')
.delete()