Deprecated

How to use new Commerce API methods

How it works

You can connect the Commerce API:

  • If you have already implemented server integration (integration with token) with Xsolla but you want to switch to new Commerce API methods
  • If you want to implement the server part of your store for a new start

Main features:

  • Authorization via Xsolla Login
  • Authorization via Pay Station access token
  • Virtual items management
  • User inventory management
  • Cart and order management

Who can use it

  • Partners who develop a store interface and want to use a third-party solution to implement the server side.
  • Partners who have already implemented server integration with Xsolla and want to connect Store with new Commerce API methods.

How to get it

To connect the Commerce API to your app:

  1. Set up the Virtual Items module in your Publisher Account.
  2. Set up authentication.
  3. Implement methods for store management.

For integration you will need the Project ID or Merchant ID shown in Project settings > Webhooks.

Authentication setup

The following user authentication options are available:

  • Via Xsolla Login. Choose this option if you have not implemented server integration with Xsolla.
  • Via Pay Station access token. Choose this option if you have implemented server integration with Xsolla.

Authentication via Xsolla Login

  1. Set up a project in Publisher Account.
  2. Implement the call of the authorization methods with the help of the JSON Web Token or OAuth 2.0 protocol.

If the user data is kept in the Xsolla data storage, implement the call of the following methods:

If the user data is kept in the PlayFab data storage, use the PlayFab how-to.

If the user data is kept on your side, use the Custom storage how-to.

Authentication via Pay Station access token

Authentication flow:

  1. Your application (client) sends the authentication request to your server.
  2. Your server requests authorization token and sends the header containing project_id/merchant_id and api_key parameters to the Xsolla server.
  3. Xsolla server sends authorization token in the parameter access_token to your server.
  4. Your server sends the parameter access_token to your client.

The returned access_token is used as an authorization token for authentication in the Commerce API and building a store interface.

Store management methods

You should implement base store management methods:

Get list of items management

Cart and order management

  • Get cart — for purchasing virtual items — Get cart by ID or Get current user’s cart. Parameter card_id will be used to add or remove items.
  • Get order — to determine if the purchase has already been processed. The following order statuses are possible:
    • New — order is created but not paid
    • Paid — order is paid
    • Canceled — order is canceled
    • Done — order is paid and the item is added to the inventory

Note
The status check should be carried out with a certain frequency, since a one-time check can occur earlier than the order is given the new status.

The created order will receive a New order status.

To open the payment UI in a new window, use the following link: https://secure.xsolla.com/paystation3/?access_token=ACCESS_TOKEN, where ACCESS_TOKEN is the token received when the order was created.

To test the payment process:

  1. Use the following URL: https://sandbox-secure.xsolla.com/paystation3/?access_token=ACCESS_TOKEN.
  2. Set the sandbox parameter to true in the request.
  3. Use the list of bank cards for testing.

User inventory management

Was this article helpful?
Thank you!
Is there anything we can improve? Message
We’re sorry to hear that
Please explain why this article wasn’t helpful to you. Message
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.
Rate this page
Rate this page
Is there anything we can improve?

Don’t want to answer

Thank you for your feedback!
Last updated: June 25, 2021

Found a typo or other text error? Select the text and press Ctrl+Enter.

Report a problem
We always review our content. Your feedback helps us improve it.
Provide an email so we can follow up
Thank you for your feedback!