Set up selling items

You can sell items via the direct link, widget, or store UI.

The following link is used for opening the payment UI:

Copy
Full screen
Small screen
https://store.xsolla.com/pages/buy.php?type={YOUR-ITEM-TYPE}&project_id={YOU_PROJECT_ID}&sku={YOUR-ITEM-SKU}

Add the following data to this link:

  • YOUR-ITEM-TYPE — item type:
    • game — game; game_key — for selling definite DRM game.
    • physical_item — physical goods.
    • virtual_item — virtual item.
    • virtual_currency — virtual currency.
    • bundle — virtual currency package or bundle.
  • YOUR-PROJECT-ID — your project ID in Publisher Account (your project > Project settings > General settings > Project ID).
  • YOUR-ITEM-SKU — item SKU. To sell a definite DRM game, you should get the DRM’s SKU by GET request Get games list shown in the full list of virtual items added to your store. Usually this SKU looks like unit_name_drm_sku.

  • Payment UI style: theme (dark is the dark parameter, or light that is the default parameter), size, and other parameters. Specify the ui_settings parameters in the URL and pass a settings.ui JSON-object that has a Base64 encoding as a value. Example of the URL with UI settings:

Copy
Full screen
Small screen
https://store.xsolla.com/pages/buy.php?type={YOUR-ITEM-TYPE}&project_id={YOU_PROJECT_ID}&sku={YOUR-ITEM-SKU}&ui_settings=ewoJCQkic2l6ZSI6ICJzbWFsbCIsCgkJCSJ0aGVtZSI6ICJkYXJrIgoJCX0=

  • Token for passing user data. Used only when selling items to authenticated users and is necessary for virtual items and virtual currency. This token depends on the authentication method. Example of the URL with a token:

Copy
Full screen
Small screen
https://store.xsolla.com/pages/buy.php?type={YOUR-ITEM-TYPE}&project_id={YOUR_PROJECT_ID}&sku={YOUR_ITEM_SKU}&xsolla_login_token={ACCESS_TOKEN}

  • The mode=sandbox parameter for payment tests. You can use test bank cards to complete payments. Example of the URL for testing:

Copy
Full screen
Small screen
https://store.xsolla.com/pages/buy.php?type={YOUR-ITEM-TYPE}&project_id={YOU_PROJECT_ID}&sku={YOUR-ITEM-SKU}&mode=sandbox

Selling via widget

Widget is a script that you can implement into your website for selling items. The examples of a working widget are on the demo page.

Code for implementing the widget:

Copy
Full screen
Small screen
<script>
    var options = {
        project_id: "YOUR-PROJECT-ID",
        item_type: "YOUR-ITEM-TYPE",
        sku: "YOUR-ITEM-SKU",
        user: "ACCESS_TOKEN",
        widget_ui: {
            target_element: '#widget-example-element'
        }
    };
    var s = document.createElement('script');
        s.type = "text/javascript";
        s.async = true;
        s.src = "https://cdn.xsolla.net/embed/buy-button/3.1.2/widget.min.js";
        s.addEventListener('load', function (e) {
          var widgetInstance = XBuyButtonWidget.create(options);
          }, false);
    var head = document.getElementsByTagName('head')[0];
    head.appendChild(s);
</script>

Add the following data to the code above:

  • YOUR-PROJECT-ID — your project ID in Publisher Account (your project > Project settings > General settings > Project ID)
  • YOUR-ITEM-TYPE — item type:
    • game — game; game_key — for selling definite DRM game.
    • physical_item — physical goods.
    • virtual_item — virtual item.
    • virtual_currency — virtual currency.
    • bundle — virtual currency package or bundle.
  • YOUR-ITEM-SKU — item SKU. To sell a definite DRM game, you should get the DRM’s SKU by GET request Get games list shown in the full list of virtual items added to your store. Usually this SKU looks like unit_name_drm_sku.
  • ACCESS_TOKEN — token for passing user data. Used only when selling items to authenticated users and is necessary for virtual items and virtual currency. This token depends on the authentication method.

See our GitHub for additional information on the widget configuration.

Selling via Store UI

For selling game keys, virtual items and virtual currency via the store UI, you can implement a separate web application or implement a store UI into the game. You should use the Commerce API or create your own store on the basis of the demo version for getting the list of items and working with them.

Basing on Commerce API

You can create a frontend part of a store by integrating the Commerce API methods:
  1. Getting the lists of virtual items, virtual currency packages and games.
  2. Purchasing items:

Choose a suitable authentication option for the methods to work correctly.

Note
To sell the game via the Commerce API methods, you should implement the choice of DRM’s on the frontend side. Pass the items.unit_items.sku parameter value from the Get games request as an SKU.

Basing on demo version

You can check the API features using a store demo version. Its code is uploaded to GitHub. You can use it as a basis for creating your own version.

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!

Continue reading

Next steps

Set up webhooks
Last updated: July 23, 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!