# Order cancellation (with payment and transaction details)

Xsolla sends the order_canceled webhook to the specified URL when the payment is canceled by the user, partner, or automatically. The webhook contains information about returned items, payment data and details of the canceled order.

The webhook is not sent if the payment is not successful, for example:
* the payment UI was opened but the user did not pay for the order
* the payment UI was opened but there were errors during the payment

The recommended webhook processing time is within 3 seconds.

Endpoint: POST order-cancellation
Version: 1.0

## Request fields (application/json):

  - `notification_type` (string, required)
    Notification type.

  - `items` (array, required)
    List of items purchased by the user.

The set of parameters included in the array depends on the webhook version. Version 2 includes additional parameters: is_free, is_bonus, and is_bundle_content. To switch the version, pass its number in the version parameter in the [Update webhook version](/api/catalog/common-webhooks/update-webhook-version/) API call.

  - `order` (object, required)
    Information about the order.

  - `order.id` (integer, required)
    Unique identifier of the user's order on the Xsolla’s side.

  - `order.mode` (string, required)
    Payment mode. default is used for real payments; sandbox for test payments.
    Enum: "default", "sandbox"

  - `order.currency_type` (string, required)
    Payment currency type. For a free order, unknown value is specified.
    Enum: "real", "virtual", "unknown", "loyalty_point"

  - `order.currency` (string, required)
    Currency of order. Virtual currency uses the SKU and real currency uses a three-letter [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code.

  - `order.amount` (string, required)
    The total cost of a cart based on the chosen currency.

  - `order.status` (string, required)
    Order status.

  - `order.platform` (string,null, required)
    Payment platform. The xsolla value is used for payments via Xsolla. For other payments, the value corresponding to the name of the game publishing platform is used: playstation_network, xbox_live, pc_standalone, nintendo_shop, google_play, app_store_ios, android_standalone, ios_standalone, android_other, ios_other, pc_other.
    Enum: "xsolla", "playstation_network", "xbox_live", "pc_standalone", "nintendo_shop", "google_play", "app_store_ios", "android_standalone", "ios_standalone", "android_other", "ios_other", "pc_other"

  - `order.comment` (string,null, required)
    User’s commentary to the order.

  - `order.invoice_id` (string,null, required)
    Real currency payments invoice ID. Virtual currency payments or free items have a null value.

  - `order.promotions` (array, required)
    Applied promotions for the entire order.
The array is returned in the following cases:
  - A promotion affects the total purchase amount, such as a promo code with the Discount on purchase setting.
  - No discount is applied to the purchase, but bonus items are added to the order. In this case, the values for the cost with discount ([amount_with_discount](/webhooks/#operation/order-cancellation!path=order/promotions/amount_with_discount&t=request)) and without discount ([amount_without_discount](/webhooks/#operation/order-cancellation!path=order/promotions/amount_without_discount&t=request)) are returned and identical, since no discount is applied.

If no order-level promotions are applied, an empty array is returned.

  - `order.promotions.amount_without_discount` (string)
    Total cost of items without a discount.

  - `order.promotions.amount_with_discount` (string)
    Total cost of items with a discount.

  - `order.promotions.sequence` (integer)
    Order of promotions application.

  - `order.coupons` (array)
    Applied coupons. If the coupon isn’t applied, the array doesn’t return.

  - `order.coupons.code` (string)
    The code of an applied coupon.

  - `order.coupons.external_id` (string)
    External ID.

  - `order.promocodes` (array)
    Applied promocodes. If the promocode isn’t applied, the array doesn’t return.

  - `order.promocodes.code` (string)
    The code of an applied promocode.

  - `order.promocodes.external_id` (string)
    External ID.

  - `user` (object, required)
    User information.

  - `user.external_id` (string, required)
    User ID.

  - `user.email` (string, required)
    User email address.

  - `user.country` (string)
    User’s country. Two-letter uppercase [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code.

  - `billing` (object)
    Transaction and payment details.

  - `billing.notification_type` (string, required)
    Notification type.

  - `billing.settings` (object)
    Custom project settings (object).

  - `billing.settings.project_id` (integer)
    Project ID. You can find this parameter in your [Publisher Account](https://publisher.xsolla.com/) next to the name of the project.

  - `billing.settings.merchant_id` (integer)
    Merchant ID.

  - `billing.purchase` (object)
    Purchase details (object).

  - `billing.purchase.subscription` (object)
    Subscription details (object).

  - `billing.purchase.subscription.plan_id` (string)
    Plan ID (external if the plan was created via API).

  - `billing.purchase.subscription.subscription_id` (integer)
    Subscription ID in Xsolla database.

  - `billing.purchase.subscription.tags` (array)
    Plan tags.

  - `billing.purchase.subscription.date_create` (string)
    Subscription creation date. Date and time per [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601).

  - `billing.purchase.subscription.currency` (string)
    Currency. Three-letter currency code per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).

  - `billing.purchase.subscription.amount` (number)
    Price in real currency.

  - `billing.purchase.total` (object, required)
    Total price of purchase (object).

  - `billing.purchase.total.currency` (string)
    Currency. Three-letter currency code per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).

  - `billing.purchase.total.amount` (number)
    Total payment amount.

  - `billing.transaction` (object, required)
    Transaction details (object).

  - `billing.transaction.id` (integer)
    Transaction ID.

  - `billing.transaction.external_id` (string)
    Transaction external ID.

  - `billing.transaction.payment_method_order_id` (string)
    Payment ID in the payment system.

  - `billing.transaction.dry_run` (integer)
    Test transaction. The parameter has the 1 value if it is a test transaction, or is not sent if the transaction is real.

  - `billing.transaction.agreement` (integer)
    Agreement ID.

  - `billing.refund_details` (object)
    Refund details (object).

  - `billing.refund_details.code` (integer)
    Code ID.

  - `billing.refund_details.reason` (string)
    Refund reason.

  - `billing.refund_details.author` (string)
    Refund initiator. The field value is passed according to the table:


    
    
        Refund initiator
        Field value
    
    
    
    
        Game (via API).
        API
    
    
        Publisher Account user (automatic refund).
        User email
    
    
        Publisher Account user (with assistance from Xsolla customer support).
        support@xsolla.com
    
    
        Xsolla (with assistance from Xsolla customer support).
        support@xsolla.com

  - `billing.payment_details` (object, required)
    Payment details (object).

  - `billing.payment_details.payment` (object)
    Amount paid by the user (object).

  - `billing.payment_details.payment.currency` (string)
    Currency. Three-letter currency code per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).

  - `billing.payment_details.payment.amount` (number)
    Amount.

  - `billing.payment_details.payment_method_sum` (object)
    Amount debited from the payment system.

  - `billing.payment_details.payment_method_sum.currency` (string)
    Currency. Three-letter currency code per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).

  - `billing.payment_details.payment_method_sum.amount` (number)
    Amount.

  - `billing.payment_details.xsolla_balance_sum` (object)
    Amount debited from Xsolla balance.

  - `billing.payment_details.xsolla_balance_sum.currency` (string)
    Currency. Three-letter currency code per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).

  - `billing.payment_details.xsolla_balance_sum.amount` (number)
    Amount.

  - `billing.payment_details.payout` (object)
    Payout details (object).

  - `billing.payment_details.payout.currency` (string)
    Currency. Three-letter currency code per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).

  - `billing.payment_details.payout.amount` (number)
    Amount.

  - `billing.payment_details.vat` (object)
    VAT details (object; EU only).

  - `billing.payment_details.vat.currency` (string)
    Currency. Three-letter currency code per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).

  - `billing.payment_details.vat.amount` (number)
    Amount.

  - `billing.payment_details.vat.percent` (number)
    VAT rate.

  - `billing.payment_details.payout_currency_rate` (string)
    Exchange rate between payment and payout currencies.

  - `billing.payment_details.country_wht` (object)
    Object with data on withholding costs applied in specific countries due to cross-border transactions.

  - `billing.payment_details.country_wht.currency` (string)
    Currency. Three-letter currency code per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).

  - `billing.payment_details.country_wht.amount` (number)
    Amount.

  - `billing.payment_details.country_wht.percent` (number)
    Percent of the withholding cost rate.

  - `billing.payment_details.user_acquisition_fee` (object)
    Total amount of user acquisition fees deducted for the purchases made via affiliate networks and influencers (object).

  - `billing.payment_details.user_acquisition_fee.currency` (string)
    Currency. Three-letter currency code per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).

  - `billing.payment_details.user_acquisition_fee.amount` (number)
    Amount.

  - `billing.payment_details.user_acquisition_fee.percent` (number)
    User acquisition fee rate, %.

  - `billing.payment_details.xsolla_fee` (object)
    Xsolla fee (object).

  - `billing.payment_details.xsolla_fee.currency` (string)
    Currency. Three-letter currency code per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).

  - `billing.payment_details.xsolla_fee.amount` (number)
    Amount.

  - `billing.payment_details.payment_method_fee` (object)
    Payment system fee.

  - `billing.payment_details.payment_method_fee.currency` (string)
    Currency. Three-letter currency code per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).

  - `billing.payment_details.payment_method_fee.amount` (number)
    Amount.

  - `billing.payment_details.sales_tax` (object)
    Sales tax (object; USA and Canada only).

  - `billing.payment_details.sales_tax.currency` (string)
    Currency. Three-letter currency code per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).

  - `billing.payment_details.sales_tax.amount` (number)
    Amount.

  - `billing.payment_details.sales_tax.percent` (number)
    Sales tax rate.

  - `billing.payment_details.direct_wht` (object)
    Direct withholding tax.

  - `billing.payment_details.direct_wht.currency` (string)
    Currency. Three-letter currency code per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).

  - `billing.payment_details.direct_wht.amount` (number)
    Amount.

  - `billing.payment_details.direct_wht.percent` (number)
    Direct withholding tax rate.

  - `billing.payment_details.repatriation_commission` (object)
    Object with data on repatriation costs, imposed on Xsolla by third parties.

  - `billing.payment_details.repatriation_commission.currency` (string)
    Currency. Three-letter currency code per [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).

  - `billing.payment_details.repatriation_commission.amount` (number)
    Amount.

  - `custom_parameters` (object)
    Additional information.


## Response 200 fields

## Response 400 fields
