Copy
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "WebhookPayload",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string"
},
"apiVersion": {
"type": "string"
},
"created": {
"type": "integer"
},
"livemode": {
"type": "boolean"
},
"data": {
"type": "object",
"properties": {
"object": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string"
},
"total": {
"type": "integer"
},
"currency": {
"type": "string"
},
"customer": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"email": {
"type": "string"
}
},
"required": [
"id",
"email"
],
"additionalProperties": false
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"productId": {
"type": "integer"
},
"quantity": {
"type": "integer"
},
"price": {
"type": "integer"
}
},
"required": [
"productId",
"quantity",
"price"
],
"additionalProperties": false
}
}
},
"required": [
"id",
"status",
"total",
"currency",
"customer",
"items"
],
"additionalProperties": false
}
},
"required": [
"object"
],
"additionalProperties": false
},
"request": {
"type": "object",
"properties": {
"idempotencyKey": {
"type": "string"
}
},
"required": [
"idempotencyKey"
],
"additionalProperties": false
}
},
"required": [
"id",
"type",
"apiVersion",
"created",
"livemode",
"data",
"request"
],
"additionalProperties": false
}
Copy
import { z } from 'zod';
export const WebhookPayloadSchema = z.object({
id: z.string(),
type: z.string(),
apiVersion: z.string(),
created: z.number(),
livemode: z.boolean(),
data: z.object({
object: z.object({
id: z.string(),
status: z.string(),
total: z.number(),
currency: z.string(),
customer: z.object({
id: z.number(),
email: z.string()
}),
items: z.array(z.object({
productId: z.number(),
quantity: z.number(),
price: z.number()
}))
})
}),
request: z.object({
idempotencyKey: z.string()
})
});
export type WebhookPayload = z.infer<typeof WebhookPayloadSchema>;