CONFIGURATION
Configuration - Android
The Xsolla Mobile SDK for Android splits its configuration into four major settings subcategories, each represented by its own specific class:
- Common - settings that define SDK's generic properties.
- Integration - settings that define how the SDK integrates with Xsolla services.
- Authentication - settings that define how the SDK authenticates with Xsolla services.
- Events - settings that define how the SDK works with the Xsolla Events API.
- Payments - settings that define Xsolla Pay Station behavior (appearance, redirects, etc).
- Analytics - settings that define the SDK's analytics related meta-data.
To create a Config for SDK from all of the subcategories, use the following snippet:
final Config config = new Config(
configCommon,
configIntegration,
configPayments,
configAnalytics
);
Commonβ
Call Config.Common.getDefault() for default configuration. Here's an example best suited for testing:
final Config.Common configCommon = Config.Common.getDefault()
.withSandboxEnabled(true)
.withLogLevel(LogLevel.VERBOSE)
.withDebugEnabled(true);
Below is a list of all settings supported by Config.Common:
| Setting | Value | Default | Description |
|---|---|---|---|
| withSandboxEnabled | boolean | false | Are test payments enabled? If enabled, no real transactions. The project should not be in LIVE mode for the sandbox to work. |
| withLogLevel | enum LogLevel (VERBOSE, DEBUG, INFO, WARN, ERROR) | ERROR | Controls the verbosity of the logging (use DEBUG if encountered any difficulties and would like to get more information on what's going under the hood). |
| withSkipNonExistentProductsOnQuery | boolean | true | Does queryProductDetailsAsync() safely ignore any missing requested products on query or fail right away? |
| withDeferredAuthenticationEnabled | boolean | true | Controls whether the authentication is postponed until after it really becomes needed for the SDK functionality, potentially speeding up the initialization flow. |
| withDebugEnabled | boolean | false | Enables the debug mode (more logging, profiling, etc). |
| withLocaleOverride | LocaleInfo | null | A specific locale to use for pricing and formatting for returned products and Pay Station (automatic if null). |
| withFallbackToDeviceLocale | boolean | false | Shall device's current locale be used if no override has been explicitly specified (otherwise it will be deduced automatically by Pay Station)? |
| withFetchPersonalizedProductsOnly | boolean | true | Return personalized products only; set to false for generic catalogs. |
| withUseGeoLocaleOnProductQuery | boolean | false | Force use of geo locale when querying products. |
| withRetryPolicies | RetryPolicies | null | Override retry behavior globally or per operation (authentication, create order, query products, etc.). |
| withCollapseRestoredMultiUnitPurchases | boolean | false | Should multiple owned units of the same SKU be returned as a single Purchase on restoration? See Purchase Restoration Settings below. |
| withProductCacheTtlMillis | Long | 3600000 | How long a cached product stays fresh for queryProductDetailsAsync(), in milliseconds (1 hour by default), measured from when it was cached. null or a non-positive value never expires within the process β restarting the app is then the only thing that bounds staleness. |
| withMaxItemsPerProductRequest | Integer | null | How many SKUs queryProductDetailsAsync() requests per call when fetching products it hasn't cached yet. null uses the backend page cap of 50; values are clamped to 1β50, since the cap is a backend limit rather than a tunable. |
| withMaxParallelProductRequests | Integer | 4 | How many product-fetch requests may be in flight at once for a single queryProductDetailsAsync(), to stay clear of the backend's rate limit. Set 1 to fetch sequentially; null or a non-positive value dispatches every chunk at once. |
| withAllowBundlesAsInApp | boolean | false | Accept a SKU that resolves to a bundle when it was requested as INAPP, instead of reporting it as unavailable for the requested type. Lets a caller that doesn't distinguish the two fetch both in one query. |
| withAllowVirtualCurrencyAsInApp | boolean | false | The same relaxation for a SKU that resolves to virtual currency on an INAPP request. |
Both relaxations are narrow and one-directional: only that one type is accepted for an INAPP request, and SUBS or any other mismatch still fails. The product you get back also reports its real type β getProductType() returns bundle or virtual_currency, never inapp β so anything downstream that branches on product type has to tolerate that.
Retry policies and profilesβ
Retry policy overrides (per operation):
| Setting | Value | Default | Description |
|---|---|---|---|
| withDefaultRetryProfileOverride | RetryProfile | null | Fallback profile applied if an operation-specific profile is not provided. |
| withAuthenticateRetryProfileOverride | RetryProfile | null | Overrides retries for authentication. |
| withCreateOrderRetryProfileOverride | RetryProfile | null | Overrides retries for order creation. |
| withPendingOrderStatusQueryRetryProfileOverride | RetryProfile | null | Overrides retries when polling pending order status. |
| withQueryProductsRetryProfileOverride | RetryProfile | null | Overrides retries for product list queries. |
| withQueryPurchasesRetryProfileOverride | RetryProfile | null | Overrides retries for purchase list queries. |
| withConsumePurchasesRetryProfileOverride | RetryProfile | null | Overrides retries for purchase consumption. |
null here doesn't mean "no retries" β it means no override, and the operation falls back to the built-in profile: a uniform 750Β ms delay, up to 12 attempts. Set an override only to depart from that.
Use RetryProfile variants to build overrides for specific operations or a global default:
- Uniform
- Exponential backoff
Fixed delay between attempts.
final RetryProfile retryProfile = RetryProfile.uniform(
PositiveInteger.create(6).getRightOrThrow(),
PositiveInteger.create(1000).getRightOrThrow()
);
| Argument | Description |
|---|---|
maxNumAttempts | Positive integer; total number of attempts allowed (initial try + retries). |
intervalMillis | Fixed delay in milliseconds between attempts. |
Delay grows exponentially from the base interval, with optional caps and jitter.
final RetryProfile retryProfile = RetryProfile.exponentialBackout(
PositiveInteger.create(5).getRightOrThrow(),
PositiveInteger.create(500).getRightOrThrow(),
PositiveInteger.create(4000).getRightOrThrow(),
null // optional jitter cap
);
| Argument | Description |
|---|---|
maxNumAttempts | Positive integer; total number of attempts allowed (initial try + retries). |
baseIntervalMillis | Initial delay in milliseconds; subsequent attempts grow exponentially from this base. |
maxIntervalMillis (optional) | Cap for the backoff delay in milliseconds; if omitted, delay can grow until attempts are exhausted. |
maxRandomExtraDelayMillis (optional) | Adds up to this many milliseconds of jitter to each backoff delay; null to disable jitter. |
final RetryPolicies retryPolicies = RetryPolicies.getDefault()
.withDefaultRetryProfileOverride(retryProfile) // pick from a tab above
.withAuthenticateRetryProfileOverride(retryProfile);
final Config.Common configCommon = Config.Common.getDefault()
.withRetryPolicies(retryPolicies);
Integrationβ
Authenticationβ
- Device ID
- Custom Login Token
- OAuth2
- Social Access Token
final Config.Integration configIntegration = Config.Integration.forXsolla(
Config.Integration.Xsolla.Authentication.forAutoJWT(
ProjectId.parse(<your_project_id>).getRightOrThrow(),
LoginUuid.parse(<your_login_id>).getRightOrThrow()
)
);
Authenticates using a custom login JWT (must be valid). Useful for situations when JWT is generated or acquired externally (e.g. using the app's backend or services like Xsolla Login, etc) and fed into the SDK.
final Config.Integration configIntegration = Config.Integration.forXsolla(
Config.Integration.Xsolla.Authentication.forJWT(
ProjectId.parse(<your_project_id>).getRightOrThrow(),
JWT.parse(<jwt>).getRightOrThrow()
)
);
With manual JWT token updating:
If your JWT tokens expire and need to be refreshed after the billing client is connected, use the JWTRefresher parameter:
final JWTRefresher jwtRefresher = new JWTRefresher();
final Config.Integration configIntegration = Config.Integration.forXsolla(
Config.Integration.Xsolla.Authentication.forJWT(
ProjectId.parse(<your_project_id>).getRightOrThrow(),
JWT.parse(<jwt>).getRightOrThrow(),
jwtRefresher
)
);
// Later, when you need to update the token:
jwtRefresher.update(JWT.parse(<new_jwt>).getRightOrThrow());
Authenticates using OAuth2.
final Config.Integration configIntegration = Config.Integration.forXsolla(
Config.Integration.Xsolla.Authentication.forOAuth2(
ProjectId.parse(<your_project_id>).getRightOrThrow(),
LoginUuid.parse(<your_login_id>).getRightOrThrow(),
OAuth2ClientId.parse(<oauth2_client_id>).getRightOrThrow()
)
);
Authenticates using a social access token received from a 3rd-party provider.
First of all, for this approach to work you'll need to figure out which social provider you're going to work with and whether it's supported by Xsolla authentication services:
All supported social providers names
- naver
- baidu
- amazon
- apple
- battlenet
- discord
- github
- kakao
- mailru
- microsoft
- msn
- ok
- paypal
- psn
- steam
- twitch
- vimeo
- vk
- yahoo
- yandex
- youtube
- xbox
- babka
- epicgames
LoginUtils.SocialProvider holds a set of predefined social provider values for convenience. To get a matching instance from a string, use LoginUtils.SocialProvider.parse("<social-provider-name>").
final LoginUtils.SocialProvider socialProvider = LoginUtils.SocialProvider.EPICGAMES;
final String socialAccessToken = "<social-access-token>";
Overall, there are two paths for this approach:
- With OAuth2 (recommended)
final Config.Integration configIntegration = Config.Integration.forXsolla(
Config.Integration.Xsolla.Authentication.forSocial(
ProjectId.parse(<your_project_id>).getRightOrThrow(),
LoginUuid.parse(<your_login_id>).getRightOrThrow(),
OAuth2ClientId.parse(<oauth2_client_id>).getRightOrThrow(),
socialProvider,
socialAccessToken
)
); - Without OAuth2
final Config.Integration configIntegration = Config.Integration.forXsolla(
Config.Integration.Xsolla.Authentication.forSocial(
ProjectId.parse(<your_project_id>).getRightOrThrow(),
LoginUuid.parse(<your_login_id>).getRightOrThrow(),
socialProvider,
socialAccessToken
)
);
Information on how to obtain Product ID and Login ID can be found here.
You can also supply a Xsolla Login β (https://xsolla.com/login) token via the Custom Login Token approach.
Purchase Restoration Settingsβ
Restoration recovers purchases a player already made β after a reinstall, a new device, or simply because the client never confirmed the original transaction β so they aren't charged twice for the same item.
Which backend the SDK restores from is decided by two settings β one in Publisher Account, one in the SDK config below. A project restores from Inventory API until both are switched over to Events API. For the exact combinations, what each backend records, and what switching a live project involves, see Selecting a mode.
Restoring from Inventory API does not give you real order or invoice identifiers.
The inventory holds what a player currently owns, with no transaction behind it, so the SDK makes those identifiers up on the device β they don't correspond to anything in Publisher Account or an order lookup. If your backend, support tools, or fraud checks need to match a restored purchase to a real Xsolla order, that requires Events API. See Purchase flow β Restored purchases for the field-by-field breakdown.
Units per restored purchaseβ
An inventory row reports a SKU and a quantity, and by default the SDK splits that row into one single-unit Purchase per owned unit. That breaks down when a catalog models in-game currency as a per-unit virtual item: a single SKU can then report hundreds of thousands of owned units in one restore, and allocating a separate Purchase for each of them can put real pressure on memory.
withCollapseRestoredMultiUnitPurchases (on Config.Common, see Common above) returns the row as a single Purchase carrying the full quantity instead. It defaults to false:
final Config.Common configCommon = Config.Common.getDefault()
.withCollapseRestoredMultiUnitPurchases(true);
| Configuration | Holding | Result |
|---|---|---|
false | Under 100 units | One Purchase per unit, each with a quantity of 1 |
false | 100 units or more | A single Purchase carrying the full quantity |
true | Any size | Always a single Purchase carrying the full quantity |
That 100-unit threshold is a hard ceiling guarding against the same case. It isn't configurable, and it applies even with the flag off β so a holding that grows past it changes shape on its own. Handle both shapes if a SKU's holdings can realistically get that large.
Consuming a collapsed Purchase drains all of its units in a single consumeAsync() call. Splitting is otherwise a presentation convenience only: the inventory reports an aggregate quantity per SKU, so the resulting objects carry no per-payment identity β see Inventory API vs. Events API.
Xsolla Events APIβ
The Xsolla Events API serves as an alternative to webhook-based integrations, where the integratorβs backend usually handles most of the logic (purchase validation, awarding, etc.). Instead of sending webhooks directly, the API intercepts them and stores their payloads in a remote queue managed by Xsolla. This approach enables serverless integrations for projects that lack backend capacity or donβt require one, yet still prefer handling the entire transaction flow directly from the app.
Supplying an Events config also switches restoration over to Events API, so restored purchases carry the real order and invoice IDs from the original Xsolla order β see Purchase Restoration Settings above.
To enable it, open your project in Publisher Account, go to Project settings > Integration settings, select Use API and click Save. See Events API in Publisher Account for details.
Opting for the Xsolla Events API disables your projectβs webhooks β you cannot use both simultaneously.
Below is the minimal events configuration required to enable the functionality in SDK:
final Config.Integration.Xsolla.Events configEvents =
Config.Integration.Events
.newBuilder()
.build()
If you would like to listen to incoming events, assign an optional custom event listener using Events.Builder.withEventListener method:
final Config.Integration.Xsolla.Events configEvents =
Config.Integration.Events
.newBuilder()
.withEventListener(event -> {
// Don't consume the event (mark as processed on the queue).
return false;
})
.build()
Now, assign the events config to the integration config:
final Config.Integration configIntegration =
Config.Integration
.forXsolla(
// ...your authentication configuration
)
.withEvents(configEvents);
Below is the list of advanced Events API related settings:
| Setting | Value | Default | Description |
|---|---|---|---|
| withDefaultQueryPeriodMillis | Long | 5000 | Amount of time between the consecutive event queries in milliseconds (-1 if disabled, null to use the default). |
| withQueryProfileIfExpectingPurchases | EventQueryProfile | null | A specific query profile to apply when expecting a purchase (e.g. just completed a purchasing flow and waiting for a confirmation and want to do an accelerated querying for a limited amount of time). |
| withExternalFreePurchaseHandlingEnabled | boolean | false | Should external purchase events that originated by claiming a free item be handled? |
Paymentsβ
Call Config.Payments.getDefault() for default configuration. Here's an example that forces the close button to appear in Xsolla Pay Station:
final Config.Payments configPayments = Config.Payments.getDefault()
.withCloseButton(Config.Payments.CloseButton.show());
Below is a list of all settings supported by Config.Payments:
| Setting | Value | Default | Description |
|---|---|---|---|
| withRedirectUrl | URL | null | URL to redirect to when returning from Xsolla Pay Station. |
| withRedirectTimeoutSecs | Integer | null | Amount of time before Xsolla Pay Station automatically closes (if null, then uses the default value). |
| withRedirectButtonText | String | null | Text on the 'return' link in Xsolla Pay Station. |
| withRedirectCondition | Integer | null | Determines under what conditions automatic closure takes place (REDIRECT_CONDITION_DISABLED, REDIRECT_CONDITION_SUCCESS, REDIRECT_CONDITION_SUCCESS_OR_CANCELED, REDIRECT_CONDITION_ANY). |
| withTheme | Config.Payments.Theme | null | Defines the visual aspect of Xsolla Pay Station (Theme.Light, Theme.Dark, Theme.Custom) β with no theme set, Pay Station picks size and style automatically. |
| withCloseButton | Config.Payments.CloseButton | null | Defines the state of the close button in Xsolla Pay Station (not to be confused with the 'return' link; CloseButton.Hide, CloseButton.Show). |
| withActivity | Config.Payments.Activity | null | Determines which approach is used for displaying Xsolla Pay Station (Activity.System, Activity.WebView, Activity.CustomTabs, Activity.TrustedWebActivity - for TWA see more information here). |
| withActivityOrientationLock | Integer | null | Specifies a desired screen orientation to lock to, when displaying Xsolla Pay Station (availability depends on the chosen Config.Payments.Activity; ACTIVITY_ORIENTATION_LOCK_PORTRAIT, ACTIVITY_ORIENTATION_LOCK_LANDSCAPE). |
| withBuyButtonSolutionEnabled | boolean | false | Enables/disables the Buy Button Solution's state (see here for more information) |
| withEmailCollectionConsentOptInEnabled | boolean | false | Enable opt-in for collecting the user's email as part of the payment flow (for example, newsletter consent). |
| withInvokePurchasesUpdatedForMissingOrderId | boolean | false | Invoke purchase callback even if order ID is missing (for order-id-less flows). |
| withShowLogoEnabled | Boolean | null | Controls visibility of the Xsolla logo in Pay Station. Pass true to show, false to hide, or null for default behavior. |
| withEventListeners | EventListeners | null | Register listeners for Pay Station navigation events (page opened, loaded, closed). Use EventListeners builder to configure callbacks. |
| withDomainOverrideConfig | DomainOverrideConfig | null | Override default Pay Station domains for production and sandbox environments. Use DomainOverrideConfig builder to specify custom domains. |
| withCustomUserId | String | null | A custom user identifier to associate with the payment session in Pay Station (null to omit). Sent as custom_parameters.custom_user_id and returned in purchase webhooks; not used for attribution β see withAttributionUserId. |
| withAttributionUserId | String | null | The ID that purchase events reported to attribution platforms (AppsFlyer, Adjust, etc.) are keyed on, sent to Pay Station as custom_parameters.custom_id. It must equal the customer user ID your attribution SDK reports, or purchases won't match up with that user. With null, events are matched on the user ID in the payment token, which by default is the player's Xsolla Login user ID.1 |
| withInstallSource | String | null | The channel your app was distributed through, sent with the order as user.mobile_app.install_source in place of the one detected from the OS installer. Use it for builds distributed outside an app store, such as an APK downloaded from your website, where the OS reports the browser, the system package installer or no installer. The value is trimmed and otherwise sent as is; a blank value counts as unset. With null, the detected value is sent: google_play, aptoide, epic_games_store, or the installer's package name β see here. |
| withQueryCancellationReasonEnabled | boolean | false | Whether to query for the reason a payment was cancelled when the purchase flow ends without completion. |
| withRedirectAppRelaunch | boolean | false | When the app is killed during a payment flow in an external browser, enables the return-to-app button in Pay Station to relaunch the app instead of silently failing. |
1 If your project authenticates players through server-side custom ID login or PlayFab, or maps the user ID to a custom JWT claim, the payment token carries that value instead of the Login user ID. Call withAttributionUserId, or purchase events won't match your attribution platform.
Custom Tabs / Trusted Web Activity provider controlsβ
For Custom Tabs and Trusted Web Activity flows, control which browser providers are allowed and their priority:
final Config.Payments configPayments = Config.Payments.getDefault()
.withActivity(Config.Payments.Activity.forCustomTabs())
.withEmailCollectionConsentOptInEnabled(true)
.withActivity(
Config.Payments.Activity.forCustomTabs()
.withBlacklistedProviders(Set.of("com.android.chrome"))
.withInternalProviderBlacklistEnabled(true)
.withBlacklistedTWAProviders(Set.of("com.vendor.browser"))
.withInternalTWAProviderBlacklistEnabled(true)
.withProviderWeights(Map.of("com.google.android.apps.chrome", 2.0f))
.withFallbackToFirstAvailableTWAProvider(true)
);
Buy Button Solutionβ
The Buy Button Solution provides a complete, native payment experience with minimal integration effort. This approach handles the entire payment flow within your app using Xsolla's optimized UI components.
When to use Buy Button Solution:
- You want a fully native integration
- You need 1,000+ payment methods out of the box
- You prefer Xsolla to manage the payment UI
- You want automatic regional compliance
To enable the Buy Button Solution for your payments (works with default flows only), use the snippet below:
final Config.Payments configPayments =
Config.Payments.getDefault()
.withBuyButtonSolutionEnabled(true);
Event Listenersβ
EventListeners is an optional, immutable callback container that lets you hook into Pay Station UI lifecycle events without subclassing or modifying the billing flow. Attach it to your payments config via .withEventListeners(...).
All callbacks are dispatched on the main thread β safe to update UI directly.
| Interface | Method | Fires when |
|---|---|---|
| IOpenedListener | onOpened() | Pay Station activity has been started. |
| ILoadedListener | onLoaded() | WebView loading finishes (fired for successful load, failed load, and aborted load alike β the SDK does not distinguish between these outcomes at the EventListeners level). |
| ICompletedListener | onCompleted() | Payment succeeded and onPurchasesUpdated was called with OK and a non-empty purchases list. |
| ICancelledListener | onCancelled() | Flow ended with a USER_CANCELED response code (fires in addition to onPurchasesUpdated(USER_CANCELED, null) β does not replace it). |
For the SKU-based flow, onCompleted only fires if the purchases list is non-empty. Orders with no valid order ID on Xsolla's side are silently skipped.
Build an EventListeners instance using the copy-on-write builder β each with* call returns a new instance. All listeners are optional; unset listeners are simply not called. Passing null to .withEventListeners(...) disables all listeners.
final EventListeners listeners = EventListeners.getDefault()
.withOpenedListener(() -> { /* Pay Station opened */ })
.withLoadedListener(() -> { /* Pay Station loaded */ })
.withCompletedListener(() -> { /* payment completed */ })
.withCancelledListener(() -> { /* payment cancelled */ });
final Config.Payments configPayments = Config.Payments.getDefault()
.withEventListeners(listeners);
Analyticsβ
Analytics configuration allows you to pass metadata to the SDK that Xsolla can use for internal analytics and reporting. While not strictly required, it can help improve visibility into app performance, user behavior, and transaction flows β and may assist in diagnosing or resolving issues more efficiently.
final Config.Analytics configAnalytics =
Config.Analytics.getDefault()
.withGameEngine("<game-engine-identifier>")
.withGameEngineVersion("<game-engine-version>">);
Below is a list of all settings supported by Config.Analytics:
| Setting | Value | Default | Description |
|---|---|---|---|
| withGameEngine | String | null | A custom game engine identifier or null for defaults. |
| withGameEngineVersion | String | null | A custom game engine version or null for defaults. |
Before configuring analytics in the SDK, contact your integration manager to confirm whether it's viable for your integration.
Testing purchase flow in sandbox modeβ
See here for more details on how to enable the sandbox mode and avoid spending real money while testing the integration.