Pre-built Android SDK for integrating in-game payments into your app via Xsolla Pay Station.
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
- SDK Documentation — full integration guide
- Demo App — sample project
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
- Android API 24+
- Java 11+
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.35'
}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
}
});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)
}
});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);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.
