Skip to main content

Payload Structure

interface WebhookEvent {
  event_id: string;
  type: "checkout.succeeded"
  data: {
    id: string; // id of the checkout you originally created
    type: "deposit" | "withdrawal";
    charge: {
      id: string; // id of the checkout you originally created
      status: "succeeded"
      from_status: "created" | "pending"; // rarely it will be from pending
      amount_cents: number;
      transaction_type: "credit" | "debit";
    };
    customer: {
      id: string;
    };
    line_items: Array<{
      product_id: string;
      quantity: number;
    }>;
    line_items_total_amount_cents: number | null;
  }
}

Example Response

{
  "event_id": "ev_tDaWu5aTVa2kbvDjGe55rxZpaMEmVFWB",
  "type": "checkout.succeeded",
  "data": {
    "id": "chk_twijxXgVFofj9mdnvzF7vhbJSZEhfUpC",
    "type": "deposit",
    "charge": {
      "id": "ch_yRZcCGouimTgbz4thtrfbj2mh3ZT6vnz",
      "status": "succeeded",
      "from_status": "created",
      "amount_cents": 2500,
      "transaction_type": "credit"
    },
    "customer": {
      "id": "cus_vi57KegYgcRqcGHqip8q6UZiqtrwMT870"
    },
    "line_items": [],
    "line_items_total_amount_cents": null
  }
}

Updating Player’s Balance

The transaction_type field in the charge object indicates the type of transaction:
  • credit: Represents money being added to the customer’s account
  • debit: Represents money being removed from the customer’s account