# 创建令牌 您可以使用任意用户参数创建令牌。 您在获取令牌时发送这些参数,并在成功付款后接收它们。 令牌只能包含本文档中描述的或由您预定义的参数。 If任何参数以错误的格式发送或具有错误的类型,都不会发出令牌。 您将收到一个422HTTP代码,其中包含JSON正文中的错误描述。 在extended_message中,您将收到错误发送的确切参数的信息。 注意此API调用不包含project_id路径参数,因此您需要使用在您公司的所有项目中都有效的API密钥来设置授权。 Endpoint: POST /merchants/{merchant_id}/token Version: 2.0 Security: basicAuth ## Path parameters: - `merchant_id` (integer, required) 商户ID。 ## Request fields (application/json): - `custom_parameters` (object) 您可以在令牌的custom_parameters对象中传递其他参数以配置反欺诈筛选器。推荐参数在下拉列表中显示。[请参阅支付中心文档](https://developers.xsolla.com/zh/doc/pay-station/features/antifraud/)。 - `custom_parameters.active_date` (string) 上一次出现日期(按照[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)格式)。 - `custom_parameters.additional_verification` (boolean) 玩家是否使用了帐户验证流程。 - `custom_parameters.character_customized` (boolean) 玩家是否对角色进行了自定义。 - `custom_parameters.chat_activity` (boolean) 玩家是否使用了聊天功能。 - `custom_parameters.completed_tasks` (integer) 完成的任务/目标数。 - `custom_parameters.forum_activity` (boolean) 玩家是否使用了论坛功能。 - `custom_parameters.items_used` (boolean) 玩家是否使用了购买的游戏装备。 - `custom_parameters.karma_points` (integer) 玩家的贡献/业力。 - `custom_parameters.last_change_password_date` (string) 上一次出现日期(按照[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)格式)。 - `custom_parameters.non_premium_currency` (integer) 非高级货币数量。 - `custom_parameters.notifications_enabled` (boolean) 玩家是否启用了通知。 - `custom_parameters.profile_completed` (boolean) 玩家在帐户资料中是否添加了其它信息。 - `custom_parameters.profile_image_added` (boolean) 玩家是否上传了简介头像。 - `custom_parameters.pvp_activity` (boolean) 玩家是否参与了玩家对战。 - `custom_parameters.registration_date` (string) 上一次出现日期(按照[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)格式)。 - `custom_parameters.session_time` (string) 上一次出现日期(按照[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)格式)。 - `custom_parameters.social_networks_added` (boolean) 玩家是否有关联的社交媒体帐户资料。 - `custom_parameters.total_bans` (integer) 玩家在聊天/论坛中被禁言的次数。 - `custom_parameters.total_characters` (integer) 游戏角色数。 - `custom_parameters.total_clans` (integer) 玩家所属的家族数。 - `custom_parameters.total_friends` (integer) 好友数。 - `custom_parameters.total_game_events` (integer) 玩家参与的游戏事件数。 - `custom_parameters.total_gifts` (integer) 玩家发出/收到的游戏礼物数。 - `custom_parameters.total_hours` (integer) 游戏总时数。 - `custom_parameters.total_inventory_value` (integer) 库存总值(以游戏货币为单位)。 - `custom_parameters.total_sum` (integer) 付款总额。 - `custom_parameters.tutorial_completed` (boolean) 玩家是否完成了游戏教程。 - `custom_parameters.unlocked_achievements` (integer) 未解锁的通关数。 - `custom_parameters.user_level` (integer) 玩家的等级、口碑或排名。 - `custom_parameters.win_rate` (integer) 赢率。 - `purchase` (object) 带有购买相关数据的对象。 Example: {"checkout":{"amount":10,"currency":"USD"},"subscription":{"gift":{"email":"recipient_email@email.com","recipient":"test_recipient_v1"}}} - `purchase.checkout` (object) 带有结账参数相关数据的对象。 Example: {"amount":10,"currency":"USD"} - `purchase.checkout.amount` (integer) 购买金额。 Example: 10 - `purchase.checkout.currency` (string) 购买币种。参照[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)标准的三字母货币代码。 Example: "USD" - `purchase.subscription` (object) 带有订阅相关数据的对象。 Example: {"gift":{"email":"recipient_email@email.com","recipient":"test_recipient_v1"}} - `purchase.subscription.available_plans` (array) 包含订阅套餐相关数据的数组。只有这些套餐会显示在支付用户界面中。 - `purchase.subscription.currency` (string) 购买计划的货币,以此币种进行所有计算。 - `purchase.subscription.gift` (object) 赠礼订阅的详细信息。 Example: {"email":"recipient_email@email.com","recipient":"test_recipient_v1"} - `purchase.subscription.gift.anonymous` (boolean) 是否隐藏送礼人姓名。如为true,则在邮件通知中隐藏送礼人姓名。默认为false。 - `purchase.subscription.gift.email` (string, required) 接收人邮箱。 Example: "recipient_email@email.com" - `purchase.subscription.gift.message` (string) 给接收者的留言。 - `purchase.subscription.gift.recipient` (string, required) 接收者ID。 Example: "test_recipient_v1" - `purchase.subscription.gift.redirect_url` (string) 在此处提供包含赠礼订阅额外信息的页面链接或帐户创建页面的链接。收礼人可从订阅赠礼邮件通知中跳转到该页面。 - `purchase.subscription.operation` (string) 此操作的类型应用于用户订阅计划。要更改订阅计划,请传入change_plan值。需在purchase.subscription.plan_id参数中指定新计划的ID。 - `purchase.subscription.plan_id` (string) 订阅计划的外部ID。可在发布商帐户的订阅 > 订阅计划中找到。 - `purchase.subscription.product_id` (string) 产品ID。 - `purchase.subscription.trial_days` (integer) 试用期,以天为单位。 - `settings` (object) 自定义项目设置。 Example: {"currency":"USD","language":"en","project_id":16184,"ui":{"components":{"virtual_currency":{"custom_amount":true}},"desktop":{"virtual_item_list":{"button_with_price":true,"layout":"list"}},"size":"medium"}} - `settings.currency` (string) 首选支付币种。参照[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)标准的三字母货币代码。 Example: "USD" - `settings.external_id` (string) 游戏中的交易ID。值对于每个用户付款必须唯一。 - `settings.language` (string) 界面语言。2字母(小写字母)[语言代码](https://developers.xsolla.com/zh/doc/pay-station/features/localization/)。 Example: "en" - `settings.mode` (string) 设置为sandbox值以测试支付流程。请使用https://sandbox-secure.xsolla.com来访问测试支付UI。 - `settings.payment_method` (integer) 付款方式ID。 - `settings.payment_widget` (string) 支付小部件。可以是 paybycash 或 giftcard。如果参数已设置,用户将分别重定向到 Pay by Cash 或 Gift Cards 小部件。 Enum: "paybycash", "giftcard" - `settings.project_id` (integer, required) 游戏的艾克索拉ID。可以在发布商帐户中找到该ID。 Example: 16184 - `settings.redirect_policy` (object) 重定向政策设置(对象)。 - `settings.redirect_policy.autoredirect_from_status_page` (boolean) 从状态页面自动重定向。 - `settings.redirect_policy.delay` (integer) 延迟时间(单位为秒),经过该时间后用户将自动重定向至返回URL。 - `settings.redirect_policy.manual_redirection_action` (string) 由用户点击关闭按钮或返回游戏按钮触发的支付中心行为。可以是redirect(默认)或postmessage。如果设置为redirect,则用户将被重定向至令牌中传入的URL或发布商帐户中指定的URL。如果设置为postmessage,则用户留在原页面。点击关闭按钮发起发送close事件,点击返回游戏则发起发送return事件。 Enum: "redirect", "postmessage" - `settings.redirect_policy.redirect_button_caption` (string) 手动重定向按钮上的文字。 - `settings.redirect_policy.redirect_conditions` (string) 将用户重定向至返回URL的支付状态。可以是none, successful, successful_or_canсeled或any。 Enum: "none", "successful", "successful_or_canceled", "any" - `settings.redirect_policy.status_for_manual_redirection` (string) 显示让用户重定向至返回URL按钮的支付状态。可以是none, successful, successful_or_canсeled或any。 Enum: "none", "successful", "successful_or_canceled", "any" - `settings.return_url` (string) 用户会在支付过后被重定向到此页面。参数user_id、foreigninvoice、invoice_id和status会被自动添加到此链接。 - `settings.ui` (object) 带有界面设置相关数据的对象。 Example: {"components":{"virtual_currency":{"custom_amount":true}},"desktop":{"virtual_item_list":{"button_with_price":true,"layout":"list"}},"size":"medium"} - `settings.ui.components` (object) 带有模块菜单设置相关数据的对象。 Example: {"virtual_currency":{"custom_amount":true}} - `settings.ui.components.subscriptions` (object) 带有订阅模块设置相关数据的对象。 - `settings.ui.components.subscriptions.hidden` (boolean) 在菜单中显示还是隐藏“管理订阅”页面。 - `settings.ui.components.subscriptions.order` (integer) 虚拟物品在模块菜单中的排列顺序。 - `settings.ui.components.virtual_currency` (object) 带有虚拟货币模块设置相关数据的对象。 Example: {"custom_amount":true} - `settings.ui.components.virtual_currency.custom_amount` (boolean) 是否允许在支付UI中输入任意数量的虚拟货币。 Example: true - `settings.ui.components.virtual_items` (object) 带有虚拟物品模块设置相关数据的对象。 - `settings.ui.components.virtual_items.selected_group` (string) 用户打开虚拟物品选项卡时将会选择的组。 - `settings.ui.components.virtual_items.selected_item` (string) 用户打开虚拟物品选项卡时将会选择的物品。物品 SKU 应发送至此处。 - `settings.ui.desktop` (object) 带有对桌面版本有效的界面设置相关数据的对象。 Example: {"virtual_item_list":{"button_with_price":true,"layout":"list"}} - `settings.ui.desktop.header` (object) 带有标题设置相关数据的对象。 - `settings.ui.desktop.header.close_button` (boolean) 是否在支付中心桌面端显示关闭按钮。该按钮将关闭支付中心并将用户重定向到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,标题中将显示Logo(请先把Logo文件提供给您的客户成功经理)。 - `settings.ui.desktop.header.visible_name` (boolean) 标题中是否显示项目名称。 - `settings.ui.desktop.header.visible_purchase` (boolean) 是否在标题中显示购买描述(purchase.description.value)。默认为true。 - `settings.ui.desktop.subscription_list` (object) 带有订阅列表设置相关数据的对象。 - `settings.ui.desktop.subscription_list.description` (string) 可以在此传递订阅相关的任意文本。文本将显示在订阅计划列表的上方。 - `settings.ui.desktop.subscription_list.display_local_price` (boolean) 如为true且如果用户的当地货币与订阅计划的货币不同,则用户将看到两种价格:以当地货币和基础货币标价的价格。 - `settings.ui.desktop.subscription_list.layout` (string) 订阅列表模式。可以是list(默认值)或grid。 Enum: "list", "grid" - `settings.ui.desktop.virtual_currency_list` (object) 带有虚拟货币列表设置相关数据的对象。 - `settings.ui.desktop.virtual_currency_list.button_with_price` (boolean) 如果为true,则价格会显示在按钮里。如果为false,则价格会显示在按钮左侧。默认值为false。 - `settings.ui.desktop.virtual_currency_list.description` (string) 可以在此传递虚拟货币列表相关的任意文本。文本将显示在虚拟货币包列表的上方。 - `settings.ui.desktop.virtual_item_list` (object) 带有虚拟物品列表设置相关数据的对象。 Example: {"button_with_price":true,"layout":"list"} - `settings.ui.desktop.virtual_item_list.view` (string) 以垂直/水平菜单显示虚拟项目组。可以horizontal_navigation或vertical_navigation(默认)。 Enum: "horizontal_navigation", "vertical_navigation" - `settings.ui.header` (object) - `settings.ui.header.visible_virtual_currency_balance` (boolean) 此元素是否可在支付UI上隐藏。默认为true。 - `settings.ui.is_prevent_external_link_open` (boolean) 是否禁用将链接重定向至外部资源。默认为true。点击外部链接时,将通过postMessage机制发送external-link-open事件。重定向链接的地址在url参数中传递。 - `settings.ui.license_url` (string) EULA的链接。 - `settings.ui.mobile` (object) - `settings.ui.mobile.footer` (object) - `settings.ui.mobile.footer.is_visible` (boolean) 是否在移动版本的支付UI中隐藏或显示脚注。 - `settings.ui.mobile.mode` (string) 用户仅可以通过他们已保存的付款方式进行付款。可以为saved_accounts。 Enum: "saved_accounts" - `settings.ui.mode` (string) 支付中心的界面模式。可能的值为user_account。请注意,页眉仅包含用户帐户的导航菜单,而没有用于选择产品或进行付款的任何选项。“用户帐户”仅在桌面模式下可用。 - `settings.ui.size` (string) 支付UI的大小。此参数可拥有以下值之一,具体取决于支付UI的所需大小: - [small](https://livedemo.xsolla.com/developers/small/):支付UI支持的最小尺寸。当窗口大小严格受限时,请使用此值(尺寸:620 x 630) - [medium](https://livedemo.xsolla.com/developers/medium/):支付UI的推荐大小。使用此值可以在灯箱中显示支付UI(尺寸:740 x 760) - [large](https://livedemo.xsolla.com/developers/large/):在新窗口或者选项卡中显示支付UI的最佳大小(尺寸:820 x 840) Enum: "small", "medium", "large" - `settings.ui.theme` (string) 支付UI的外观主题。可以是default(默认值)或default_dark。 Enum: "default", "default_dark" - `settings.ui.user_account` (object) 对象以及有关用户账号的数据。 - `settings.ui.user_account.history` (object) 历史记录子菜单。 - `settings.ui.user_account.history.enable` (boolean) 在菜单中显示还是隐藏“管理订阅”页面。默认值为false。 - `settings.ui.user_account.info` (object) 我的账户页面。 - `settings.ui.user_account.payment_accounts` (object) 保存的付款方法子菜单。 - `settings.ui.user_account.subscriptions` (object) 管理订阅子菜单。 - `settings.ui.version` (string) 设备的类型。可以是desktop(默认值)或mobile。 Enum: "desktop", "mobile" - `user` (object) 带用户相关数据的对象。 Example: {"age":19,"country":{"allow_modify":true,"value":"US"},"email":{"value":"john.smith@mail.com"},"id":{"value":"user_2"},"name":{"value":"John Smith"}} - `user.age` (integer) 用户年龄。 Example: 19 - `user.attributes` (object) 带有用户属性相关数据的对象,用于筛选物品列表。应当是带键值对的有效JSON哈希。 - `user.country` (object) Example: {"allow_modify":true,"value":"US"} - `user.country.allow_modify` (boolean) 用户是否可以更改支付UI上的国家/地区。如果令牌中传入了country.value值,则值默认为false。 Example: true - `user.country.value` (string) 使用[ISO 3166-1 alpha-2标准](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)规定的2字母组合表示国家/地区。 Example: "US" - `user.email` (object) user.email对象是反欺诈模型的必要部分,有助于提高接受率。同时它也是艾克索拉和支付系统的要求。如果未传入该参数,支付页面将显示输入邮箱必填字段。购买凭证将发送至在该参数中传入的或在支付页面上输入的邮箱地址。 Example: {"value":"john.smith@mail.com"} - `user.email.value` (string, required) 用户电子邮箱。必须符合[RFC 822](https://www.w3.org/Protocols/rfc822/#z8)协议标准。 Example: "john.smith@mail.com" - `user.id` (object, required) Example: {"value":"user_2"} - `user.id.value` (string, required) 用户ID。 Example: "user_2" - `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) Example: {"value":"John Smith"} - `user.name.value` (string) 用户昵称。 Example: "John Smith" - `user.phone` (object) - `user.phone.value` (string) 电话号码。 - `user.public_id` (object) - `user.public_id.value` (string) 唯一识别用户并为用户所熟知的参数,与用户ID(电子邮件、昵称等)不同。此参数在可以在游戏商店以外进行购买时使用(如现金售货亭中的游戏按键)。 - `user.steam_id` (object) - `user.steam_id.value` (string) Steam ID。 - `user.tracking_id` (object) - `user.tracking_id.value` (string) 唯一的跟踪ID(用于营销活动)。 - `user.utm` (object) 对象包含描述流量特性的数据。 - `user.utm.utm_campaign` (string) 活动标题。该参数应当包含直译的活动标题或者翻译为英文的活动标题。 - `user.utm.utm_content` (string) 该活动的实质。 - `user.utm.utm_medium` (string) 流量渠道(内容关联广告、媒体广告、邮件列表消息)。 - `user.utm.utm_source` (string) 流量来源。 - `user.utm.utm_term` (string) 活动关键词。在指定该参数的情况下,统计数据是基于在确定您的广告活动的目标对象过程中所使用的关键词数据而生成的,而不是基于检索项数据。在Google Analytics中,utm_term标签的内容成为包含检索项的综合报告中的一部分。 ## Response 200 fields (application/json): - `token` (string) ## Response 422 fields (application/json): - `extended_message` (object) - `extended_message.global_errors` (array) - `extended_message.property_errors` (object) 对象包含参数名称和错误描述。 - `http_status_code` (integer) - `message` (string) - `request_id` (string)