Skip to main content

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:

SettingValueDefaultDescription
withSandboxEnabledbooleanfalseAre test payments enabled? If enabled, no real transactions. The project should not be in LIVE mode for the sandbox to work.
withLogLevelenum LogLevel (VERBOSE, DEBUG, INFO, WARN, ERROR)ERRORControls 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).
withSkipNonExistentProductsOnQuerybooleantrueDoes queryProductDetailsAsync() safely ignore any missing requested products on query or fail right away?
withDeferredAuthenticationEnabledbooleantrueControls whether the authentication is postponed until after it really becomes needed for the SDK functionality, potentially speeding up the initialization flow.
withDebugEnabledbooleanfalseEnables the debug mode (more logging, profiling, etc).
withLocaleOverrideLocaleInfonullA specific locale to use for pricing and formatting for returned products and Pay Station (automatic if null).
withFallbackToDeviceLocalebooleanfalseShall device's current locale be used if no override has been explicitly specified (otherwise it will be deduced automatically by Pay Station)?
withFetchPersonalizedProductsOnlybooleantrueReturn personalized products only; set to false for generic catalogs.
withUseGeoLocaleOnProductQuerybooleanfalseForce use of geo locale when querying products.
withRetryPoliciesRetryPoliciesnullOverride retry behavior globally or per operation (authentication, create order, query products, etc.).
withCollapseRestoredMultiUnitPurchasesbooleanfalseShould multiple owned units of the same SKU be returned as a single Purchase on restoration? See Purchase Restoration Settings below.
withProductCacheTtlMillisLong3600000How 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.
withMaxItemsPerProductRequestIntegernullHow 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.
withMaxParallelProductRequestsInteger4How 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.
withAllowBundlesAsInAppbooleanfalseAccept 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.
withAllowVirtualCurrencyAsInAppbooleanfalseThe 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):

SettingValueDefaultDescription
withDefaultRetryProfileOverrideRetryProfilenullFallback profile applied if an operation-specific profile is not provided.
withAuthenticateRetryProfileOverrideRetryProfilenullOverrides retries for authentication.
withCreateOrderRetryProfileOverrideRetryProfilenullOverrides retries for order creation.
withPendingOrderStatusQueryRetryProfileOverrideRetryProfilenullOverrides retries when polling pending order status.
withQueryProductsRetryProfileOverrideRetryProfilenullOverrides retries for product list queries.
withQueryPurchasesRetryProfileOverrideRetryProfilenullOverrides retries for purchase list queries.
withConsumePurchasesRetryProfileOverrideRetryProfilenullOverrides 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:

Fixed delay between attempts.

final RetryProfile retryProfile = RetryProfile.uniform(
PositiveInteger.create(6).getRightOrThrow(),
PositiveInteger.create(1000).getRightOrThrow()
);
ArgumentDescription
maxNumAttemptsPositive integer; total number of attempts allowed (initial try + retries).
intervalMillisFixed delay in milliseconds between attempts.
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​

final Config.Integration configIntegration = Config.Integration.forXsolla(
Config.Integration.Xsolla.Authentication.forAutoJWT(
ProjectId.parse(<your_project_id>).getRightOrThrow(),
LoginUuid.parse(<your_login_id>).getRightOrThrow()
)
);

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.

warning

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);
ConfigurationHoldingResult
falseUnder 100 unitsOne Purchase per unit, each with a quantity of 1
false100 units or moreA single Purchase carrying the full quantity
trueAny sizeAlways 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:

SettingValueDefaultDescription
withDefaultQueryPeriodMillisLong5000Amount of time between the consecutive event queries in milliseconds (-1 if disabled, null to use the default).
withQueryProfileIfExpectingPurchasesEventQueryProfilenullA 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).
withExternalFreePurchaseHandlingEnabledbooleanfalseShould 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:

SettingValueDefaultDescription
withRedirectUrlURLnullURL to redirect to when returning from Xsolla Pay Station.
withRedirectTimeoutSecsIntegernullAmount of time before Xsolla Pay Station automatically closes (if null, then uses the default value).
withRedirectButtonTextStringnullText on the 'return' link in Xsolla Pay Station.
withRedirectConditionIntegernullDetermines under what conditions automatic closure takes place (REDIRECT_CONDITION_DISABLED, REDIRECT_CONDITION_SUCCESS, REDIRECT_CONDITION_SUCCESS_OR_CANCELED, REDIRECT_CONDITION_ANY).
withThemeConfig.Payments.ThemenullDefines the visual aspect of Xsolla Pay Station (Theme.Light, Theme.Dark, Theme.Custom) β€” with no theme set, Pay Station picks size and style automatically.
withCloseButtonConfig.Payments.CloseButtonnullDefines the state of the close button in Xsolla Pay Station (not to be confused with the 'return' link; CloseButton.Hide, CloseButton.Show).
withActivityConfig.Payments.ActivitynullDetermines which approach is used for displaying Xsolla Pay Station (Activity.System, Activity.WebView, Activity.CustomTabs, Activity.TrustedWebActivity - for TWA see more information here).
withActivityOrientationLockIntegernullSpecifies 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).
withBuyButtonSolutionEnabledbooleanfalseEnables/disables the Buy Button Solution's state (see here for more information)
withEmailCollectionConsentOptInEnabledbooleanfalseEnable opt-in for collecting the user's email as part of the payment flow (for example, newsletter consent).
withInvokePurchasesUpdatedForMissingOrderIdbooleanfalseInvoke purchase callback even if order ID is missing (for order-id-less flows).
withShowLogoEnabledBooleannullControls visibility of the Xsolla logo in Pay Station. Pass true to show, false to hide, or null for default behavior.
withEventListenersEventListenersnullRegister listeners for Pay Station navigation events (page opened, loaded, closed). Use EventListeners builder to configure callbacks.
withDomainOverrideConfigDomainOverrideConfignullOverride default Pay Station domains for production and sandbox environments. Use DomainOverrideConfig builder to specify custom domains.
withCustomUserIdStringnullA 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.
withAttributionUserIdStringnullThe 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
withInstallSourceStringnullThe 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.
withQueryCancellationReasonEnabledbooleanfalseWhether to query for the reason a payment was cancelled when the purchase flow ends without completion.
withRedirectAppRelaunchbooleanfalseWhen 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.

InterfaceMethodFires when
IOpenedListeneronOpened()Pay Station activity has been started.
ILoadedListeneronLoaded()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).
ICompletedListeneronCompleted()Payment succeeded and onPurchasesUpdated was called with OK and a non-empty purchases list.
ICancelledListeneronCancelled()Flow ended with a USER_CANCELED response code (fires in addition to onPurchasesUpdated(USER_CANCELED, null) β€” does not replace it).
info

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:

SettingValueDefaultDescription
withGameEngineStringnullA custom game engine identifier or null for defaults.
withGameEngineVersionStringnullA 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.