Webhook map
orderspaid(orders.paid)
paymentscaptured(payments.captured)failed(payments.failed)
refundsprocessed(refunds.processed)
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
Orders
Paid
orders.paid
A Razorpay order was paid
Payload
| Name | Type | Required | Description |
|---|---|---|---|
entity | event | Yes | — |
account_id | string | Yes | — |
event | order.paid | Yes | — |
contains | string[] | Yes | — |
created_at | number | Yes | — |
payload | object | Yes | — |
payload full type
payload full type
{
order: {
entity: {
id: string,
entity: order,
amount: number,
amount_paid?: number | null,
amount_due?: number,
currency: string,
receipt?: string | null,
offer_id?: string | null,
status: string,
attempts?: number,
notes?: {
} | any[],
created_at?: number
}
},
payment?: {
entity: {
id: string,
entity: payment,
amount: number,
currency: string,
status: string,
order_id?: string | null,
invoice_id?: string | null,
method?: string | null,
captured?: boolean,
description?: string | null,
email?: string | null,
contact?: string | null,
notes?: {
} | any[],
created_at?: number
}
}
}
Response data full type
Response data full type
{
entity: event,
account_id: string,
event: order.paid,
contains: string[],
created_at: number,
payload: {
order: {
entity: {
id: string,
entity: order,
amount: number,
amount_paid?: number | null,
amount_due?: number,
currency: string,
receipt?: string | null,
offer_id?: string | null,
status: string,
attempts?: number,
notes?: {
} | any[],
created_at?: number
}
},
payment?: {
entity: {
id: string,
entity: payment,
amount: number,
currency: string,
status: string,
order_id?: string | null,
invoice_id?: string | null,
method?: string | null,
captured?: boolean,
description?: string | null,
email?: string | null,
contact?: string | null,
notes?: {
} | any[],
created_at?: number
}
}
}
}
webhookHooks example
razorpay({
webhookHooks: {
orders: {
paid: {
before(ctx, args) {
return { ctx, args };
},
after(ctx, response) {
},
},
},
},
})
Payments
Captured
payments.captured
A Razorpay payment was captured
Payload
| Name | Type | Required | Description |
|---|---|---|---|
entity | event | Yes | — |
account_id | string | Yes | — |
event | payment.captured | Yes | — |
contains | string[] | Yes | — |
created_at | number | Yes | — |
payload | object | Yes | — |
payload full type
payload full type
{
payment: {
entity: {
id: string,
entity: payment,
amount: number,
currency: string,
status: string,
order_id?: string | null,
invoice_id?: string | null,
method?: string | null,
captured?: boolean,
description?: string | null,
email?: string | null,
contact?: string | null,
notes?: {
} | any[],
created_at?: number
}
}
}
Response data full type
Response data full type
{
entity: event,
account_id: string,
event: payment.captured,
contains: string[],
created_at: number,
payload: {
payment: {
entity: {
id: string,
entity: payment,
amount: number,
currency: string,
status: string,
order_id?: string | null,
invoice_id?: string | null,
method?: string | null,
captured?: boolean,
description?: string | null,
email?: string | null,
contact?: string | null,
notes?: {
} | any[],
created_at?: number
}
}
}
}
webhookHooks example
razorpay({
webhookHooks: {
payments: {
captured: {
before(ctx, args) {
return { ctx, args };
},
after(ctx, response) {
},
},
},
},
})
Failed
payments.failed
A Razorpay payment failed
Payload
| Name | Type | Required | Description |
|---|---|---|---|
entity | event | Yes | — |
account_id | string | Yes | — |
event | payment.failed | Yes | — |
contains | string[] | Yes | — |
created_at | number | Yes | — |
payload | object | Yes | — |
payload full type
payload full type
{
payment: {
entity: {
id: string,
entity: payment,
amount: number,
currency: string,
status: string,
order_id?: string | null,
invoice_id?: string | null,
method?: string | null,
captured?: boolean,
description?: string | null,
email?: string | null,
contact?: string | null,
notes?: {
} | any[],
created_at?: number
}
}
}
Response data full type
Response data full type
{
entity: event,
account_id: string,
event: payment.failed,
contains: string[],
created_at: number,
payload: {
payment: {
entity: {
id: string,
entity: payment,
amount: number,
currency: string,
status: string,
order_id?: string | null,
invoice_id?: string | null,
method?: string | null,
captured?: boolean,
description?: string | null,
email?: string | null,
contact?: string | null,
notes?: {
} | any[],
created_at?: number
}
}
}
}
webhookHooks example
razorpay({
webhookHooks: {
payments: {
failed: {
before(ctx, args) {
return { ctx, args };
},
after(ctx, response) {
},
},
},
},
})
Refunds
Processed
refunds.processed
A Razorpay refund was processed
Payload
| Name | Type | Required | Description |
|---|---|---|---|
entity | event | Yes | — |
account_id | string | Yes | — |
event | refund.processed | Yes | — |
contains | string[] | Yes | — |
created_at | number | Yes | — |
payload | object | Yes | — |
payload full type
payload full type
{
refund: {
entity: {
id: string,
entity: refund,
payment_id: string,
amount: number,
currency?: string | null,
notes?: {
} | any[],
receipt?: string | null,
speed_processed?: string | null,
speed_requested?: string | null,
status: string,
created_at?: number
}
},
payment?: {
entity: {
id: string,
entity: payment,
amount: number,
currency: string,
status: string,
order_id?: string | null,
invoice_id?: string | null,
method?: string | null,
captured?: boolean,
description?: string | null,
email?: string | null,
contact?: string | null,
notes?: {
} | any[],
created_at?: number
}
}
}
Response data full type
Response data full type
{
entity: event,
account_id: string,
event: refund.processed,
contains: string[],
created_at: number,
payload: {
refund: {
entity: {
id: string,
entity: refund,
payment_id: string,
amount: number,
currency?: string | null,
notes?: {
} | any[],
receipt?: string | null,
speed_processed?: string | null,
speed_requested?: string | null,
status: string,
created_at?: number
}
},
payment?: {
entity: {
id: string,
entity: payment,
amount: number,
currency: string,
status: string,
order_id?: string | null,
invoice_id?: string | null,
method?: string | null,
captured?: boolean,
description?: string | null,
email?: string | null,
contact?: string | null,
notes?: {
} | any[],
created_at?: number
}
}
}
}
webhookHooks example
razorpay({
webhookHooks: {
refunds: {
processed: {
before(ctx, args) {
return { ctx, args };
},
after(ctx, response) {
},
},
},
},
})