Skip to main content

Payload Structure

interface WebhookEvent {
  event_id: string;
  type: "checkout.failed";
  data: {
    id: string; // id of the checkout you originally created
    type: "deposit" | "withdrawal";
    charge: {
      id: string;
      status: string;
      from_status: string;
      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.failed",
  "data": {
    "id": "chk_twijxXgVFofj9mdnvzF7vhbJSZEhfUpC",
    "type": "deposit",
    "charge": {
      "id": "ch_yRZcCGouimTgbz4thtrfbj2mh3ZT6vnz",
      "status": "failed",
      "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

This event is triggered when a deposit or withdrawal fails. For the most part the player’s balance is not affected by this event - however it is possible that a charge (usually a withdrawal) can transition from succeeded to failed. You can track this if you keep the state of the charge.id or you can use the from_status field to track the state of the charge.