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 withXsollaAuth
. - Change the signature of the
onSuccess
callback method used when calling the authentication method. ReplaceAction<string>
withAction
. - Remove the passing of the
refreshToken
parameter when calling theRefreshOAuthToken
method. - Remove the passing of the
token
parameter when calling theGetUserInfo
method. - Replace the call to
XsollaAuth.Instace.OAuthLogout
withXsollaAuth.Logout
and remove the passing of thetoken
parameter when calling the method. - Remove the passing of the
deviceType
,deviceId
,device
parameters when calling theAuthViaDeviceID
method. Remove the logic for determining mobile device information. - Change the signature of the
onSuccess
callback method used when calling theRegister
method. ReplaceAction<int>, Action, Action<LoginUrlResponse>
withAction<LoginLink>
. - Remove the passing of the
rememberMe
parameter when calling theSignIn
method. - Change the signature of the
onSuccess
callback method used when calling theStartAuthByEmail
andStartAuthByPhoneNumber
methods. ReplaceAction<string>
withAction<OperationId>
.
XsollaCart class upgrade
- Replace
XsollaCart.Instance
calls withXsollaCart
. - Replace the
XsollaCart.Instance.PurchaseCart
calls withXsollaCart.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 withXsollaOrders
. - Change the code for calling the
OpenPurchaseUI
method. Pass the payment token as thepaymentToken
parameter (thepurhaseData
parameter has been replaced withpaymentToken
). - Change the signature of the
onBrowserClosed
callback method used when calling theOpenPurchaseUI
method. ReplaceAction<bool>
withAction<BrowserCloseInfo>
. - Remove the passing of the
projectId
parameter when calling class methods.
XsollaUserAccount class upgrade
- Replace the
XsollaUserAccount.Instance
calls withXsollaUserAccount
. - Remove the passing of the
token
parameter when calling class methods.
XsollaSubscriptions class upgrade
- Replace the
XsollaSubscriptions.Instance
calls withXsollaSubscriptions
. - Remove the passing of the
projectId
parameter when calling class methods.
XsollaInventory class upgrade
- Replace the
XsollaInventory.Instance
calls withXsollaInventory
. - Remove the passing of the
projectId
parameter when calling class methods.
XsollaGameKeys class upgrade
- Replace the
XsollaGameKeys.Instance
calls withXsollaGameKeys
. - Remove the passing of the
projectId
parameter when calling class methods.
Token class upgrade
- Replace the
Token.Instance
calls withXsollaToken
. - Replace the
Token.Instance.GetSteamUserID
calls withSteamUItils.GetSteamUserId
. - Modify the code to get the value of the access and refresh tokens. Use the
XsollaToken.AccessToken
andXsollaToken.RefreshToken
properties.
Upgrade utility classes
- Replace the use of the
AndroidSDKSocialAuthHelper
andIosSDKSocialAuthHelper
classes with theXsollaAuth.AuthViaSocialNetwork
call. - Replace the use of the
AndroidSDKPaymentsHelper
andIosSDKPaymentsHelper
classes with theXsollaWebBrowser.OpenPurchaseUI
call.
Package replacement
- Open your Unity project.
- Delete the
Xsolla
folder. - 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.
- Unzip the package.
- In the Unity Editor, go to
Assets > Import Package > Custom Package in the main menu and select the SDK or demo project package. - In the dependency warning window, click
Install/Upgrade . As a result, theImport 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. - Click
Import . - Test your application and make changes to the project code if necessary.
Was this article helpful?
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.Found a typo or other text error? Select the text and press Ctrl+Enter.