# 订单成功支付（包含付款和交易详情）

当用户订单支付成功时艾克索拉发送order_paid webhook到指定的URL。

order_paid webhook包含所购商品、付款数据和交易详细信息。

如果付款不成功，则不会发送order_paid webhook，例如：
* 打开了支付表单，但用户没有为订单付款
* 打开了支付表单，但付款过程中出现错误

建议order_paid webhook的处理时间小于3秒。


提示
Webhook中发送的字段取决于以下设置：您在帐户的设置 &gt; Webhook &gt; 高级设置部分中配置的选项艾克索拉侧配置的选项如有任何疑问，请联系您的客户成功经理，或发送邮件至csm@xsolla.com。


响应部分描述了预期的回答。您可以使用其他响应代码。根据响应码和自动退款功能的连接，艾克索拉侧的webhook处理逻辑如下：


    
    
        响应代码
        禁用了自动退款（默认）
        启用了自动退款
    
    
    
    
        400、401、402、403、404、409、422、415
        无操作
        自动退款给用户
    
    
        200、201、204
        无操作
        无操作
    
    
        不同代码或对webhook无响应
        在指定的时间间隔内发送多个webhook：2次间隔5分钟的尝试，7次间隔15分钟的尝试，10次间隔60分钟的尝试。
        在指定的时间间隔内发送多个webhook：2次间隔5分钟的尝试，7次间隔15分钟的尝试，10次间隔60分钟的尝试。如果发送了所有webhook后仍未收到成功响应，则会向用户自动退款。
    
    


要连接自动退款功能，请联系您的客户成功经理或发送电子邮件至csm@xsolla.com。

Endpoint: POST successful-order-payment
Version: 1.0

## Request fields (application/json):

  - `billing` (object)
    交易和付款详细信息。

  - `billing.notification_type` (string, required)
    通知类型。

  - `billing.payment_details` (object, required)
    带有支付详细信息的对象。

  - `billing.payment_details.country_wht` (object)
    对象，包含因跨境交易而在具体国家/地区产生的预扣费用数据。

  - `billing.payment_details.country_wht.amount` (number)
    金额。

  - `billing.payment_details.country_wht.currency` (string)
    货币。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)的三字母货币代码。

  - `billing.payment_details.country_wht.percent` (number)
    预扣费用费率百分比。

  - `billing.payment_details.direct_wht` (object)
    直接预扣税。

  - `billing.payment_details.direct_wht.amount` (number)
    金额。

  - `billing.payment_details.direct_wht.currency` (string)
    货币。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)的三字母货币代码。

  - `billing.payment_details.direct_wht.percent` (number)
    直接预扣税税率。

  - `billing.payment_details.payment` (object)
    带有用户支付相关数据的对象。

  - `billing.payment_details.payment.amount` (number)
    金额。

  - `billing.payment_details.payment.currency` (string)
    货币。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)的三字母货币代码。

  - `billing.payment_details.payment_method_fee` (object)
    支付系统佣金的大小。

  - `billing.payment_details.payment_method_fee.amount` (number)
    金额。

  - `billing.payment_details.payment_method_fee.currency` (string)
    货币。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)的三字母货币代码。

  - `billing.payment_details.payment_method_sum` (object)
    带有通过支付方式收费的金额相关数据的对象。

  - `billing.payment_details.payment_method_sum.amount` (number)
    金额。

  - `billing.payment_details.payment_method_sum.currency` (string)
    货币。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)的三字母货币代码。

  - `billing.payment_details.payout` (object)
    带有支出详细信息的对象。

  - `billing.payment_details.payout.amount` (number)
    金额。

  - `billing.payment_details.payout.currency` (string)
    货币。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)的三字母货币代码。

  - `billing.payment_details.payout_currency_rate` (string)
    从支付币种到支出币种的汇率。

  - `billing.payment_details.repatriation_commission` (object)
    包含汇回本国费用数据的对象，该费用是第三方对艾克索拉收取的费用。

  - `billing.payment_details.repatriation_commission.amount` (number)
    金额。

  - `billing.payment_details.repatriation_commission.currency` (string)
    货币。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)的三字母货币代码。

  - `billing.payment_details.sales_tax` (object)
    销售税（对象；仅适用于美国和加拿大）。

  - `billing.payment_details.sales_tax.amount` (number)
    金额。

  - `billing.payment_details.sales_tax.currency` (string)
    货币。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)的三字母货币代码。

  - `billing.payment_details.sales_tax.percent` (number)
    销售税税率。

  - `billing.payment_details.user_acquisition_fee` (object)
    从通过联盟网络和圈内达人完成的购买中扣除的用户获取费用总额（对象）。

  - `billing.payment_details.user_acquisition_fee.amount` (number)
    金额。

  - `billing.payment_details.user_acquisition_fee.currency` (string)
    货币。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)的三字母货币代码。

  - `billing.payment_details.user_acquisition_fee.percent` (number)
    用户获取费费率(%)。

  - `billing.payment_details.vat` (object)
    增值税大小（仅适用于欧盟）。

  - `billing.payment_details.vat.amount` (number)
    金额。

  - `billing.payment_details.vat.currency` (string)
    货币。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)的三字母货币代码。

  - `billing.payment_details.vat.percent` (number)
    VAT税率。

  - `billing.payment_details.xsolla_balance_sum` (object)
    计入艾克索拉余额的金额。

  - `billing.payment_details.xsolla_balance_sum.amount` (number)
    金额。

  - `billing.payment_details.xsolla_balance_sum.currency` (string)
    货币。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)的三字母货币代码。

  - `billing.payment_details.xsolla_fee` (object)
    艾克索拉费用（对象）。

  - `billing.payment_details.xsolla_fee.amount` (number)
    金额。

  - `billing.payment_details.xsolla_fee.currency` (string)
    货币。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)的三字母货币代码。

  - `billing.purchase` (object)
    带有购买相关数据的对象。

  - `billing.purchase.coupon` (object)
    带有优惠券相关数据的对象（如果此交易使用了优惠券）。

  - `billing.purchase.coupon.campaign_code` (string)
    优惠券营销活动的代码。

  - `billing.purchase.coupon.coupon_code` (string)
    优惠券代码。

  - `billing.purchase.gift` (object)
    礼物详情（对象）。

  - `billing.purchase.gift.giver_id` (string)
    送礼人ID。

  - `billing.purchase.gift.hide_giver_from_receiver` (string)
    是否对收礼人隐藏送礼人的身份信息。

  - `billing.purchase.gift.message` (string)
    送礼人留言。

  - `billing.purchase.gift.receiver_email` (string)
    收礼人邮箱。

  - `billing.purchase.gift.receiver_id` (string)
    收礼人ID。

  - `billing.purchase.promotions` (array)
    应用于此交易的促销活动。

  - `billing.purchase.promotions.id` (integer)
    促销活动 ID。

  - `billing.purchase.promotions.technical_name` (string)
    促销活动的技术名称。

  - `billing.purchase.subscription` (object)
    订阅详情（对象）。

  - `billing.purchase.subscription.amount` (number)
    以实际货币表示的价格。

  - `billing.purchase.subscription.currency` (string)
    货币。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)的三字母货币代码。

  - `billing.purchase.subscription.date_create` (string)
    订阅的创建日期。符合 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)标准规定的日期与时间。

  - `billing.purchase.subscription.date_next_charge` (string)
    下次收费的日期。符合[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)标准规定的日期与时间。

  - `billing.purchase.subscription.plan_id` (string)
    计划ID（如果计划通过API创建，则为外部ID）。

  - `billing.purchase.subscription.product_id` (string)
    产品ID（如果在访问令牌中发送）。

  - `billing.purchase.subscription.subscription_id` (integer)
    艾克索拉数据库的订阅ID。

  - `billing.purchase.subscription.tags` (array)
    计划标签。

  - `billing.purchase.total` (object, required)
    带有总购买价格相关数据的对象。

  - `billing.purchase.total.amount` (number)
    总购买金额。

  - `billing.purchase.total.currency` (string)
    货币。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)的三字母货币代码。

  - `billing.settings` (object)
    带有自定义项目设置的对象。

  - `billing.settings.merchant_id` (integer)
    商户ID。

  - `billing.settings.project_id` (integer)
    项目ID。您可以在[帐户](/zh/webhooks/overview/#business-accounts)中项目名称旁找到该参数。

  - `billing.transaction` (object, required)
    交易ID。

  - `billing.transaction.agreement` (integer)
    协议ID。

  - `billing.transaction.dry_run` (integer)
    测试交易。如为测试交易，该参数的值为1；如为真实交易，则不会发送该参数。

  - `billing.transaction.external_id` (string)
    交易外部ID。详细信息请参阅[常见问答](/zh/doc/pay-station/references/faq/#faq_payments_q_new_transaction_external_id)。

  - `billing.transaction.id` (integer)
    交易ID。

  - `billing.transaction.payment_date` (string)
    付款日期。

  - `billing.transaction.payment_method` (integer)
    付款方式ID。

  - `billing.transaction.payment_method_name` (string)
    付款方式名称。

  - `billing.transaction.payment_method_order_id` (string)
    支付系统中的付款ID。

  - `custom_parameters` (object)
    附加信息。

  - `items` (array, required)
    用户所购商品的列表。

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](/zh/api/catalog/common-webhooks/update-webhook-version/) API call.

  - `notification_type` (string, required)
    通知类型。

  - `order` (object, required)
    订单信息。

  - `order.amount` (string, required)
    基于所选货币的购物车总价。

  - `order.comment` (string,null, required)
    用户对订单的备注。

  - `order.coupons` (array)
    应用的优惠券。如未应用优惠券，则不会返回该数组。

  - `order.coupons.code` (string)
    应用的优惠券的券码。

  - `order.coupons.external_id` (string)
    外部ID。

  - `order.currency` (string, required)
    订单货币。虚拟货币使用SKU，真实货币使用三个字母的[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)代码。

  - `order.currency_type` (string, required)
    支付货币类型。对于免费订单，则值指定为unknown。
    Enum: "real", "virtual", "unknown", "loyalty_point"

  - `order.id` (integer, required)
    艾克索拉侧用户订单的唯一标识符。

  - `order.invoice_id` (string,null, required)
    实际货币付款发票ID。虚拟货币付款或免费商品的值为null。

  - `order.mode` (string, required)
    付款模式。对于真实支付，使用default；对于测试性支付，使用sandbox。
    Enum: "default", "sandbox"

  - `order.platform` (string,null, required)
    支付平台。 xsolla值用于通过艾克索拉进行的支付。其他支付使用与游戏发布平台名称对应的值。
    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.promocodes` (array)
    应用的促销码。如未应用促销码，则不会返回该数组。

  - `order.promocodes.code` (string)
    应用的促销码的代码。

  - `order.promocodes.external_id` (string)
    外部ID。

  - `order.promotions` (array, required)
    对整个订单应用促销活动。
在下列情况下返回该数组：
  - 促销活动会影响总订单金额，例如具有对购买项提供折扣设置的促代码。
  - 购买时不享受折扣，但订单中会添加赠品。在这种情况下，由于未应用折扣，将返回含折扣的价格([amount_with_discount](/zh/webhooks/#operation/order-cancellation!path=order/promotions/amount_with_discount&t=request))和不含折扣的价格值([amount_without_discount](/zh/webhooks/#operation/order-cancellation!path=order/promotions/amount_without_discount&t=request))且两个值相同。

如果未应用任何订单级促销活动，将返回一个空数组。

  - `order.promotions.amount_with_discount` (string)
    应用折扣后商品总价。

  - `order.promotions.amount_without_discount` (string)
    不应用折扣的商品总价。

  - `order.promotions.sequence` (integer)
    应用促销活动的顺序。

  - `order.status` (string, required)
    订单状态。

  - `user` (object, required)
    用户信息。

  - `user.country` (string)
    用户所在国家/地区。使用[ISO 3166-1 alpha-2 标准](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)规定的2字母组合表示国家/地区。

  - `user.email` (string, required)
    用户邮箱地址。

  - `user.external_id` (string, required)
    用户ID。


## Response 200 fields

## Response 400 fields
