CONFIGURATION
Configuration
To Configure SDk please use following code:
- C#
- C++
var settings = XsollaStoreClientSettings.Builder.Create()
.SetProjectId("< your_project_id >")
.SetLoginId("< your_login_id >")
.SetRestorePurchasesOnInit(true)
.SetWebViewType(XsollaStoreClientSettings.WebViewType.Auto)
.SetWebViewOrientationLock(XsollaStoreClientSettings.OrientationLock.Auto)
.SetUIThemeSize(XsollaStoreClientSettings.ThemeSize.Auto)
.SetUIThemeStyle(XsollaStoreClientSettings.ThemeStyle.Auto)
.SetUICustomTheme("")
.SetUseCloseButton(XsollaStoreClientSettings.CloseButton.Auto)
.SetUIControlTintColor(Color.clear)
.SetUIBarTintColor(Color.clear)
.SetRedirectUrl("")
.SetRedirectButtonText("")
.SetRedirectDelay(6)
.Build();
auto settings = CXsollaClientSettings::Create();
settings->SetProjectId("< your_project_id >");
settings->SetLoginId("< your_login_id >");
Eventsβ
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.
Restoring through the Events API also gives you the order identifier from the original Xsolla purchase, so you can match a restored purchase against your own records. Inventory-backed restoration has no order to reference.
Opting for the Xsolla Events API disables your project's webhooks. In other words, you cannot simultaneously handle webhooks on your backend and use the Events API in your app.
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.
Below is the minimal events configuration required to enable the events functionality in the SDK:
- C#
- C++
var settings = XsollaStoreClientSettings.Builder.Create()
//..
.SetWebhooksMode(XsollaStoreClientSettings.WebhooksMode.EventsApi)
.Build();
auto settings = CXsollaClientSettings::Create();
//..
settings->SetWebhooksMode(CXsollaClientSettings::WebhooksMode::EventsApi);
For additional information, see the webhooks page.
Build configuration from the settingsβ
- C#
- C++
var configuration = XsollaStoreClientConfiguration.Builder.Create()
// Set the settings object you've acquired in previous step here..
.SetSettings(settings)
.SetSandbox(true)
.SetLogLevel(XsollaLogLevel.Debug)
.Build();
auto configuration = CXsollaClientConfiguration::Create();
configuration->SetSettings(settings);
configuration->SetSandbox(true);
configuration->SetLogLevel(CXsollaClientConfiguration::XsollaLogLevel::Debug);
Assign Xsolla access token to the configurationβ
- C#
- C++
A valid access token must already be known before the SDK initialization step.
var configuration = XsollaStoreClientConfiguration.Builder.Create()
.SetSettings(settings)
.SetAccessToken("< your access token >")
.Build();
auto configuration = CXsollaClientConfiguration::Create();
configuration->SetSettings(settings);
configuration->SetAccessToken("< your access token >");
Using device ID instead of the access tokenβ
Below is an example with the fields required to be set for the device ID authentication approach to work:
- C#
- C++
var settings = XsollaStoreClientSettings.Builder.Create()
.SetProjectId("< your_project_id >")
.SetLoginId("< your_login_id >")
.Build();
auto settings = CXsollaClientSettings::Create();
settings->SetProjectId("< your_project_id >");
settings->SetLoginId("< your_login_id >");
Using OAuth2 instead of the access tokenβ
Below is an example with the fields required to be set for the OAuth2 authentication approach to work:
- C#
- C++
var settings = XsollaStoreClientSettings.Builder.Create()
.SetProjectId("< your_project_id >")
.SetLoginId("< your_login_id >")
.SetOAuthClientId("< your_oauth_client_id >")
// ..other properties
.Build();
auto settings = CXsollaClientSettings::Create();
settings->SetProjectId("< your_project_id >");
settings->SetLoginId("< your_login_id >");
settings->SetOAuthClientId("< your_oauth_client_id >")
Testing purchase flow in sandbox modeβ
See Testing guide for more details on how to enable the sandbox mode and avoid spending real money while testing the integration.