This commit updates the versions of some dependencies, removes a few unused packages, and corrects the locations of some of the dependencies. Specific changes include version updates for '@tanstack/react-query-next-experimental', 'lucide-react', and 'supabase'. Furthermore, several unnecessary '@tanstack/react-table', 'next', 'tailwind-merge', and 'zod' dependencies were removed from various packages. The exact details of these changes can be obtained by comparing the changes in the 'pnpm-lock.yaml' file.
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { getBillingEventHandlerService } from '@kit/billing-gateway';
|
|
import { getLogger } from '@kit/shared/logger';
|
|
import { getSupabaseRouteHandlerClient } from '@kit/supabase/route-handler-client';
|
|
|
|
import billingConfig from '~/config/billing.config';
|
|
|
|
/**
|
|
* @description Handle the webhooks from Stripe related to checkouts
|
|
*/
|
|
export async function POST(request: Request) {
|
|
const provider = billingConfig.provider;
|
|
const logger = await getLogger();
|
|
|
|
const ctx = {
|
|
name: 'billing.webhook',
|
|
provider,
|
|
};
|
|
|
|
logger.info(ctx, `Received billing webhook. Processing...`);
|
|
|
|
const supabaseClientProvider = () =>
|
|
getSupabaseRouteHandlerClient({ admin: true });
|
|
|
|
const service = await getBillingEventHandlerService(
|
|
supabaseClientProvider,
|
|
provider,
|
|
billingConfig,
|
|
);
|
|
|
|
try {
|
|
await service.handleWebhookEvent(request);
|
|
|
|
logger.info(ctx, `Successfully processed billing webhook`);
|
|
|
|
return new Response('OK', { status: 200 });
|
|
} catch (error) {
|
|
console.error(error);
|
|
|
|
logger.error(
|
|
{
|
|
...ctx,
|
|
error: JSON.stringify(error),
|
|
},
|
|
`Failed to process billing webhook`,
|
|
);
|
|
|
|
return new Response('Error', { status: 500 });
|
|
}
|
|
}
|