SDK for Unity / How to migrate to SDK version 2.0.0 and higher
  Back to Docs

SDK for Unity

How to migrate to SDK version 2.0.0 and higher

Structure changes in version 2.0.0

  • Request methods and classes have been replaced with static ones.
  • The project ID is not passed to methods as a parameter. The SDK uses the value specified in the project settings.
  • The user’s authorization token is not passed to methods as a parameter and is not returned by callback functions. The SDK determines the token based on the user’s previous authentication and passes it to the methods for getting a catalog, purchasing, and displaying the inventory.
  • The logic for determining the information about a mobile device has been added to the SDK. The data is encapsulated in a DeviceInfo structure.

See the full list of changes in the сhangelog.

XsollaAuth class upgrade

  • Replace XsollaAuth.Instance calls with XsollaAuth.
  • Change the signature of the onSuccess callback method used when calling the authentication method. Replace Action<string> with Action.
  • Remove the passing of the refreshToken parameter when calling the RefreshOAuthToken method.
  • Remove the passing of the token parameter when calling the GetUserInfo method.
  • Replace the call to XsollaAuth.Instace.OAuthLogout with XsollaAuth.Logout and remove the passing of the token parameter when calling the method.
  • Remove the passing of the deviceType, deviceId, device parameters when calling the AuthViaDeviceID method. Remove the logic for determining mobile device information.
  • Change the signature of the onSuccess callback method used when calling the Register method. Replace Action<int>, Action, Action<LoginUrlResponse> with Action<LoginLink>.
  • Remove the passing of the rememberMe parameter when calling the SignIn method.
  • Change the signature of the onSuccess callback method used when calling the StartAuthByEmail and StartAuthByPhoneNumber methods. Replace Action<string> with Action<OperationId>.

XsollaCart class upgrade

  • Replace XsollaCart.Instance calls with XsollaCart.
  • Replace the XsollaCart.Instance.PurchaseCart calls with XsollaCart.CreateOrder.
  • Remove the passing of the projectId parameter when calling class methods.
  • If you are only working with the current user’s cart, remove the passing of the cartId parameter when calling class methods.

XsollaOrders class upgrade

  • Replace the XsollaOrders.Instance calls with XsollaOrders.
  • Change the code for calling the OpenPurchaseUI method. Pass the payment token as the paymentToken parameter (the purhaseData parameter has been replaced with paymentToken).
  • Change the signature of the onBrowserClosed callback method used when calling the OpenPurchaseUI method. Replace Action<bool> with Action<BrowserCloseInfo>.
  • Remove the passing of the projectId parameter when calling class methods.

XsollaUserAccount class upgrade

  • Replace the XsollaUserAccount.Instance calls with XsollaUserAccount.
  • Remove the passing of the token parameter when calling class methods.

XsollaSubscriptions class upgrade

  • Replace the XsollaSubscriptions.Instance calls with XsollaSubscriptions.
  • Remove the passing of the projectId parameter when calling class methods.

XsollaInventory class upgrade

  • Replace the XsollaInventory.Instance calls with XsollaInventory.
  • Remove the passing of the projectId parameter when calling class methods.

XsollaGameKeys class upgrade

  • Replace the XsollaGameKeys.Instance calls with XsollaGameKeys.
  • Remove the passing of the projectId parameter when calling class methods.

Token class upgrade

  • Replace the Token.Instance calls with XsollaToken.
  • Replace the Token.Instance.GetSteamUserID calls with SteamUItils.GetSteamUserId.
  • Modify the code to get the value of the access and refresh tokens. Use the XsollaToken.AccessToken and XsollaToken.RefreshToken properties.

Upgrade utility classes

  • Replace the use of the AndroidSDKSocialAuthHelper and IosSDKSocialAuthHelper classes with the XsollaAuth.AuthViaSocialNetwork call.
  • Replace the use of the AndroidSDKPaymentsHelper and IosSDKPaymentsHelper classes with the XsollaWebBrowser.OpenPurchaseUI call.

Package replacement

  1. Open your Unity project.
  2. Delete the Xsolla folder.
  3. Download the SDK or demo project package.
Note
If you use code snippets or a demo scene UI in your project, download the demo project package because it already contains the SDK files. If you included a demo project in your Unity project, you don’t need to integrate the SDK.
  1. Unzip the package.
  2. In the Unity Editor, go to Assets > Import Package > Custom Package in the main menu and select the SDK or demo project package.
  3. In the dependency warning window, click Install/Upgrade. As a result, the Import Unity Package window opens with a list of files checked and ready for installation. The list will indicate which files remain unchanged, which will be added, and which will be replaced.
  4. Click Import.
  5. Test your application and make changes to the project code if necessary.
Was this article helpful?
Thank you!
Is there anything we can improve? Message
We’re sorry to hear that
Please explain why this article wasn’t helpful to you. Message
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.
Last updated: January 22, 2024

Found a typo or other text error? Select the text and press Ctrl+Enter.

Report a problem
We always review our content. Your feedback helps us improve it.
Provide an email so we can follow up
Thank you for your feedback!