Skip to main content

Order Canceled Webhook

Aghanim utilizes an order canceled webhook to inform you of a transaction reversed by a bank or a payment system, providing detailed information about the event.

The order canceled webhook is activated through the Order canceled event, selectable in Game → Webhooks.

warning

To remove in-game items from player accounts, use the item.remove webhook. The order canceled webhook is designed to provide detailed data when item.remove is insufficient.

Order canceled flow image
Order canceled flow image

Requirements

To use the order canceled webhook from Aghanim, you should have the webhook server configured as follows:

  • HTTPS endpoint, accepting POST webhook requests.
  • Listen for events, generated and signed by Aghanim.
  • Handle the idempotency_key included in the webhook payload to prevent processing duplicate webhooks.
  • Respond with a 2xx status code upon successful handling of an order canceled event, and 4xx or 5xx for denial or errors.

Configuration

  1. Develop a function for the order.canceled webhook processing.
  2. Make your endpoint available.
  3. Register your endpoint within Aghanim account → GameWebhooksNew Webhook by choosing the Order canceled event.

Alternatively, you can register your endpoint within Aghanim using the Create Webhook API method.

Request schema

Below is an example of an order.canceled webhook request:

POST /your/webhook/uri HTTP/1.1
Content-Type: application/json
Host: your-webhook-endpoint.com
User-Agent: Aghanim/0.1.0
X-Aghanim-Signature: 2e45ed4dede5e09506717490655d2f78e96d4261040ef48cc623a780bda38812
X-Aghanim-Signature-Timestamp: 1725548450

{
"event_type": "order.canceled",
"event_data": {
"amount": 9499,
"company_id": "com_exTAxmkZQCO",
"country": "US",
"created_at": 1725547595,
"currency": "USD",
"game_id": "gm_exTAyxPsVwh",
"id": "ord_eCacpFwavzi",
"items": [
{
"id": "itm_exTBZQmIlDz",
"name": "Crystals",
"description": "Reign supreme over your rivals with this massive crystal treasure.",
"sku": "crystals",
"quantity": 480000,
"price": 9499,
"price_decimal": 94.99,
"currency": "USD",
"type": "item",
"nested_items": null
}
],
"modified_at": 1725547657,
"player_id": "2D2R-OP3C",
"receipt_number": "2409051289614565",
"status": "canceled",
"user_id": "usr_eymySUreClx",
"metadata": null,
"creator": null
},
"event_time": 1725548450,
"event_id": "whevt_eCacGbJVbvToOgzjXUgOCitkQE",
"idempotency_key": "idmpt_aXRlb...JkX2VFS",
"request_id": "d1593e9c-c291-4004-8846-6679c2e5810b",
"sandbox": false,
"trigger": "checkout.cancel",
"transaction_id": "whtx_eCacGbJVbvT",
"context": null,
"game_id": "gm_exTAyxPsVwh"
}

The Event schema

KeyTypeDescription
event_idstringUnique Event ID generated by Aghanim.
game_idstringYour game ID in the Aghanim system.
event_typestringThe type of the event, order.canceled in this case.
event_timenumberEvent date in Unix epoch time.
event_dataEventDataContains the event-specific data, with possible keys for inherited objects.
idempotency_keystringEnsures webhook actions are executed only once, even if retried.
request_idstring|nullIf the event was triggered by an API request, the request ID is included.
sandboxbooleanIndicates whether the event was sent from the sandbox game environment.
triggerstring|nullThe trigger that caused the event to be sent.
transaction_idstringThe transaction ID generated by Aghanim. This ID may be the same for multiple events emitted within the same transaction.
contextEventContext|nullContextual information about the event.

The EventContext schema

KeyTypeDescription
orderOrderContext|nullOrder information associated with the event if applicable.
playerPlayerContext|null(Optional) Player information. To add this, enable "Add player context" in the webhook settings.

The EventData schema

KeyTypeDescription
idstringOrder ID generated by Aghanim.
company_idstringYour company ID in the Aghanim system.
game_idstringYour game ID in the Aghanim system.
user_idstringGame Hub user ID in the Aghanim system.
player_idstringThe unique Player ID chosen for player authentication.
statusstringOrder status. Can be: created,captured,paid,canceled,refunded,refund_requested.
amountnumberOrder amount in minor currency units.
currencystringOrder currency.
countrystringPayment method country.
created_atnumberOrder creation date in Unix epoch time.
modified_atnumberOrder modification date in Unix epoch time.
itemsItem[]Includes purchased item details.
feesFeesInformation about taxes and fees.
revenue_usdnumberThe expected net revenue, converted to USD cents using estimated foreign exchange rates and payment method fees. The final value is determined after reconciliation with payment providers, typically by the 10th of the following month.
metadataobject|nullThe metadata object structured as key-value pairs to store additional information about the order.
creatorCreator|nullInformation about creator associated with the order.

The Item schema

KeyTypeDescription
idstringItem ID generated by Aghanim.
namestringItem name.
descriptionstring|nullItem description.
skustringItem SKU matching on both the game and Aghanim sides.
quantitynumberItem quantity.
pricenumberItem price in minor currency units.
price_decimalnumberItem price in decimal units.
currencystringItem price currency.
typestringThe type of item. Possible values: item, bundle.
nested_itemsNestedItem[]|nullAn array of items included in the bundle.
fallback_itemItem|nullThe item that may be given as fallback if the main item can't be given to the player.

Item type bundle can contain several nested items inside.
You can handle the common sku of the bundle or handle each nested item individually.

The NestedItem schema

KeyTypeDescription
idstringItem ID generated by Aghanim.
namestringItem name.
descriptionstring|nullItem description.
skustringItem SKU matching on both the game and Aghanim sides.
quantitynumberItem quantity.
typestringThe type of item. Possible values: item, bundle.
nested_itemsNestedItem[]|nullAn array of items included in the bundle.

The PlayerContext schema

KeyTypeDescription
player_idstring|nullThe unique Player ID chosen for player authentication.
playerobject|nullPlayer ID components when using Composite Authorization.
attributesAttributesBasic player attributes expected by Aghanim.
custom_attributesCustomAttributesCustom player attributes.

The Creator schema

KeyTypeDescription
namestringName of the creator.
payout_decimal_usdnumberCreator payout amount in USD in major units.

Need help?
Contact our integration team at integration@aghanim.com