# 按购买项向用户发放商品 按购买项将指定商品添加到指定的用户物品库中。 注意: 一次只能处理50个操作。超出此限制的操作将被忽略。 Endpoint: POST /v2/project/{project_id}/inventory/purchase Version: 2.0.0 Security: basicAuth ## Path parameters: - `project_id` (integer, required) 项目ID。 ## Request fields (application/json): - `comment` (string) 操作说明。例如:“每月挑战奖励”。 - `custom_parameters` (object) 项目特定参数。 Example: {"array_param":[{"user_device_info":{"engine_version":"Unity 2020.2.0b5","os":"windows"},"user_public_id":{"nickname":"player1"}},{"user_device_info":{"engine_version":"UE 4.25","os":"mac"},"user_public_id":{"nickname":"player1"}}],"bool_param":true,"int_param":100,"null_param":null,"object_param":{"key":"value"}} - `items` (array, required) - `items.quantity` (number, required) 需要发放的此类商品数。 - `items.sku` (string, required) 商品类标识符。SKU只能包含小写英文字母、数字字符、句点、破折号和下划线。 - `platform` (string) 用户玩游戏的发布平台。 Enum: "playstation_network", "xbox_live", "xsolla", "pc_standalone", "nintendo_shop", "google_play", "app_store_ios", "android_standalone", "ios_standalone", "android_other", "ios_other", "pc_other" - `purchase` (object, required) - `purchase.amount` (string, required) 扣除任何减项前的购买金额。 - `purchase.currency` (string, required) 符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)格式的购买货币。 - `purchase.external_purchase_date` (string, required) 符合ISO 8601格式的购买日期。 - `purchase.external_purchase_id` (string, required) 来自购买平台的购买发票标识符。 - `user` (object, required) - `user.id` (string) 平台上的唯一用户标识符。 ## Response 200 fields (application/json): - `count` (integer) Example: 10 - `operations` (array) - `operations.amount` (string) 扣除任何减项前的购买金额。 Example: "2.99" - `operations.comment` (string) 操作说明。例如:“每月挑战奖励”。 Example: "Montly challange rewards" - `operations.currency` (string) 符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)格式的购买货币。 Example: "USD" - `operations.custom_parameters` (object) 项目特定参数。 Example: {"array_param":[{"user_device_info":{"engine_version":"Unity 2020.2.0b5","os":"windows"},"user_public_id":{"nickname":"player1"}},{"user_device_info":{"engine_version":"UE 4.25","os":"mac"},"user_public_id":{"nickname":"player1"}}],"bool_param":true,"int_param":100,"null_param":null,"object_param":{"key":"value"}} - `operations.external_purchase_date` (string) 符合ISO 8601格式的购买日期。 Example: "2020-01-01T05:00:00+05:00" - `operations.external_purchase_id` (string) 来自购买平台的购买发票标识符。 Example: "10-534-35" - `operations.items` (array) - `operations.items.quantity` (integer) 需要发放的此类商品数。 Example: 1 - `operations.items.sku` (string) 商品类标识符。SKU只能包含小写英文字母、数字字符、句点、破折号和下划线。 Example: "com.xsolla.item_1" - `operations.order_id` (number) 艾克索拉侧的操作说明。 Example: 123456 - `operations.platform` (string) 用户玩游戏的发布平台。 Enum: "playstation_network", "xbox_live", "xsolla", "pc_standalone", "nintendo_shop", "google_play", "app_store_ios", "android_standalone", "ios_standalone", "android_other", "ios_other", "pc_other" - `operations.user_id` (string) 平台上的唯一用户标识符。 Example: "d.user" ## Response 422 fields (application/json): - `errorCode` (integer) 错误代码。 Example: 1102 - `errorMessage` (string) 错误消息。 Example: "[0401-1102]: Unprocessable Entity. The property sku is required" - `statusCode` (integer) Example: 422