# 为购买创建支付令牌 为其生成订单和支付令牌。订单根据请求正文中传递的商品生成。 要在新窗口中打开支付UI,请使用以下链接:https://secure.xsolla.com/paystation4/?token={token},其中{token}是收到的令牌。 如仅进行测试,请使用此URL:https://sandbox-secure.xsolla.com/paystation4/?token={token}。 注意 user.country.value参数用于选择订单的货币。如果用户的国家/地区未知, 请在X-User-Ip头中提供用户的IP作为替代方案。必须至少提供两者中的一个此方法才能正常工作。所选货币用于支付中心中的付款方式。 Endpoint: POST /v3/project/{project_id}/admin/payment/token Version: 2.0.0 Security: basicAuth ## Path parameters: - `project_id` (integer, required) 项目ID。您可以在您的发布商帐户项目名称旁边找到。 Example: 44056 ## Request fields (application/json): - `custom_parameters` (object,null) 自定义参数的形式是一组有效的JSON键值对。 您可以通过此字段传入补充参数来配置反欺诈筛选条件。 [请参阅支付中心文档](https://developers.xsolla.com/zh/doc/pay-station/features/antifraud/)。 Example: {"custom_parameters":{"bool_param":true,"int_param":100,"null_param":null,"string_param":"example"}} - `promo_code` (string) 区分大小写的唯一券码。包含字母和数字。 Example: "WINTER2021" - `purchase` (object, required) - `purchase.items` (array, required) - `purchase.items.quantity` (number, required) 商品的数量。 Example: 2 - `purchase.items.sku` (string, required) 唯一商品ID。 SKU只能包含大小写英文字母和数字字符、句点、破折号和下划线。 Example: "t-shirt" - `sandbox` (boolean) 设置为true以测试付款流程。在这种情况下,请使用https://sandbox-secure.xsolla.com访问测试支付UI。 - `settings` (object) 为用户配置支付流程和支付UI的设置。 - `settings.currency` (string) 首选购买货币。[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)标准下的三个字母的货币代码。请查看文档详细了解[艾克索拉支持的货币](https://developers.xsolla.com/zh/doc/pay-station/references/supported-currencies/)。 - `settings.external_id` (string) 交易外部ID。 - `settings.language` (string) 界面语言。2字母(小写字母)[语言代码](https://developers.xsolla.com/zh/doc/pay-station/features/localization/)。 - `settings.payment_method` (integer) 支付方式ID,它决定支付界面显示的货币,因为有些支付方式可能只支持某些特定的货币。 - `settings.redirect_policy` (object) - `settings.redirect_policy.delay` (integer) 经过指定延迟时间后自动将用户重定向到返回URL。 - `settings.redirect_policy.redirect_button_caption` (string) 本地化的重定向按钮文字。 Example: "Text button" - `settings.redirect_policy.redirect_conditions` (string) 触发将用户重定向到返回URL的支付状态。 Enum: "none", "successful", "successful_or_canceled", "any" - `settings.redirect_policy.status_for_manual_redirection` (string) 触发显示重定向按钮的支付状态,用户单击该按钮后将被重定向到返回URL。 Enum: "none", "vc", "successful", "successful_or_canceled", "any" - `settings.return_url` (string) 用户会在支付过后被重定向到此页面。参数user_id、foreigninvoice、invoice_id和status会被自动添加到此链接。 - `settings.ui` (object) 界面设置。 - `settings.ui.currency_format` (string) 设置为code以在支付UI中显示三字母的[ISO 4217](https://developers.xsolla.com/zh/doc/pay-station/references/supported-currencies/)货币代码。默认显示货币符号而不是三字母货币代码。 - `settings.ui.desktop` (object) 桌面版本的界面设置。 - `settings.ui.desktop.header` (object) 页眉设置。 - `settings.ui.desktop.header.close_button` (boolean) 是否在桌面支付UI中显示关闭按钮。该按钮将关闭支付UI并将用户重定向到settings.return_url参数中指定的URL。默认为false。 - `settings.ui.desktop.header.is_visible` (boolean) 页眉在支付UI上是否可见。 - `settings.ui.desktop.header.type` (string) 如何显示页眉。不能为compact(隐藏项目名称和用户ID)或normal(默认)。 Enum: "compact", "normal" - `settings.ui.desktop.header.visible_logo` (boolean) 如果true,徽标将显示在标题中。要上传图像,请在[发布者帐户](https://publisher.xsolla.com/)然后转到付款站 > 设置部分。 - `settings.ui.desktop.header.visible_name` (boolean) 页眉中是否显示项目名称。 - `settings.ui.desktop.header.visible_purchase` (boolean) 是否在页眉中显示购买描述(purchase.description.value)。默认为true。 - `settings.ui.header` (object) - `settings.ui.header.visible_virtual_currency_balance` (boolean) 此元素是否可在支付UI上隐藏。 - `settings.ui.is_cart_open_by_default` (boolean) 打开支付UI移动版本时购物车商品列表的显示方式。如为true,列表以扩展视图显示。如为false(默认)或未传入此参数,列表以折叠视图显示。 - `settings.ui.is_independent_windows` (boolean) 是否将用户从嵌入式启动器浏览器(WebView)跳转到其默认的浏览器来进行购买。 - `settings.ui.is_payment_methods_list_mode` (boolean) 打开支付UI时是否显示在该用户所在国家/地区可用的支付方式。如为false(默认),将显示在settings.payment_method参数中传入的支付方式或[PayRank算法](https://developers.xsolla.com/zh/solutions/payments/payment-ui-management/top-payment-methods-management/)选择的支付方式。 - `settings.ui.is_prevent_external_link_open` (boolean) 是否禁用将链接重定向至外部资源。点击外部链接时,将通过postMessage机制发送external-link-open事件。重定向链接的地址在url参数中传递。 - `settings.ui.is_show_close_widget_warning` (boolean) 关闭支付页面前鼠标悬停在×图标时是否显示交易正在处理中的警告。如传入false,或未传入参数,则不显示警告。 - `settings.ui.is_three_ds_independent_windows` (boolean) 是否在新浏览器窗口中打开3-D Secure检查。如果您的设置强制执行内容安全政策(CSP),请设置为true。 - `settings.ui.layout` (string) 支付UI主要元素的位置。您可以在游戏内打开支付UI和/或交换订单信息和支付方式信息列的位置。详细信息请参阅[自定义说明](https://developers.xsolla.com/zh/doc/pay-station/features/ui-theme-customization/#pay_station_ui_theme_customization_layout)。 Enum: "embed", "column_reverse", "embed_column_reverse" - `settings.ui.mobile` (object) - `settings.ui.mode` (string) 支付UI的界面模式。只能是user_account。请注意,页眉仅包含用户帐户的导航菜单,而没有用于选择产品或进行付款的任何选项。“用户帐户”仅在桌面模式下可用。 Enum: "user_account" - `settings.ui.theme` (string) 支付UI主题。可以是63295a9a2e47fab76f7708e1(浅色主题(默认)),或63295aab2e47fab76f7708e3(深色主题)。您也可以[创建自定义主题](https://developers.xsolla.com/zh/doc/pay-station/features/ui-theme-customization/#pay_station_ui_theme_customization_in_token),然后在此参数中传入其ID。 Enum: "63295a9a2e47fab76f7708e1", "63295aab2e47fab76f7708e3" - `settings.ui.user_account` (object) 用户帐户详细信息。 - `settings.ui.user_account.info` (object) 我的账户页面。 - `settings.ui.user_account.info.enable` (boolean, required) 是否显示子菜单。默认为false。 - `settings.ui.user_account.info.order` (integer, required) 子菜单在菜单中的位置。 - `settings.ui.user_account.payment_accounts` (object) 我的支付帐户子菜单。 - `settings.ui.user_account.subscriptions` (object) 管理订阅子菜单。 - `user` (object, required) - `user.age` (integer) 用户年龄。 - `user.country` (object) - `user.country.allow_modify` (boolean) 用户是否可以在支付UI中更改国家/地区。 - `user.country.value` (string) [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)标准下的两个大写字母的国家/地区代码。如未在X-User-Ip头中传入IP地址,则此属性为必需。请查看文档详细了解[艾克索拉支持的国家/地区](https://developers.xsolla.com/zh/zh/doc/shop-builder/references/supported-countries/)。示例:country=US Example: "US" - `user.email` (object) - `user.email.value` (string) 用户邮箱。必须符合RFC 822协议。 - `user.id` (object, required) - `user.id.value` (string) 用户身份。对于测试,您可以传递任意。如要接受真实付款,需使用您系统中的用户ID值。该ID在[用户验证](https://developers.xsolla.com/zh/webhooks/operation/user-validation/)Webhook中传递。 - `user.is_legal` (boolean) 用户是否为法律实体。 - `user.legal` (object) 包含法律实体详细信息的对象。如果user.is_legal为true,则对象及其所有参数为必需。 - `user.legal.address` (string) 完整法定地址。 - `user.legal.country` (string) 公司所在国家/地区。参照[ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)标准的两个大写字母表示的国家/地区代码。 - `user.legal.name` (string) 完整法定名称。 - `user.legal.vat_id` (string) 个人纳税人识别号。 - `user.name` (object) - `user.name.value` (string) 用户昵称。 - `user.phone` (object) - `user.phone.allow_modify` (boolean) 用户是否可以在支付UI中更改手机号。如果令牌中传入了phone.value值,则值默认为false。 - `user.phone.hidden` (boolean) - `user.phone.value` (string, required) 用户手机号码。 - `user.steam_id` (object) - `user.steam_id.value` (string, required) Steam ID。 - `user.tracking_id` (object) - `user.tracking_id.value` (string, required) 唯一的跟踪ID(用于营销活动)。 ## Response 201 fields (application/json): - `order_id` (integer) 订单ID。 Example: 1 - `token` (string) 支付令牌。 ## Response 401 fields (application/json): - `errorCode` (integer) Example: 1020 - `errorMessage` (string) Example: "[0401-1020]: Error in Authentication method occurred" - `statusCode` (integer) Example: 401 ## Response 422 fields (application/json): - `errorCode` (number) 错误代码。 Example: 1102 - `errorMessage` (string) 可读的错误消息。 Example: "[0401-1102]: Unprocessable Entity. The property `external_id` is required" - `statusCode` (number) 响应状态码。 Example: 422 - `transactionId` (string) 请求的唯一ID。 Example: "da145238620011eb8e24fe6913ff226a"