Skip to main content

Quick Start 🚀

info

To get access to the Xsolla Mobile SDK during Developer Preview phase, please fill out the form.

Let's start

important

Xsolla Mobile SDK is an evolution of the enterprise-level Xsolla SDK solution, previously designed for integration into large-scale projects from the ground up. It is widely used by mid-to-large scale developers and publishers.

This quick start guide will walk you through integrating Xsolla Mobile SDK to accept payments in your game. Using a pre-configured test project ID, we'll cover the essentials: setting up basic user authentication, importing SKUs, and processing a test payment. By the end, you'll have a functional payment system integrated into your game, demonstrating how Xsolla can streamline your monetization process. Let's get started and have your game accepting payments in just a few simple steps!

Install the SDK

During the Preview phase, please contact your Account Manager to get access to the Xsolla Mobile SDK.

  1. Open the Unity Editor.
  2. In the main menu, click Window > Package Manager.
  3. Add a package as a dependence:
    • Click the ➕ icon and select Add package from tarball.
    • Select the downloaded SDK package (.tgz).
    • Click Open and wait for the import to complete.

Configure the SDK

In Unity Editor:

  • Go to Window > Xsolla > MobileSDK > Edit Settings from the main menu

  • Go to Inspector panel

  • In the opened asset, set these pre-defined sample project properties below to their respective values:

    PropertyValue
    Project ID77640
    Login ID026201e3-7e40-11ea-a85b-42010aa80004

    tip

    The provided project and login IDs are predefined and can be used for quick test integrations.

  • Your settings asset should look similar to this:

    publisher account 6

  • Now, add these few lines to your scene initialization code, e.g. Start() method of a class that inherits from MonoBehaviour:

    public class YourSDKIntegrationBehaviour : MonoBehaviour, IDetailedStoreListener {
    public Start() {
    var settings = XsollaStoreClientSettingsAsset.Instance().settings;

    var configuration = XsollaStoreClientConfiguration.Builder.Create()
    .SetSettings(settings)
    .SetSandbox(true)
    .SetLogLevel(XsollaLogLevel.Debug)
    .Build();

    // ...
    }

    // ...
    }

Initialize the SDK

Now, when we have our configuration ready, it's time to move onto initialization of the SDK itself.

  • Make sure Unity InAppPurchasing plugin is already installed:

    info

    For information on how to install Unity InAppPurchasing plugin, refer to this page

  • Create the SDK module using the XsollaPurchasingModule.Builder with the configuration you prepared earlier as its parameter inside YourSDKIntegrationBehaviour's Start method:

    var module = XsollaPurchasingModule.Builder.Create()
    .SetConfiguration(configuration)
    .Build();
  • Feed the created SDK module into the ConfigurationBuilder and populate the returned instance with the SKUs pre-created for testing purposes:

    var configurationBuilder = ConfigurationBuilder.Instance(module)
    .AddProduct("key_1", ProductType.Consumable);
  • Register the SDK with the Unity's InAppPurchasing:

    UnityPurchasing.Initialize(this, configurationBuilder);

Make a Purchase

Once the SDK is fully initialized, a purchase can be made.

Modify the MonoBehavior used for configuration and initialization steps to also inherit from IDetailedStoreListener. And add the lines below to it:

public class YourSDKIntegrationBehaviour : MonoBehaviour, IDetailedStoreListener {
// ...

public void OnInitialized(IStoreController controller, IExtensionProvider extensions) {
controller.InitiatePurchase("key_1");
}

// ...

public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) {
if (args.purchasedProduct.definition.id == "key_1") {
Debug.Log("Successfully purchased 'key_1'");
}
return PurchaseProcessingResult.Complete;
}

// ...

Collect payment

The SDK relies on Xsolla Pay Station for secure payment collections.

These steps will take your through a test payment collection flow:

  • Choose the card payment method:

    quick start3

  • Use one of the test cards listed here and click Pay to confirm the payment:

    quick start3

  • Once the payment goes through, you'll see a confirmation:

    quick start3

What's next?

Congratulations! 🎉 You've successfully integrated Xsolla Mobile SDK and processed your first test payment. This achievement unlocks access to over 700 global payment methods and sets the foundation for integrating more Xsolla solutions, including our powerful Web Shop.

You've mastered the basics:

  • ✅ User authentication
  • ✅ SKU management
  • ✅ Secure payment processing

This is just the beginning of optimizing your game's monetization. Ready to explore more? Check out our documentation for advanced features and other Xsolla products to further boost your game's success!

important

The next thing you need to do is to create your own publisher account and setup a new project there.

note

You might also be interested in studying the extended examples provided for your convenience to get better understanding of the whole purchasing flow based on Xsolla Mobile SDK: