The Pay2Play module allows game developers to sell PIN codes directly from a game's website. Users can access the store using the Pay2Play widget. The module has several integration options and allows developers to:
Xsolla Sandbox is a standalone environment that supports all features of the live environment, except real payments. You can access the Sandbox by sending "settings.mode" = "sandbox" within the access_data object. The JSON structure and parameters in access_data are the same as in the Token request.
To test a bank card payment:
Open the store in sandbox mode.
Choose the item to purchase.
Choose the Credit/debit cards group of payment methods.
Enter the bank card details and any values in the remaining fields. You can also specify incorrect details (card number, expiration date, or CVV) in order to generate an error.
The Pay2Play widget opens your store in a lightbox (on desktop screens) or a new window (on mobile and tablet screens). The widget automatically determines the type of device. To get the widget code, open module settings in your Publisher Account and go to the Publish tab. Copy the code of the desired widget and add it to your game’s website. We recommend using asynchronous loading.
Asynchronous loading example
HTML
<script>var access_data = {"settings":{"project_id":14004},"purchase":{"pin_codes":{"codes":[{"digital_content":"game_sku"}]}}};
var target_element = "#widget-example-element";
var s = document.createElement('script');
s.type = "text/javascript";
s.async = true;
s.src = "//static.xsolla.com/embed/pay2play/2.1.0/widget.min.js";
s.addEventListener('load', function(e){
var widgetInstance = XPay2PlayWidget.create(access_data,target_element);
}, false);
var head = document.getElementsByTagName('head')[0];
head.appendChild(s);
</script>
You can find the complete list of widget initialization parameters in the API Reference and its installation instructions on GitHub.
To integrate the store UI into your game, you will need an access token. An access token is a string that identifies the game, user and purchase parameters.
Xsolla API uses HTTP Basic Authentication. Provide your Merchant ID as the basic auth username and the API key as your password.
Set the value to "mode":"sandbox" to test the payment process.
In an HTTP POST request, you can use parameters for store UI. Request and response payloads are formatted as JSON.
Example Request
Below you can find sample code of how to get a token in PHP with the help of Xsolla PHP SDK. If you're using another programming language, please take a look at the CURL example by clicking on the CURL tab.
Xsolla sends the following webhooks to your project:
User Validation
Payment
Refund
To acknowledge that you received webhook notifications without any problem, your server should return a 204 HTTP status code without body. The full description of webhook mechanism with samples is described in detail in the API Reference.
Xsolla Sandbox is a standalone environment that supports all features of the live environment, except real payments. You can access the Sandbox by sending "mode" = "sandbox" when getting the token.
To test a bank card payment:
Open the store in sandbox mode.
Choose the item to purchase.
Click Credit/debit cards.
Enter the bank card details and any values in the remaining fields. You can also specify incorrect details (card number, expiration date, or CVV) in order to generate an error.
The Pay2Play widget opens your store in a lightbox (on desktop screens) or a new window (on mobile and tablet screens). The widget automatically determines the type of device. To get the widget code, open module settings in your Publisher Account and go to the Publish tab. Copy the code of the desired widget and add it to your game’s website. We recommend using asynchronous loading.
Asynchronous loading example
HTML
<script>var access_data = {"settings":{"project_id":14004},"purchase":{"pin_codes":{"codes":[{"digital_content":"game_sku"}]}}};
var target_element = "#widget-example-element";
var s = document.createElement('script');
s.type = "text/javascript";
s.async = true;
s.src = "//static.xsolla.com/embed/pay2play/2.1.0/widget.min.js";
s.addEventListener('load', function(e){
var widgetInstance = XPay2PlayWidget.create(access_data,target_element);
}, false);
var head = document.getElementsByTagName('head')[0];
head.appendChild(s);
</script>
You can find the complete list of widget initialization parameters in the API Reference and its installation instructions on GitHub.
A project can receive tips from each purchase. To enable the option, open Pay2Play price settings and set Use Tips in the Pay2Play widget to On. Three pre-defined tip amounts are available for each currency you add.
The user will be able to choose the tip amount before entering the store. The tips will be added to the purchase price.
You can limit the number of PIN codes that can be sold for a project. You will get two email notifications: one when 100 or fewer PIN codes are left, and another one when none are. If the limit is exceeded, users won’t be able to execute payment.
The Pay2Play module allows you to configure regional restrictions on PIN code sales. In particular, you can:
Set different prices for individual countries or groups of countries;
Prohibit sales in certain countries.
Once you have properly configured the project, a user trying to purchase a PIN code in a restricted country will see a corresponding warning. In countries for which PIN code sales are prohibited, payment is not possible.
To enable the feature, contact your account manager. We will need the following information for each platform that you want to be subject to regional restrictions:
Restriction type:
Activation: A PIN code can be activated in certain countries only.
Launch: A PIN code can be activated in any country, but the game can be launched in certain countries only;
Activation and launch: A PIN code can be activated and the game can be launched in certain countries only.
List of country groups with different PIN code prices.
Settings for each group of countries:
Group name.
SKU — a unique group identifier.
List of prices in different currencies. Make sure to include the price in the default currency set in module settings.
List of countries within each group.
List of countries where PIN codes are disabled (if any).
For any single platform, a country can belong either to a different-price group or to the preorders-disabled group. If a country is not listed in any of the groups, PIN codes can be sold without any restrictions, at the prices set in default module settings.
Important! If PIN code activation and game launching are made on your or the DRM platform’s side, then, on the release date, make sure to upload PIN codes with regional restrictions already configured.