Billing

Webhooks

Handle webhooks from your billing provider.

TurboStarter takes care of handling billing webhooks to update the customer data based on the events received from billing provider.

Sometimes - you will need to set more webhooks, or do something custom with the webhooks.

In these cases, you can customize the billing webhook handler at apps/web/src/app/api/webhooks/billing/route.ts.

By default, the webhook handler is set to be as simple as possible:

route.ts
export { webhookHandler as POST } from "@turbostarter/billing/server";

However, you can extend it using the callbacks provided from @turbostarter/billing package:

route.ts
import { webhookHandler } from "@turbostarter/billing/server";
 
export const POST = (request: NextRequest) =>
  webhookHandler(request, {
    onCheckoutSessionCompleted: (sessionId) => {},
    onSubscriptionCreated: (subscriptionId) => {},
    onSubscriptionUpdated: (subscriptionId) => {},
    onSubscriptionDeleted: (subscriptionId) => {},
  });

You can provide one or more of the callbacks to handle the events you are interested in.

Last updated on

On this page

No Headings
Ship your startup everywhere. In minutes.Get TurboStarter