Payload Structure
interface WebhookEvent {
event_id: string;
data: {
id: string; // id of the checkout you originally created
line_items: Array<{
product_id: string;
quantity: number;
total_amount_cents: number;
product_name: string;
product_url: string;
product_price_cents: number;
sku: string;
}>;
line_items_total_amount_cents: number | null;
type: "deposit" | "withdrawal"; // the checkout type — not the event type below
charge: {
id: string;
amount_cents: number;
transaction_type: "credit" | "debit";
status: "succeeded";
from_status: "created" | "pending"; // rarely it will be from pending
failure_code: string | null;
failure_message: string | null;
};
customer: {
id: string;
};
subscription: {
id: string;
interval: "day" | "week" | "month" | "year";
interval_count: number;
line_items: Array<{
product_id: string;
sku: string;
product_name: string;
product_url: string;
quantity: number;
price_cents: number;
total_amount_cents: number;
}>;
line_items_total_amount_cents: number | null;
} | null; // null for non-subscription checkouts
};
type: "checkout.succeeded";
}
Example Response
{
"event_id": "ev_tDaWu5aTVa2kbvDjGe55rxZpaMEmVFWB",
"data": {
"id": "chk_twijxXgVFofj9mdnvzF7vhbJSZEhfUpC",
"line_items": [
{
"product_id": "prod_8KpQmZ3xRyVnTsUcWjLaGdBh",
"quantity": 2,
"total_amount_cents": 5000,
"product_name": "Gold Coins Pack",
"product_url": "https://example.com/products/gold-coins",
"product_price_cents": 2500,
"sku": "gold-coins-1000"
}
],
"line_items_total_amount_cents": 5000,
"type": "deposit",
"charge": {
"id": "ch_yRZcCGouimTgbz4thtrfbj2mh3ZT6vnz",
"amount_cents": 5000,
"transaction_type": "credit",
"status": "succeeded",
"from_status": "created",
"failure_code": null,
"failure_message": null
},
"customer": {
"id": "cus_vi57KegYgcRqcGHqip8q6UZiqtrwMT870"
},
"subscription": null
},
"type": "checkout.succeeded"
}
Updating Your Internal Ledger
Thetransaction_type field in the charge object indicates the type of transaction:
credit: Represents money being added to the customer’s accountdebit: Represents money being removed from the customer’s account

