Xsolla-logo
  • 文档
  • 创建帐户

订单支付成功Webhook POST

当满足以下条件时,艾克索拉将order_paid webhook发送到指定的 URL:

  1. 用户成功支付订单。
  2. 艾克索拉收到成功处理payment webhook的响应。

order_paid webhook包含所购商品和交易详细信息。

如果出现以下情况,将不会发送order_paid webhook:

  • 支付不成功,例如:
    • 打开了支付表单,但用户没有为订单付款
    • 打开了支付表单,但付款过程中出现错误
  • 尚未收到成功处理payment webhook的响应。

建议order_paid webhook的处理速度小于3秒。

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

响应代码 禁用了自动付款退回(默认) 启用了自动付款退回
400401402403404409422415 无操作 自动退款给用户
200201204 无操作 无操作
不同代码或对webhook无响应 在指定的时间间隔内发送多个webhook:2次间隔5分钟的尝试,7次间隔15分钟的尝试,10次间隔60分钟的尝试。 在指定的时间间隔内发送多个webhook:2次间隔5分钟的尝试,7次间隔15分钟的尝试,10次间隔60分钟的尝试。如果发送了所有webhook后仍未收到成功响应,则会向用户自动退款。

如需连接自动退款功能,请联系项目的帐户经理或发送邮件至am@xsolla.com

Request
Request Body schema: application/json
notification_type
required
string

通知类型。

required
Array of objects

用户所购商品的列表。

Array
sku
required
string

项目的唯一ID。对于game_key类型的商品,使用sku_drm格式的值。

type
required
string

商品类型。它可以具有以下值:virtual_goodvirtual_currencygame_keybundle。对于bundle类型的商品(包括虚拟货币套餐),商品数组将显示:

  • 捆绑包或虚拟货币套餐的参数
  • 捆绑包中包含的商品或套餐中包含的货币
Enum: "virtual_good" "virtual_currency" "game_key" "bundle"
quantity
required
integer

商品数量。

amount
required
string

基于数量的商品总价。如果汇率和佣金有变,则可能与商品价格不一致。

required
Array of objects

应用促销。如果未应用促销,则会在参数中传递一个空数组。

Array
amount_with_discount
string

应用折扣后商品总价。

amount_without_discount
string

不应用折扣的商品总价。

sequence
integer

应用促销活动的顺序。

is_pre_order
required
boolean

如果为true,则该商品为预订商品。

is_free
required
boolean

如果为true,则该商品免费或属于某个捆绑包。

is_bonus
required
boolean

如果为true,则该商品为奖励。

is_bundle_content
required
boolean

如果为true,则该商品属于某个捆绑包。

custom_attributes
object <json>

包含商品属性和值的JSON对象。

required
object

订单信息。

id
required
integer

艾克索拉侧用户订单的唯一标识符。

mode
required
string

付款模式。对于真实支付,使用default;对于测试性支付,使用sandbox

Enum: "default" "sandbox"
currency_type
required
string

支付货币类型。对于免费订单,则值指定为unknown

Enum: Description
real

对于真实货币

unknown

对于免费订单

virtual

对于虚拟货币

currency
required
string

订单货币。虚拟货币使用SKU,真实货币使用三个字母的ISO 4217代码。

amount
required
string

基于所选货币的购物车总价。

status
required
string

订单状态。

platform
required
string or null

支付平台。 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"
comment
required
string or null

用户对订单的备注。

invoice_id
required
string or null

实际货币付款发票ID。虚拟货币付款或免费商品的值为null

required
Array of objects

应用促销。如果未应用促销,则会在参数中传递一个空数组。

Array
amount_with_discount
string

应用折扣后商品总价。

amount_without_discount
string

不应用折扣的商品总价。

sequence
integer

应用促销活动的顺序。

Array of objects

应用的优惠券。如未应用优惠券,则不会返回该数组。

Array
code
string

应用的优惠券的券码。

external_id
string

外部ID。

Array of objects

应用的促销码。如未应用促销码,则不会返回该数组。

Array
code
string

应用的促销码的代码。

external_id
string

外部ID。

required
object

用户信息。

external_id
required
string

用户ID。

email
required
string

用户邮箱地址。

custom_parameters
object

附加信息。

Responses
200

返回以指示处理成功。

400

提供的信息出错时返回(例如,缺少必需的参数、授权失败等)。

Request samples
curl -v 'https://your.hostname/your/uri' \
-X POST \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Signature d09695066c52c1b8bdae92f2d6eb59f5b5f89843' \
-d '{
    "notification_type": "order_paid",
    "items": [
      {
        "sku": "virtual-good-item_test",
        "type": "virtual_good",
        "is_pre_order": false,
        "quantity": 3,
        "amount": "1000",
        "promotions": [
          {
            "amount_without_discount": "6000",
            "amount_with_discount": "5000",
            "sequence": 1
          },
          {
            "amount_without_discount": "5000",
            "amount_with_discount": "4000",
            "sequence": 2
          }
        ]
        "custom_attributes":
          {
            "purchased": 0,
            "attr": "value"
          },
        "is_free": false,
        "is_bonus": false,
        "is_bundle_content": false
      },
      {
        "sku": "virtual-good-item_test_test_new",
        "type": "bundle",
        "is_pre_order": false,
        "quantity": 1,
        "amount": "1000",
        "promotions": [],
        "is_free": false,
        "is_bonus": false,
        "is_bundle_content": false
      },
      {
        "sku": "gold",
        "type": "virtual_currency",
        "is_pre_order": false,
        "quantity": 1500,
        "amount": "[null]",
        "promotions": [],
        "is_free": true,
        "is_bonus": false,
        "is_bundle_content": true
      }
    ],
    "order": {
      "id": 1,
      "mode": "default",
      "currency_type": "virtual",
      "currency": "sku_currency",
      "amount": "2000",
      "status": "paid",
      "platform": "xsolla",
      "comment": null,
      "invoice_id": "1",
      "promotions": [
        {
          "amount_without_discount": "4000",
          "amount_with_discount": "2000",
          "sequence": 1
        }
      ],
      "promocodes": [
        {
          "code": "promocode_some_code",
          "external_id": "promocode_sku"
        }
      ],
      "coupons": [
        {
          "code": "WINTER2021",
          "external_id": "coupon_sku"
        }
      ]
    },
    "user": {
      "external_id": "id_xsolla_login_1",
      "email": "gc_user@xsolla.com"
    }

}'