Skip to content

Overview

  • Version: 2.0
  • Servers: https://api.xsolla.com/merchant/v2/

This API reference describes endpoints for managing subscriptions, coupons, and promotions. To get more information about Subscriptions, see the product guide and the glossary.

Download OpenAPI description
Languages
Servers
Mock server
https://xsolla.redocly.app/_mock/api/subscriptions/
Operations

Request

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.

Notice

This 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.

Security
basicAuth
Path
merchant_idintegerrequired

Merchant ID.

Bodyapplication/jsonrequired
userobject

User details.

Example: {"country":{"allow_modify":true,"value":"US"},"age":19,"email":{"value":"john.smith@mail.com"},"id":{"value":"user_2"},"name":{"value":"John Smith"}}
user.​idobjectrequired
Example: {"value":"user_2"}
user.​id.​valuestringrequired

User ID.

Example: "user_2"
user.​emailobject

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.

Example: {"value":"john.smith@mail.com"}
user.​email.​valuestringrequired

User email. Must be valid according to the RFC 822 protocol.

Example: "john.smith@mail.com"
user.​nameobject
Example: {"value":"John Smith"}
user.​name.​valuestring

User screen name.

Example: "John Smith"
user.​ageinteger

User age.

Example: 19
user.​phoneobject
user.​phone.​valuestring

User phone number.

user.​countryobject
Example: {"allow_modify":true,"value":"US"}
user.​country.​valuestring

Two-letter uppercase country code per ISO 3166-1 alpha-2.

Example: "US"
user.​country.​allow_modifyboolean

Whether a user can change the country on payment UI. If country.value is passed in the token, the value is false by default.

Example: true
user.​attributesobject

User attributes for filtering the item list, represented as a valid JSON set of key-value pairs.

user.​steam_idobject
user.​steam_id.​valuestring

Steam ID.

user.​tracking_idobject
user.​tracking_id.​valuestring

Unique tracking ID (used in marketing campaigns).

user.​public_idobject
user.​public_id.​valuestring

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.​utmobject

Traffic attributes.

user.​utm.​utm_sourcestring

Traffic source.

user.​utm.​utm_mediumstring

Traffic channel (contextual ads, media ads, email lists, etc.).

user.​utm.​utm_campaignstring

Campaign title, transliterated or translated to English.

user.​utm.​utm_termstring

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_contentstring

Campaign content.

user.​is_legalboolean

Whether the user is a legal entity.

user.​legalobject

Object with legal entity details. Object and all its parameters are required if user.is_legal is true.

user.​legal.​namestring

Full legal name.

user.​legal.​addressstring

Full legal address.

user.​legal.​vat_idstring

Individual taxpayer identifier.

user.​legal.​countrystring

Country of incorporation. Two-letter uppercase country code per ISO 3166-1 alpha-2 is used.

settingsobject

Custom project settings.

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.​project_idintegerrequired

Game’s Xsolla ID. Can be found in Publisher Account.

Example: 16184
settings.​external_idstring

Transaction ID in the game. Has to be unique for each user payment.

settings.​languagestring

Interface language. Two-letter lowercase language code.

Example: "en"
settings.​return_urlstring

Page to redirect the user to after payment. Parameters user_id, foreigninvoice, invoice_id and status will be automatically added to the link.

settings.​redirect_policyobject

Redirect policy settings.

settings.​redirect_policy.​redirect_conditionsstring

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.​delayinteger

Delay (in seconds) after which a user is automatically redirected to the return URL.

settings.​redirect_policy.​autoredirect_from_status_pageboolean

Whether to automatically redirect from the status page.

settings.​redirect_policy.​status_for_manual_redirectionstring

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_actionstring

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_captionstring

Text on the button for manual redirection.

settings.​currencystring

Preferred payment currency. Three-letter currency code per ISO 4217.

Example: "USD"
settings.​modestring

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_methodinteger

Payment method ID.

settings.​payment_widgetstring

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.​uiobject

Interface settings.

Example: {"components":{"virtual_currency":{"custom_amount":true}},"desktop":{"virtual_item_list":{"button_with_price":true,"layout":"list"}},"size":"medium"}
settings.​ui.​themestring

Payment UI theme. Can be default or default_dark.

Enum"default""default_dark"
settings.​ui.​sizestring

Payment UI size. Can be:

  • small: the least possible size of the payment UI. Use this value when the window size is strictly limited (dimensions: 620 x 630)
  • medium: recommended size. Use this value to display the payment UI in a lightbox (dimensions: 740 x 760)
  • large: the optimal size for displaying the payment UI in a new window or tab (dimensions: 820 x 840)
Enum"small""medium""large"
Example: "medium"
settings.​ui.​versionstring

Device type. Can be desktop (default) or mobile.

Enum"desktop""mobile"
settings.​ui.​desktopobject

Interface settings for the desktop version.

Example: {"virtual_item_list":{"button_with_price":true,"layout":"list"}}
settings.​ui.​desktop.​headerobject

Header settings.

settings.​ui.​desktop.​header.​is_visibleboolean

Whether to show the header in the payment UI.

settings.​ui.​desktop.​header.​visible_logoboolean

If true, the header will show your logo (first provide the image to your Customer Success Manager).

settings.​ui.​desktop.​header.​visible_nameboolean

Whether to show the project name in the header.

settings.​ui.​desktop.​header.​visible_purchaseboolean

Whether to show the purchase description (purchase.description.value) in the header. true by default.

settings.​ui.​desktop.​header.​typestring

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_buttonboolean

Whether to show a Close button in Pay Station desktop. The button closes Pay Station and redirects the user to the URL specified in the settings.return_url parameter. false by default.

settings.​ui.​desktop.​subscription_listobject

Settings for the list of subscription plans.

settings.​ui.​desktop.​subscription_list.​layoutstring

List template. Can be list (default) or grid.

Enum"list""grid"
settings.​ui.​desktop.​subscription_list.​descriptionstring

Any text to show above the list of available subscription plans in the payment UI.

settings.​ui.​desktop.​subscription_list.​display_local_priceboolean

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.​desktop.​virtual_item_listobject

Settings for the list of virtual items.

Example: {"button_with_price":true,"layout":"list"}
settings.​ui.​desktop.​virtual_item_list.​layoutstring

List template. Can be list (default) or grid.

Enum"list""grid"
Example: "list"
settings.​ui.​desktop.​virtual_item_list.​button_with_priceboolean

If true, the price will be shown on the button. If false, the price will be shown on the left of the button. false by default.

Example: true
settings.​ui.​desktop.​virtual_item_list.​viewstring

Display virtual item groups as a vertical/horizontal menu. Can be horizontal_navigation or vertical_navigation (default).

Enum"horizontal_navigation""vertical_navigation"
settings.​ui.​desktop.​virtual_currency_listobject

Settings for the list of virtual currencies.

settings.​ui.​desktop.​virtual_currency_list.​descriptionstring

Any text to show above the list of virtual currencies.

settings.​ui.​desktop.​virtual_currency_list.​button_with_priceboolean

If true, the price will be shown on the button. If false, the price will be shown on the left of the button. false by default.

settings.​ui.​headerobject
settings.​ui.​header.​visible_virtual_currency_balanceboolean

Whether or not this element can be hidden on Payment UI. true by default.

settings.​ui.​mobileobject
settings.​ui.​mobile.​modestring

A user can only pay using their saved payment methods. Can be saved_accounts.

Value"saved_accounts"
settings.​ui.​mobile.​headerobject
settings.​ui.​mobile.​header.​close_buttonboolean

Whether to show a Close button in Pay Station mobile. The button closes Pay Station and redirects the user to the URL specified in the settings.return_url parameter. false by default.

settings.​ui.​mobile.​footerobject
settings.​ui.​mobile.​footer.​is_visibleboolean

Whether to hide the footer in the mobile version of the payment UI.

settings.​ui.​license_urlstring

Link to the EULA.

settings.​ui.​componentsobject

Menu settings.

Example: {"virtual_currency":{"custom_amount":true}}
settings.​ui.​components.​virtual_itemsobject

Virtual items submenu settings.

settings.​ui.​components.​virtual_items.​orderinteger

Position of the submenu in the menu.

settings.​ui.​components.​virtual_items.​hiddenboolean

Whether to show the submenu.

settings.​ui.​components.​virtual_items.​selected_groupstring

Group to show after opening the virtual items tab.

settings.​ui.​components.​virtual_items.​selected_itemstring

Item to show after opening the virtual items tab (item SKU).

settings.​ui.​components.​virtual_currencyobject

Virtual currency submenu settings.

Example: {"custom_amount":true}
settings.​ui.​components.​virtual_currency.​custom_amountboolean

Whether the user can enter an arbitrary quantity of the virtual currency in the payment UI.

Example: true
settings.​ui.​components.​virtual_currency.​orderinteger

Position of the submenu in the menu.

settings.​ui.​components.​virtual_currency.​hiddenboolean

Whether to show the submenu.

settings.​ui.​components.​subscriptionsobject

Subscription plans submenu settings.

settings.​ui.​components.​subscriptions.​orderinteger

Position of the submenu in the menu.

settings.​ui.​components.​subscriptions.​hiddenboolean

Whether to show the submenu.

settings.​ui.​modestring

Interface mode in Pay Station. Can be user_account only. The header contains only the account navigation menu, and the user cannot select a product or make a payment. This mode is only available on the desktop.

settings.​ui.​is_prevent_external_link_openboolean

Whether or not redirecting links to an external resource is disabled. true 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.​user_accountobject

User account details.

settings.​ui.​user_account.​infoobject

Page My account.

settings.​ui.​user_account.​info.​orderinteger

Position of the submenu in the menu.

settings.​ui.​user_account.​info.​enableboolean

Whether to show the submenu. false by default.

settings.​ui.​user_account.​historyobject

History submenu.

settings.​ui.​user_account.​history.​orderinteger

Position of the submenu in the menu.

settings.​ui.​user_account.​history.​enableboolean

Whether to show the submenu. false by default.

settings.​ui.​user_account.​payment_accountsobject

My payment accounts submenu.

settings.​ui.​user_account.​payment_accounts.​orderinteger

Position of the submenu in the menu.

settings.​ui.​user_account.​payment_accounts.​enableboolean

Whether to show the submenu. false by default.

settings.​ui.​user_account.​subscriptionsobject

Manage subscriptions submenu.

settings.​ui.​user_account.​subscriptions.​orderinteger

Position of the submenu in the menu.

settings.​ui.​user_account.​subscriptions.​enableboolean

Whether to show the submenu. false by default.

purchaseobject

Object containing purchase details.

Example: {"checkout":{"currency":"USD","amount":10},"subscription":{"gift":{"recipient":"test_recipient_v1","email":"recipient_email@email.com"}}}
purchase.​checkoutobject

Object containing checkout details.

Example: {"currency":"USD","amount":10}
purchase.​checkout.​currencystring

Currency of the purchase. Three-letter currency code per ISO 4217.

Example: "USD"
purchase.​checkout.​amountinteger(float)

Purchase amount.

Example: 10
purchase.​subscriptionobject

Subscription data.

Example: {"gift":{"recipient":"test_recipient_v1","email":"recipient_email@email.com"}}
purchase.​subscription.​plan_idstring

External ID of the subscription plan. Can be found in the Subscriptions > Subscription plans section of Publisher Account.

purchase.​subscription.​operationstring

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_idstring

Product ID.

purchase.​subscription.​currencystring

Currency of the subscription plan to use in all calculations.

purchase.​subscription.​available_plansArray of strings

Subscription plans to show in the payment UI.

purchase.​subscription.​trial_daysinteger

Trial period in days.

purchase.​subscription.​giftobject

Gifted subscription details.

Example: {"recipient":"test_recipient_v1","email":"recipient_email@email.com"}
purchase.​subscription.​gift.​recipientstringrequired

ID of the recipient.

Example: "test_recipient_v1"
purchase.​subscription.​gift.​emailstringrequired

Recipient email.

Example: "recipient_email@email.com"
purchase.​subscription.​gift.​anonymousboolean

Whether to hide the gifter name. If true, the sender's name is hidden in the email notification. Defaults to false.

purchase.​subscription.​gift.​messagestring

Message for the recipient.

purchase.​subscription.​gift.​redirect_urlstring

Provide a link here to a page with additional information about the gifted subscription or to the account creation page. The gift recipient can navigate to this page from the subscription gift email notification.

custom_parametersobject

You can pass additional parameters in the token in the custom_parameters object to configure anti-fraud filters. The recommended parameters are shown in the drop-down list. See Pay Station documentation.

custom_parameters.​registration_datestring

Account creation date per ISO 8601.

custom_parameters.​total_hoursinteger

Total number of in-game hours.

custom_parameters.​total_charactersinteger

Number of in-game characters.

custom_parameters.​social_networks_addedboolean

Whether the player has connected social media profiles.

custom_parameters.​profile_image_addedboolean

Whether the player has uploaded a profile image.

custom_parameters.​active_datestring

Last seen date per ISO 8601.

custom_parameters.​total_friendsinteger

Number of friends.

custom_parameters.​additional_verificationboolean

Whether the player uses account verification procedures.

custom_parameters.​win_rateinteger

Win rate.

custom_parameters.​last_change_password_datestring

Last password change date per ISO 8601.

custom_parameters.​chat_activityboolean

Whether the player uses the chat function.

custom_parameters.​forum_activityboolean

Whether the player uses the forum function.

custom_parameters.​total_bansinteger

Number of times the player was banned in the chat/forum.

custom_parameters.​profile_completedboolean

Whether the player added additional information to their profile.

custom_parameters.​notifications_enabledboolean

Whether the player enabled notifications.

custom_parameters.​user_levelinteger

Player’s level, reputation, or rank.

custom_parameters.​karma_pointsinteger

Player’s karma.

custom_parameters.​total_suminteger(float)

Total amount of payments.

custom_parameters.​non_premium_currencyinteger(float)

Amount of non-premium currency.

custom_parameters.​total_game_eventsinteger

Number of in-game events the player took part in.

custom_parameters.​total_giftsinteger

Number of in-game gifts the player has sent/received.

custom_parameters.​tutorial_completedboolean

Whether the player has completed the game’s tutorial.

custom_parameters.​completed_tasksinteger

Number of tasks/objectives completed.

custom_parameters.​items_usedboolean

Whether the player uses purchased in-game items.

custom_parameters.​pvp_activityboolean

Whether the player takes part in PvP battles.

custom_parameters.​total_clansinteger

Number of clans the player is a member of.

custom_parameters.​unlocked_achievementsinteger

Number of achievements unlocked.

custom_parameters.​total_inventory_valueinteger(float)

Total inventory value (in-game currency).

custom_parameters.​character_customizedboolean

Whether the player has customized their character.

custom_parameters.​session_timestring

Average session time per ISO 8601.

curl -i -X POST \
  -u <username>:<password> \
  'https://xsolla.redocly.app/_mock/api/subscriptions/merchants/{merchant_id}/token' \
  -H 'Content-Type: application/json' \
  -d '{
    "purchase": {
      "checkout": {
        "currency": "USD",
        "amount": 10
      },
      "subscription": {
        "gift": {
          "recipient": "test_recipient_v1",
          "email": "recipient_email@email.com"
        }
      }
    },
    "settings": {
      "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"
      }
    },
    "user": {
      "country": {
        "allow_modify": true,
        "value": "US"
      },
      "age": 19,
      "email": {
        "value": "john.smith@mail.com"
      },
      "id": {
        "value": "user_2"
      },
      "name": {
        "value": "John Smith"
      }
    }
  }'

Responses

Created.

Bodyapplication/json
tokenstring
Response
application/json
{ "token": "eop57k1boA7nnYPtewZ6KEXJyJADEwRT" }
Operations
Operations
Operations
Operations
Operations
Operations
Operations