Buy Button

Buy Button is a comprehensive solution for digital goods selling.

Note: If you are already using Xsolla products and want to integrate Buy Button, please contact your Account Manager.

How It Works

Step 1

Step 2

Step 3

User Flow

Integration Flow

To integrate Buy Button:

  1. Register an Xsolla Publisher Account.
  2. Create a project.
  3. Choose your monetization option(s).
  4. Choose the option for selling the items.
  5. Set up webhooks.

Note: This guide describes the minimum settings required to quick-start the solution. If you have any questions, please contact your Account Manager.

Creating a Project

  1. Go to Projects and click Create new project.
  2. In setup mode:
    1. Specify the webhook URL.
    2. Generate a secret key to sign project webhooks.

Monetization Options

Virtual Currency

The Virtual Currency option allows game developers to sell in-game currencies. Key features:

  • Sell packages of in-game currency
  • Run promotional campaigns
  • Manage in-game currency user balances
  • Auto-detect user currency and country

Setting Up

  1. Go to Virtual Currency settings and configure the following parameters:
    • Name
    • Price per unit
    • Image
  2. Create as many virtual currency packages as you need and set the following parameters for each of them:
    • Price
    • Image
  3. Turn on package display in Store.

Recipes

Our Recipes will help you try out some of the advanced features of the Virtual Currency:

Virtual Items

The Virtual Items option allows you to sell in-game content for real or virtual currencies. Key features:

  • Set prices in real and virtual currencies
  • Set up catalogs with one or several levels
  • Manage content access. For example, you can make a certain item available only to users who have reached a certain level, etc.
  • Configure brief and detailed item cards
  • Run promotional campaigns
  • Manage in-game currency user balances
  • Auto-detect user currency and country

Setting Up

  1. Go to Virtual Items settings.
  2. Fill the store catalog:
    1. Create item groups
    2. Create items, specifying the following for each of them:
      • One or more groups that the item should belong to
      • SKU
      • Name and short description
      • Prices in real and virtual currencies
      • Image
  3. Turn on group display in Store.

Recipes

Our Recipes will help you try out some of the advanced features of the Virtual Items:

Game Keys

The Game Keys solution allows partners to sell game keys, builds, and distribution packages right from their game’s website. This is done via the direct link, by the widget, or by the store UI that is integrated via the API methods. Key features:

  • Choose DRM platforms via which to distribute keys and distribution packages
  • Set different prices for different DRM platforms
  • Pre-orders

Setting Up

  1. Go to Store > Game Keys and click New package.
  2. Configure package parameters:
    • SKU - a unique identifier
    • Game title
  3. Choose DRM.
  4. Configure prices for the selected DRMs.
  5. Upload keys for the selected DRMs.

Recipes

Our Recipes let you try out some of the advanced features of the Game Keys:

Selling Items

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

Info: When you configure the direct link for selling game keys, the value of the YOUR-ITEM-TYPE parameter depends on the Store management methods of your project. If the Integrate new Store management methods 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:

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 with old Store management methods) or unit (for a project with new Store management methods)
    • 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:

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:

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:

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.

Info: When you configure the widget for selling game keys, the value of the YOUR-ITEM-TYPE parameter depends on the Store management methods of your project. If the Integrate new Store management methods toggle is set to On, you should pass the value of the parameter to the new methods.

Code for implementing the widget:

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

Authentication Settings

Both the authorized and unauthorized users can make purchases.

Not Authenticated Users

You can sell games and physical goods to users without authentication if you follow the rules below:
  • Use a direct link or widget without a token to sell one copy of the game.
  • Pass the unique user ID and email address to sell several copies of the game in a cart.
  • Use methods for fast purchases to sell one physical item without specified parameters.
  • Pass the unique user ID to sell several physical items in a cart.

You should use the unique user ID in the title as a number or line when calling the Store API methods (x-unauthorized-id parameter). The identifier is generated on the frontend side, for example via the identifier generation library.

The email address and other additional data (username and country code per ISO 3166-1 alpha-2) have the Base64 encoding and are passed in the title for the x-user parameter when calling the method for getting a payment token.

Example:

{
 "name": "John Smith" 
 "email": "test@test.com" 
 "country": "US" 
}

You can also pass the data to body or query in the object form.

Example:

"user": {
 "name": "John Smith" 
 "email": "test@test.com" 
 "country": "US"
}

Authenticated Users

There are the following options for authenticating users:

  1. If you integrated Xsolla Login, the requests are authenticated via the Xsolla Login JWT.
  2. If you have your own authentication system, the requests are authenticated via the Pay Station Access Token.

Setting up Authentication via Xsolla Login

  1. Follow the instructions to set up a project in Publisher Account.
  2. Implement the authentication methods callback: based on the JSON Web Token or OAuth 2.0 protocol.

If the user data is stored in the Xsolla storage, implement the following methods:

If the user data is stored in the PlayFab database, use the recipe for the PlayFab storage.

If you store user data in a custom storage, use the recipe for a custom storage.

Setting up Authentication via Pay Station Access Token

Authentication flow:

  1. Your client sends the authentication request to your server.
  2. Your server passes Merchant ID and API key to the Xsolla server and requests access_token.
  3. The Xsolla server sends access_token to your server.
  4. Your server sends access_token to your client.

Returned access_token is used as an authentication token to authenticate the requests sent by the game client.

Setting Up Webhooks

Implement the following webhooks:

Acknowledge the receipt of a webhook by responding with HTTP code 204 without a message body. You can read more about webhooks, including examples, in the API Reference.

Note: After setting up the webhooks, open Pay Station settings and set Checkout to On.

Promotional Options

Coupons

The Coupon feature enables partners to create a coupon campaign which includes coupon codes that can either be uploaded by the partner or generated in Publisher Account. Coupons can grant a user virtual currency, virtual items, or trial days for a subscription plan. Customize the number of redemptions and the expiration date (if any).

See recipe

Labels

The Labels feature lets partners affix Labels to virtual items and virtual currency package promotions. For example, "Best Value".

See recipe

Bonuses

The Bonus feature lets users receive a bonus item when they make a purchase. A bonus can be any of the following:

  • Virtual currency
  • Trial days for a subscription
  • Virtual item(s)
  • Game(s)
  • Physical goods (e.g. merchandise)

See recipe

Recipes

Our Recipes will help you try out some of the advanced features of the Buy Button:

Tutorials