Skip to main content
The Dodo Payments plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see Overview for setup context and the exact URL shape).
New to Corsair? See webhooks and hooks.

Webhook map

  • payments
    • failed (payments.failed)
    • succeeded (payments.succeeded)
  • refunds
    • succeeded (refunds.succeeded)
  • subscriptions
    • active (subscriptions.active)
    • cancelled (subscriptions.cancelled)

HTTP handler setup

app/api/webhook/route.ts
import { processWebhook } from "corsair";
import { corsair } from "@/server/corsair";

export async function POST(request: Request) {
    const headers = Object.fromEntries(request.headers);
    const body = await request.json();
    const result = await processWebhook(corsair, headers, body);
    return result.response;
}

Events

Payments

Failed

payments.failed A Dodo payment failed Payload
NameTypeRequiredDescription
eventpayment.failedYes
created_atstringNo
dataobjectYes
{
  id: string,
  amount: number,
  currency: string,
  status: string,
  customer_id?: string | null,
  subscription_id?: string | null,
  billing?: {
  } | null,
  payment_link?: string | null,
  created_at?: string
}
{
  event: payment.failed,
  created_at?: string,
  data: {
    id: string,
    amount: number,
    currency: string,
    status: string,
    customer_id?: string | null,
    subscription_id?: string | null,
    billing?: {
    } | null,
    payment_link?: string | null,
    created_at?: string
  }
}
webhookHooks example
dodopayments({
    webhookHooks: {
        payments: {
            failed: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Succeeded

payments.succeeded A Dodo payment succeeded Payload
NameTypeRequiredDescription
eventpayment.succeededYes
created_atstringNo
dataobjectYes
{
  id: string,
  amount: number,
  currency: string,
  status: string,
  customer_id?: string | null,
  subscription_id?: string | null,
  billing?: {
  } | null,
  payment_link?: string | null,
  created_at?: string
}
{
  event: payment.succeeded,
  created_at?: string,
  data: {
    id: string,
    amount: number,
    currency: string,
    status: string,
    customer_id?: string | null,
    subscription_id?: string | null,
    billing?: {
    } | null,
    payment_link?: string | null,
    created_at?: string
  }
}
webhookHooks example
dodopayments({
    webhookHooks: {
        payments: {
            succeeded: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Refunds

Succeeded

refunds.succeeded A Dodo refund succeeded Payload
NameTypeRequiredDescription
eventrefund.succeededYes
created_atstringNo
dataobjectYes
{
  id: string,
  payment_id: string,
  amount: number,
  status: string,
  reason?: string | null,
  created_at?: string
}
{
  event: refund.succeeded,
  created_at?: string,
  data: {
    id: string,
    payment_id: string,
    amount: number,
    status: string,
    reason?: string | null,
    created_at?: string
  }
}
webhookHooks example
dodopayments({
    webhookHooks: {
        refunds: {
            succeeded: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Subscriptions

Active

subscriptions.active A Dodo subscription became active Payload
NameTypeRequiredDescription
eventsubscription.activeYes
created_atstringNo
dataobjectYes
{
  id: string,
  customer_id: string,
  plan_id?: string | null,
  status: string,
  billing_cycle?: {
  } | null,
  created_at?: string
}
{
  event: subscription.active,
  created_at?: string,
  data: {
    id: string,
    customer_id: string,
    plan_id?: string | null,
    status: string,
    billing_cycle?: {
    } | null,
    created_at?: string
  }
}
webhookHooks example
dodopayments({
    webhookHooks: {
        subscriptions: {
            active: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})

Cancelled

subscriptions.cancelled A Dodo subscription was cancelled Payload
NameTypeRequiredDescription
eventsubscription.cancelledYes
created_atstringNo
dataobjectYes
{
  id: string,
  customer_id: string,
  plan_id?: string | null,
  status: string,
  billing_cycle?: {
  } | null,
  created_at?: string
}
{
  event: subscription.cancelled,
  created_at?: string,
  data: {
    id: string,
    customer_id: string,
    plan_id?: string | null,
    status: string,
    billing_cycle?: {
    } | null,
    created_at?: string
  }
}
webhookHooks example
dodopayments({
    webhookHooks: {
        subscriptions: {
            cancelled: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})