Set up selling items
You can sell items via the direct link, widget, or store UI.
Selling via direct link
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:
- curl
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 orunit for a project where IntegrateCommerce API toggle is set to ON - physical goods — physical_good
- virtual item — virtual_item
- virtual currency — virtual_currency
- virtual currency package or bundle — bundle
- game — digital_content for a project where Integrate
- 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:
- curl
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:
- curl
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:
- curl
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:
- curl
<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
- game — digital_content (for a project with old management methods) or
- 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
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 theBasing on Store API
You can create a frontend part of a store by integrating the- Getting the lists of virtual items, virtual currency packages and games.
- Purchasing items:
- fast purchase of one item. A token for opening the payment UI will be passed to the response.
- buying several items:
- adding an item to the cart
- getting the list of items in the cart
- paying for the items in the cart. A token for opening the payment UI will be passed to the response
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 theWas this article helpful?
Thank you for your feedback!
We'll review your message and use it to help us improve your experience.