Merchant ID.
Subscriptions API (2.0)
- 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.
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.
User details.
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. Must be valid according to the RFC 822 protocol.
User attributes for filtering the item list, represented as a valid JSON set of key-value pairs.
Traffic attributes.
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.
Object with legal entity details. Object and all its parameters are required if user.is_legal is true.
Country of incorporation. Two-letter uppercase country code per ISO 3166-1 alpha-2 is used.
Custom project settings.
Game’s Xsolla ID. Can be found in Publisher Account.
Page to redirect the user to after payment. Parameters user_id, foreigninvoice, invoice_id and status will be automatically added to the link.
Redirect policy settings.
Payment status for which a user is redirected to the return URL. Can be none, successful, successful_or_canсeled, or any.
Delay (in seconds) after which a user is automatically redirected to the return URL.
Whether to automatically redirect from the status page.
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.
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.
Preferred payment currency. Three-letter currency code per ISO 4217.
Set to sandbox to test out the payment process. In this case, use https://sandbox-secure.xsolla.com to access the test payment UI.
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.
Interface settings.
Payment UI theme. Can be default or default_dark.
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)
Interface settings for the desktop version.
Header settings.
If true, the header will show your logo (first provide the image to your Customer Success Manager).
Whether to show the purchase description (purchase.description.value) in the header. true by default.
How to show the header. Can be compact (hides project name and user ID) or normal (default).
Settings for the list of subscription plans.
List template. Can be list (default) or grid.
Any text to show above the list of available subscription plans in the payment UI.
Settings for the list of virtual items.
List template. Can be list (default) or grid.
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 for the list of virtual currencies.
Any text to show above the list of virtual currencies.
A user can only pay using their saved payment methods. Can be saved_accounts.
Menu settings.
Virtual items submenu settings.
Whether to show the submenu.
Group to show after opening the virtual items tab.
Virtual currency submenu settings.
Whether the user can enter an arbitrary quantity of the virtual currency in the payment UI.
Whether to show the submenu.
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.
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.
User account details.
Page My account.
History submenu.
My payment accounts submenu.
Object containing purchase details.
Object containing checkout details.
Currency of the purchase. Three-letter currency code per ISO 4217.
Subscription data.
External ID of the subscription plan. Can be found in the Subscriptions > Subscription plans section of Publisher Account.
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.
Subscription plans to show in the payment UI.
Gifted subscription details.
ID of the recipient.
Recipient email.
Whether to hide the gifter name. If true, the sender's name is hidden in the email notification. Defaults to false.
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.
Account creation date per ISO 8601.
Whether the player has connected social media profiles.
Last seen date per ISO 8601.
Whether the player uses account verification procedures.
Last password change date per ISO 8601.
Whether the player added additional information to their profile.
Average session time per ISO 8601.
- https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/token
- Mock serverhttps://xsolla.redocly.app/_mock/api/subscriptions/merchants/{merchant_id}/token
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
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"
}
}
}'{ "token": "eop57k1boA7nnYPtewZ6KEXJyJADEwRT" }