Set up selling items

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

Note:
When you configure the direct link for selling game keys, the value of the YOUR-ITEM-TYPE parameter depends on the integration settings of your project. If the Integrate Commerce API toggle is set to ON, you should pass the value of the parameter to the new methods.

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 — digital_content for a project where Integrate Commerce API toggle is set to OFF or unit for a project where Integrate Commerce API toggle is set to ON
    • physical goods — physical_good
    • virtual item — virtual_item
    • virtual currency — virtual_currency
    • virtual currency package or bundle — bundle
  • YOUR-PROJECT-ID — your project ID in Publisher Account (your project > Project settings > General settings > Project ID)
  • YOUR-ITEM-SKU — item SKU

You can also pass the following additional parameters in the link:

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

Note:
When you configure the widget for selling game keys, the value of the YOUR-ITEM-TYPE parameter depends on the integration settings of your project. If the Integrate Commerce API toggle is set to ON, you should pass the value of the parameter to the new methods.

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 — digital_content (for a project with old management methods) or unit (for a project with new management methods)
    • physical goods — physical_good
    • virtual item — virtual_item
    • virtual currency — virtual_currency
    • virtual currency package or bundle — bundle
  • YOUR-ITEM-SKU — item 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 Store 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 Store API

You can create a frontend part of a store by integrating the Store 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 Store 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.

Continue reading