Refactor and improve billing module
The billing module has been refined and enhanced to include deeper validation and detailing of billing plans and products. The checkout session creation process was revised to handle more complex scenarios, incorporating better parsing and validation. Additional validations were added for the plan and product schemas, improving product details extraction, and rearranging of module exports was made for better organization. The code refactor allows easier future modifications and upgrades for recurring and one-time payments with nuanced product configurations.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use server';
|
||||
|
||||
import { redirect } from 'next/navigation';
|
||||
import { RedirectType, redirect } from 'next/navigation';
|
||||
|
||||
import { Logger } from '@kit/shared/logger';
|
||||
import { requireAuth } from '@kit/supabase/require-auth';
|
||||
@@ -33,28 +33,13 @@ export async function deletePersonalAccountAction(formData: FormData) {
|
||||
`Deleting personal account...`,
|
||||
);
|
||||
|
||||
const deleteAccountResponse = await service.deletePersonalAccount(
|
||||
await service.deletePersonalAccount(
|
||||
getSupabaseServerActionClient({ admin: true }),
|
||||
{
|
||||
userId,
|
||||
},
|
||||
);
|
||||
|
||||
//
|
||||
// also delete any associated data and subscriptions
|
||||
|
||||
if (deleteAccountResponse.error) {
|
||||
Logger.error(
|
||||
{
|
||||
error: deleteAccountResponse.error,
|
||||
name: 'accounts',
|
||||
},
|
||||
`Error deleting personal account`,
|
||||
);
|
||||
|
||||
throw new Error('Error deleting personal account');
|
||||
}
|
||||
|
||||
Logger.info(
|
||||
{
|
||||
userId,
|
||||
@@ -65,5 +50,5 @@ export async function deletePersonalAccountAction(formData: FormData) {
|
||||
|
||||
await client.auth.signOut();
|
||||
|
||||
redirect('/');
|
||||
redirect('/', RedirectType.replace);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user