# Create token You can create a token with arbitrary user parameters. You send these parameters when obtaining the token and receive them back after a successful payment. A token can only contain parameters either described in this document or predefined by you. If any parameter is sent in the wrong format or has the wrong type, no token will be issued. You will receive a 422 HTTP code with the error description in the JSON body. In extended_message you will receive an information what exact parameters have been sent incorrectly. By default, the token lifetime is 24 hours. If you want to change this value, contact your Customer Success Manager or send an email to csm@xsolla.com. The new value will be enabled for all your company’s projects created in Publisher Account. NoticeThe token you obtain after calling this API method can be used only for authorizing other requests. You can use this token to open the payment UI only if you integrated the Subscriptions product.To open the payment UI in a new window, use the following link: https://secure.xsolla.com/paystation4/?token={token}, where {token} is the received token.For testing purposes, use this URL: https://sandbox-secure.xsolla.com/paystation4/?token={token}. NoticeThis API call does not contain the project_id path parameter, so you need to use the API key that is valid in all the company’s projects to set up authorization. Endpoint: POST /merchants/{merchant_id}/token Version: 2.0 Security: basicAuth ## Path parameters: - `merchant_id` (integer, required) Merchant ID. ## Request fields (application/json): - `user` (object) User details. - `user.id` (object, required) - `user.id.value` (string, required) Unique user ID in the game stored on your side. Make sure you pass the existing user ID. In case an error occurs, refer to the [answers to the FAQs](/doc/pay-station/references/faq/#faq_validation). - `user.email` (object) The user.email object is an integral part of building anti-fraud models and helps increase acceptance rates. It is both Xsolla and payment systems requirement. If the parameter is not passed, the required field for entering email appears on the payment page. A user receives a purchase receipt to the email passed in the parameter or entered on the payment page. - `user.email.value` (string, required) User email. Must be valid according to the [RFC 822](https://www.w3.org/Protocols/rfc822/#z8) protocol. - `user.email.allow_modify` (boolean) Whether a user can enter their email in the payment UI. If the user.email.value parameter is passed in the token, the value is false by default. - `user.name` (object) - `user.name.value` (string) User screen name. - `user.name.allow_modify` (boolean) Whether a user can enter their name in the payment UI. If the user.name.value parameter is passed in the token, the value is false by default. - `user.age` (integer) User age. - `user.phone` (object,null) - `user.phone.value` (string) User phone number. - `user.country` (object) - `user.country.value` (string) Two-letter uppercase country code per [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). - `user.country.allow_modify` (boolean) Whether a user can change the country on payment UI. If country.value is passed in the token, the value is false by default. - `user.attributes` (object) User attributes for filtering the item list, represented as a valid JSON set of key-value pairs. - `user.steam_id` (object) - `user.steam_id.value` (string) Steam ID. - `user.tracking_id` (object) - `user.tracking_id.value` (string) Unique user ID — used in marketing campaigns. Can contain digits and Latin characters. - `user.public_id` (object) - `user.public_id.value` (string) Parameter that uniquely identifies the user and is known to the user (email, screen name, etc). Allows the user to make purchases outside the game store (e.g., via cash kiosks). - `user.utm` (object) Traffic attributes. - `user.utm.utm_source` (string) Traffic source. - `user.utm.utm_medium` (string) Traffic channel (contextual ads, media ads, email lists, etc.). - `user.utm.utm_campaign` (string) Campaign title, transliterated or translated to English. - `user.utm.utm_term` (string) Campaign keyword. If set, statistics will be based on the keywords used for ad targeting rather than on specific search queries. In Google Analytics, the specified utm_term is part of the general search terms report. - `user.utm.utm_content` (string) Campaign content. - `user.is_legal` (boolean) Whether the user is a legal entity. - `user.legal` (object) Object with legal entity details. Object and all its parameters are required if user.is_legal is true. - `user.legal.name` (string) Full legal name. - `user.legal.address` (string) Full legal address. - `user.legal.vat_id` (string) Individual taxpayer identifier. - `user.legal.country` (string) Country of incorporation. Two-letter uppercase country code per [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) is used. - `settings` (object) Settings for configuring payment process and the payment UI for a user. - `settings.project_id` (integer, required) Game’s Xsolla ID. Can be found in Publisher Account. - `settings.external_id` (string) Transaction ID in the game. Has to be unique for each user payment. Refer to documentation for detailed information. - `settings.language` (string) Interface language. Two-letter lowercase [language code](https://developers.xsolla.com/doc/pay-station/features/localization/). - `settings.return_url` (string) URL of the page where a user is redirected to after the payment. Refer to documentation for detailed information about configuring redirects. - `settings.redirect_policy` (object) Redirect policy settings. - `settings.redirect_policy.redirect_conditions` (string) Payment status for which a user is redirected to the return URL. Can be none, successful, successful_or_canсeled, or any. Enum: "none", "successful", "successful_or_canceled", "any" - `settings.redirect_policy.delay` (integer) Delay (in seconds) after which a user is automatically redirected to the return URL. - `settings.redirect_policy.status_for_manual_redirection` (string) Payment status for which a button redirecting a user to the return URL is displayed. Can be none, successful, successful_or_canсeled, or any. Enum: "none", "successful", "successful_or_canceled", "any" - `settings.redirect_policy.manual_redirection_action` (string) Pay Station behavior triggered by the user clicking the close button or the Back to the Game button. Can be redirect (by default) and postmessage. If set to redirect, a user is redirected to the URL passed in the token or specified in Publisher Account. If set to postmessage, a user is not redirected to other pages. Clicking the close icon initiates sending the close event, and clicking the Back to the Game button — the return event. Enum: "redirect", "postmessage" - `settings.redirect_policy.redirect_button_caption` (string) Text on the button for manual redirection. - `settings.currency` (string) Preferred payment currency. Three-letter currency code per [ISO 4217](https://developers.xsolla.com/doc/pay-station/references/supported-currencies/). - `settings.mode` (string) Set to sandbox to test out the payment process. In this case, use https://sandbox-secure.xsolla.com to access the test payment UI. - `settings.payment_method` (integer) Payment method ID. - `settings.payment_widget` (string) Payment widget. Can be paybycash or giftcard. If the parameter is set, the user is redirected to the Pay by Cash or Gift Cards widget, respectively. Enum: "paybycash", "giftcard" - `settings.ui` (object) Interface settings. - `settings.ui.theme` (string) Payment UI theme. Can be 63295a9a2e47fab76f7708e1 for the light theme (default) or 63295aab2e47fab76f7708e3 for the dark theme. You can also [create a custom theme](https://developers.xsolla.com/doc/pay-station/features/ui-theme-customization/#pay_station_ui_theme_customization_in_token) and pass its ID in this parameter. Enum: "63295a9a2e47fab76f7708e1", "63295aab2e47fab76f7708e3" - `settings.ui.desktop` (object) Interface settings for the desktop version. - `settings.ui.desktop.header` (object) Header settings. - `settings.ui.desktop.header.is_visible` (boolean) Whether to show the header in the payment UI. - `settings.ui.desktop.header.visible_logo` (boolean) If true, the logo is displayed in the header. To upload the image, open your project in [Publisher Account](https://publisher.xsolla.com/) and go to the Pay Station > Settings section. - `settings.ui.desktop.header.visible_name` (boolean) Whether to show the project name in the header. - `settings.ui.desktop.header.visible_purchase` (boolean) Whether to show the purchase description (purchase.description.value) in the header. true by default. - `settings.ui.desktop.header.type` (string) How to show the header. Can be compact (hides project name and user ID) or normal (default). Enum: "compact", "normal" - `settings.ui.desktop.header.close_button` (boolean) Whether to show the Close button in the payment UI. The button closes the payment UI and redirects the user to the URL specified in the settings.return_url parameter. false by default. - `settings.ui.desktop.header.close_button_icon` (string) The icon of the Close button in the payment UI. Enum: "arrow", "cross" - `settings.ui.desktop.subscription_list` (object) Settings for the list of subscription plans. - `settings.ui.desktop.subscription_list.description` (string) Any text to show above the list of available subscription plans in the payment UI. - `settings.ui.desktop.subscription_list.display_local_price` (boolean) If true, and if the user’s local currency is different from the one set for the subscription plan, the user will be able to see both prices: one in the local and one in the basic currency. - `settings.ui.header` (object) - `settings.ui.header.visible_virtual_currency_balance` (boolean) Whether or not this element can be hidden on Payment UI. true by default. - `settings.ui.mobile` (object) - `settings.ui.components` (object) Menu settings. - `settings.ui.components.virtual_items` (object) Virtual items submenu settings. - `settings.ui.components.virtual_items.order` (integer) Position of the submenu in the menu. - `settings.ui.components.virtual_items.hidden` (boolean) Whether to show the submenu. - `settings.ui.components.virtual_items.selected_group` (string) Group to show after opening the virtual items tab. - `settings.ui.components.virtual_items.selected_item` (string) Item to show after opening the virtual items tab (item SKU). - `settings.ui.components.virtual_currency` (object) Virtual currency submenu settings. - `settings.ui.components.virtual_currency.custom_amount` (boolean) Whether the user can enter an arbitrary quantity of the virtual currency in the payment UI. - `settings.ui.components.subscriptions` (object) Subscription plans submenu settings. - `settings.ui.mode` (string) Display mode of the payment UI for managing saved payment methods. Can be set to user_account or omitted. In this mode, the user can only change the language, add new payment methods, and remove existing ones. NoteWhen this parameter is passed, the redirect button is not displayed. To redirect a user after saving a payment method, configure automatic redirects. - `settings.ui.is_prevent_external_link_open` (boolean) Whether or not redirecting links to an external resource is disabled. false by default. When clicking an external link, the external-link-open event is sent via the postMessage mechanism. The address for the redirected link is passed in the url parameter. - `settings.ui.is_payment_methods_list_mode` (boolean) Whether the list of payment methods available in the user’s country is displayed when opening the payment UI. If false (default), the payment method passed in the settings.payment_method parameter or the method selected by the [PayRank algorithm](https://developers.xsolla.com/solutions/payments/payment-ui-management/top-payment-methods-management/) is displayed. - `settings.ui.is_independent_windows` (boolean) Whether to redirect users from the embedded launcher’s browser (WebView) to their default browser to make a purchase. false by default. - `settings.ui.user_account` (object) User account details. - `settings.ui.user_account.payment_accounts` (object) Saved methods section. - `settings.ui.user_account.payment_accounts.enable` (boolean) Specifies whether to display the pencil icon in the payment UI that goes to the payment method editing page. true by default. - `settings.ui.user_account.payment_accounts.order` (integer) Position of the section in the drop-down list in the payment UI. Required if settings.ui.user_account.payment_accounts.enable is passed. - `settings.ui.currency_format` (string) Set to code to display a three-letter [ISO 4217](https://developers.xsolla.com/doc/pay-station/references/supported-currencies/) currency code in the payment UI. The currency symbol is displayed instead of the three-letter currency code by default. - `settings.ui.is_show_close_widget_warning` (boolean) Whether to show a warning about processing the transaction when hovering over the × icon before closing the payment page. If false is passed, or the parameter is not passed, the warning is not displayed. true by default. - `settings.ui.layout` (string) Location of the main elements of the payment UI. You can open the payment UI inside your game and/or swap the columns with information about an order and payment methods. Refer to the [customization instructions](https://developers.xsolla.com/doc/pay-station/features/ui-theme-customization/#pay_station_ui_theme_customization_layout) for detailed information. Enum: "embed", "column_reverse", "embed_column_reverse" - `settings.ui.is_three_ds_independent_windows` (boolean) Whether the 3-D Secure verification opens in a new browser window. If your setup enforces a Content Security Policy (CSP), set to true. - `settings.ui.is_cart_open_by_default` (boolean) The display of the list of cart items and financial details in the payment UI. If true, information is displayed in an extended view. If false (default) or the parameter is not passed, information is displayed in a collapsed view. - `settings.ui.gp_quick_payment_button` (boolean) The way the Google Pay payment method is displayed. If true, the button for quick payment via Google Pay is displayed at the top of the payment UI, regardless of the user’s device and browser. If false, Google Pay is displayed in the list of payment methods according to the [PayRank](/doc/pay-station/how-to/how-to-manage-top-payment-methods/) algorithm. If the parameter is not passed, Google Pay is displayed at the top of the payment UI on any user’s devices and browsers, except Safari — on Safari, it is displayed in the list of payment methods. - `settings.ui.apple_pay_quick_payment_button` (boolean) Whether to display the button for quick payment via Apple Pay at the top of the payment UI on supported devices. true by default. If false, Apple Pay is displayed in the list of payment methods according to the [PayRank](/doc/pay-station/how-to/how-to-manage-top-payment-methods/) algorithm. NoteOn Android devices and any other devices that don’t support payment with Apple Pay, this payment method will be hidden from the list of available ones regardless of the parameter value. - `settings.ui.is_search_field_hidden` (boolean) Whether to show a payment method search bar in the payment UI. If true, the search bar is hidden. false by default. - `settings.ui.is_language_selector_hidden` (boolean) Whether the language selector is hidden on the payment page. If false (by default), the selector is displayed. - `purchase` (object) Object containing purchase details. - `purchase.subscription` (object) Subscription data. - `purchase.subscription.plan_id` (string) External ID of the subscription plan. Can be found in the Subscriptions > Subscription plans section of Publisher Account. - `purchase.subscription.operation` (string) The type of operation applied to the user’s subscription plan. To change the subscription plan, pass the change_plan value. You need to specify the new plan ID in the purchase.subscription.plan_id parameter. - `purchase.subscription.product_id` (string) Product ID. - `purchase.subscription.currency` (string) Currency of the subscription plan to use in all calculations. - `purchase.subscription.available_plans` (array) Subscription plans to show in the payment UI. - `purchase.subscription.trial_days` (integer) Trial period in days. - `custom_parameters` (object) This object contains parameters to configure anti-fraud filters. The list of parameters is shown below. To add custom parameters, contact your Customer Success Manager or email at [csm@xsolla.com](mailto:csm@xsolla.com). - `custom_parameters.registration_date` (string) Account creation date per [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601). - `custom_parameters.total_hours` (integer) Total number of in-game hours. - `custom_parameters.total_characters` (integer) Number of in-game characters. - `custom_parameters.social_networks_added` (boolean) Whether the player has connected social media profiles. - `custom_parameters.profile_image_added` (boolean) Whether the player has uploaded a profile image. - `custom_parameters.active_date` (string) Last seen date per [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601). - `custom_parameters.total_friends` (integer) Number of friends. - `custom_parameters.additional_verification` (boolean) Whether the player uses account verification procedures. - `custom_parameters.win_rate` (integer) Win rate. - `custom_parameters.last_change_password_date` (string) Last password change date per [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601). - `custom_parameters.chat_activity` (boolean) Whether the player uses the chat function. - `custom_parameters.forum_activity` (boolean) Whether the player uses the forum function. - `custom_parameters.total_bans` (integer) Number of times the player was banned in the chat/forum. - `custom_parameters.profile_completed` (boolean) Whether the player added additional information to their profile. - `custom_parameters.notifications_enabled` (boolean) Whether the player enabled notifications. - `custom_parameters.user_level` (integer) Player’s level, reputation, or rank. - `custom_parameters.karma_points` (integer) Player’s karma. - `custom_parameters.total_sum` (number) Total amount of payments. - `custom_parameters.non_premium_currency` (number) Amount of non-premium currency. - `custom_parameters.total_game_events` (integer) Number of in-game events the player took part in. - `custom_parameters.total_gifts` (integer) Number of in-game gifts the player has sent/received. - `custom_parameters.tutorial_completed` (boolean) Whether the player has completed the game’s tutorial. - `custom_parameters.completed_tasks` (integer) Number of tasks/objectives completed. - `custom_parameters.items_used` (boolean) Whether the player uses purchased in-game items. - `custom_parameters.pvp_activity` (boolean) Whether the player takes part in PvP (Player(s) versus player(s)) battles. - `custom_parameters.total_clans` (integer) Number of clans the player is a member of. - `custom_parameters.unlocked_achievements` (integer) Number of achievements unlocked. - `custom_parameters.total_inventory_value` (number) Total inventory value (in-game currency). - `custom_parameters.character_customized` (boolean) Whether the player has customized their character. - `custom_parameters.session_time` (string) Average session time per [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601). ## Response 200 fields (application/json): - `token` (string) ## Response 422 fields (application/json): - `http_status_code` (integer) - `message` (string) - `extended_message` (object) - `extended_message.global_errors` (array) - `extended_message.property_errors` (object) Object contains parameter names with error descriptions. - `request_id` (string)