Skip to content

Latest commit

 

History

25 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xsolla Mobile SDK for Android

License Latest release Java 11+ Android API 24+ Gradle compatible

Pre-built Android SDK for integrating in-game payments into your app via Xsolla Pay Station.

SDK Explorer

See exactly how payments work before writing a single line of code. The SDK Explorer lets you walk through authentication, catalog loading, purchasing, and finalization — all in an interactive environment.

SDK Explorer — interactive demo of Xsolla Mobile SDK payment flow

Integrate Now →

Essential Links

Overview

Xsolla Mobile SDK provides a Google Play Billing-compatible API for in-game purchases via Xsolla Pay Station. It mirrors Google's Billing Library patterns (BillingClient, ProductDetails, Purchase) so integration feels familiar to Android developers.

Key features:

  • 1000+ payment methods across 200+ geographies
  • 130+ currencies including local and alternative payment methods
  • Built-in anti-fraud protection
  • 25+ languages supported out of the box
  • Player authentication (Xsolla Login widget, social login, custom tokens)
  • Product catalog and virtual items
  • Buy Button and Web Shop integration

Requirements

  • Android API 24+
  • Java 11+

Installation

Add the Xsolla Maven repository to your settings.gradle:

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()

        maven {
            url "https://raw.githubusercontent.com/xsolla/xsolla-sdk-android/main"
        }
    }
}

Then add the dependency in your module's build.gradle:

dependencies {
    implementation 'com.xsolla.android:mobile:3.0.52'
}

Quick Start

1. Connect

Configure the SDK with your project credentials, set up a purchase listener (see step 4), and establish a billing connection:

import com.xsolla.android.mobile.*;

int PROJECT_ID = 77640;
String LOGIN_ID = "026201e3-7e40-11ea-a85b-42010aa80004";

Config config = new Config(
    Config.Common.getDefault()
        .withSandboxEnabled(true),
    Config.Integration.forXsolla(
        Config.Integration.Xsolla.Authentication.forAutoJWT(
            ProjectId.parse(PROJECT_ID).getRightOrThrow(),
            LoginUuid.parse(LOGIN_ID).getRightOrThrow()
        )
    ),
    Config.Payments.getDefault(),
    Config.Analytics.getDefault()
);

BillingClient billingClient = BillingClient.newBuilder(context)
    .setListener(purchasesUpdatedListener)
    .setConfig(config)
    .build();

billingClient.startConnection(new BillingClientStateListener() {
    @Override
    public void onBillingSetupFinished(BillingResult billingResult) {
        if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
            // Ready to query products and make purchases
        }
    }

    @Override
    public void onBillingServiceDisconnected() {
        // Handle reconnection
    }
});

2. Load Catalog

Query your product catalog by SKU:

List<QueryProductDetailsParams.Product> productList = Arrays.asList(
    QueryProductDetailsParams.Product.newBuilder()
        .setProductId("com.xsolla.crystals.10")
        .setProductType(BillingClient.ProductType.INAPP)
        .build()
    // ...more products
);

QueryProductDetailsParams params = QueryProductDetailsParams.newBuilder()
    .setProductList(productList)
    .build();

billingClient.queryProductDetailsAsync(params, (billingResult, productDetailsList) -> {
    if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
        // Store `productDetailsList` and use it to launch purchases (see step 3)
    }
});

3. Purchase

Use the product from your catalog to launch a purchase via Pay Station:

// Use from `productDetailsList` (see step 2)
ProductDetails product = productDetailsList.get(0);

BillingFlowParams flowParams = BillingFlowParams.newBuilder()
    .setProductDetailsParamsList(Collections.singletonList(
        BillingFlowParams.ProductDetailsParams.newBuilder()
            .setProductDetails(product)
            .build()
    ))
    .build();

billingClient.launchBillingFlow(activity, flowParams);

4. Finalize

Handle completed transactions in your PurchasesUpdatedListener and consume each purchase:

PurchasesUpdatedListener purchasesUpdatedListener = (billingResult, purchases) -> {
    if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && purchases != null) {
        for (Purchase purchase : purchases) {
            // Award the product to the user, then consume
            ConsumeParams consumeParams = ConsumeParams.newBuilder()
                .setPurchaseToken(purchase.getPurchaseToken())
                .build();

            billingClient.consumeAsync(consumeParams, (result, purchaseToken) -> {
                // Purchase consumed
            });
        }
    }
};

For the full integration guide, see the SDK Documentation.

Support

License

Apache 2.0 License. See LICENSE.

About

Official Xsolla SDK for Android. Built for mobile-first game development with native Kotlin and Java components that follow Android platform conventions throughout. Docs: https://developers.xsolla.com/sdk/

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors