Set up selling items
You can sell items via the direct link, widget, or store UI.
Selling via direct link
The following link is used for opening the payment UI:
Copy
- 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
— 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 likeunit_name_drm_sku
.
- Payment UI style: theme (dark is the
dark
parameter, or light that is thedefault
parameter), size, and other parameters. Specify theui_settings
parameters in the URL and pass asettings.ui
JSON-object that has a Base64 encoding as a value. Example of the URL with UI settings:
Copy
- 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:
Copy
- 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:
Copy
- 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.Code for implementing the widget:
Copy
- 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
— 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 likeunit_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
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 Commerce 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 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 theWas this article helpful?
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
Don’t want to answer
Thank you for your feedback!
Continue reading
Next steps
Set up webhooksFound a typo or other text error? Select the text and press Ctrl+Enter.