Skip to content

Set Up Events Processing and SDK Methods

Mariia Makarova edited this page Dec 25, 2020 · 3 revisions

SDK methods can be accessed via the Instance property of the XsollaStore class which implements a singleton pattern.

Store Unity SDK provides the following groups of methods:

Login Methods

Basic Registration and Authentication

User Registration

Method name in documentation: Register.

Call the “Registration” method to register a new user.

Parameter name Type Description
username
Required
string Username for a new account.
password
Required
string Password for a new account.
email
Required
string Email for verification.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request for registration of a new user is successfully completed.
onError
Optional
Callback triggered when an error occurs during the purchase of the cart content. See the error description for more details.
User Authentication

Method name in Documentation: Auth by Username and Password.

Call the “SignIn” method to authenticate a user.

Parameter name Type Description
username
Required
string Username of the user.
password
Required
string Password of the user.
rememberUser
Required
string Whether the user agrees to save the authentication data. Default is ‘false’.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request for user authentication is successfully completed.
onError
Optional
Callback triggered when an error occurs during request processing. See the error description for more details.
Reset Password

Method name in Documentation: Reset password.

Call the “ResetPassword” method to reset a password. A new password will be sent to the user email.

Parameter name Type Description
username
Required
string Username for a new account.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request for password reset is successfully completed.
onError
Optional
Callback triggered when an error occurs during request processing. See the error description for more details.

Cross-authentication

Steam Authentication

Method name in Documentation: Cross-auth.

Call the “SteamAuth” method to authenticate a user via Steam sessionTicket.

Note: this method does not work “out the box” yet. If you want to use this method:

  • Contact the support team at support@xsolla.com.
  • Read all comments in the code for this method.
Parameter name Type Description
appId
Required
string Your application Steam AppID.
sessionTicket
Required
string Requested user's session_ticket by SteamAPI.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the user authentication is successfully completed.
onError
Optional
Callback triggered when an error occurs during request processing. See the error description for more details.

User’s Attributes

Getting User’s Attributes

Method name in Documentation: Get User's Attributes from Client.

Call the “GetUserAttributes” method to obtain user attributes.

Parameter name Type Description
token
Required
string JWT from Xsolla Login.
projectId
Required
string Project ID from your Publisher Account.
attributeKeys
Required
List <string> Attributes names list.
userId
Required
string Login user ID.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the user attributes are successfully obtained. It sends the List<UserAttribute> with the corresponding data.
onError
Optional
Callback triggered when an error occurs during request processing. See the error description for more details.
Create or Update User's Attributes

Method name in Documentation: Update User's Attributes from Client.

Call the “UpdateUserAttributes” method to create or update user attributes.

Parameter name Type Description
token
Required
string JWT from Xsolla Login.
projectId
Required
string Project ID from your Publisher Account.
attributeKeys
Required
List <UserAttribute> Attributes list.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request is successfully processed.
onError
Optional
Callback triggered when an error occurs during request processing. See the error description for more details.
Remove User's Attributes

Method name in Documentation: Update User's Attributes from Client.

Call the “RemoveUserAttributes” method to create or update user attributes.

Parameter name Type Description
token
Required
string JWT from Xsolla Login.
projectId
Required
string Project ID from your Publisher Account.
attributeKeys
Required
List <string> Attributes names list.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request is successfully processed.
onError
Optional
Callback triggered when an error occurs during request processing. See the error description for more details.

Friend System and User Account

Get user’s friends from social provider

Method name in Documentation: Get User's Friends.

Parameter name Type Description
token
Required
string JWT from Xsolla Login.
provider SocialProvider Name of social provider.
offset int Offset.
limit int Limit.
withUid bool Shows whether the social friends are from your game.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Update a List of User’s Friends

Method name in Documentation: Update User's Friends.

Use "UpdateUserSocialFriends" method to begin processing to update a list of user’s friends from a social provider.

Parameter name Type Description
token
Required
string JWT from Xsolla Login.
provider SocialProvider Name of social provider.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Get Friends of Authenticated User

Method name in Documentation: Get Friends.

Parameter name Type Description
token
Required
string JWT from Xsolla Login.
type
Required
FriendsSearchType Friends type.
sortType FriendsSearchResultsSort Condition for sorting users.
order FriendsSearchResultsSortOrder Condition for sorting users.
count int Maximum friends.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Update Friend List of Authenticated User

Method name in Documentation: Update Friends.

Parameter name Type Description
token
Required
string JWT>
action
Required
FriendAction Type of the action.
user
Required
string The Xsolla Login user ID to change relationship with.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Link Social Provider

Method name in Documentation: Link Social Network To Account.

Call "LinkSocialProvider" method to link the social network, which is used by the player for authentication, to the user account.

Parameter name Type Description
SocialProvider
Required
SocialProvider Name of social provider.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Get Linked Social Providers

Method name in Documentation: Get Linked Networks.

Call "GetLinkedSocialProviders" method to get a list of the social networks linked to the user account.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Get Links for Social Auth

Method name in Documentation: Get Links for Social Auth.

Call "GetLinksForSocialAuth" method to get links for authentication via the social networks enabled in Publisher Account > Login settings > Social Networks. The links are valid for 10 minutes. You can get the link by this method and add it to your button for authentication via the social network.

Parameter name Type Description
locale string Defines localization request localization settings.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Search Users

Method name in Documentation: Search Users by Nickname.

Call "SearchUsers" method to search users by nickname in the same Login project as current user.

NOTE: User can search only 1 time per second.

Parameter name Type Description
token
Required
string JWT from Xsolla Login.
nickname
Required
int User's nickname.
offset
Required
int Offset.
limit
Required
int Limit.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Get Public Info

Method name in Documentation: Get public user's profile.

Call "GetPublicInfo" method to get public user info by user ID.

Parameter name Type Description
token
Required
string JWT from Xsolla Login.
user
Required
string The Xsolla Login user ID.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Get User Phone Number

Method name in Documentation: Get User Phone Number.

Call "GetUserPhoneNumber" method to get the phone number of the authenticated user by JWT.

Parameter name Type Description
token
Required
string JWT from Xsolla Login.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Change User Phone Number

Method name in Documentation: Update User Phone Number.

Call "ChangeUserPhoneNumber" method to update the phone number of the authenticated user by JWT.

Parameter name Type Description
token
Required
string JWT from Xsolla Login.
phoneNumber
Required
string User's phone number.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Delete User Phone Number

Method name in Documentation: Delete User Phone Number.

Call "DeleteUserPhoneNumber" method to delete the phone number of the authenticated user by JWT.

Parameter name Type Description
token
Required
string JWT from Xsolla Login.
phoneNumber
Required
string User's phone number.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional*
Failed operation callback.
Upload User Picture

Method name in Documentation: Upload User Picture.

Call "UploadUserPicture" method to upload the profile picture of the authenticated user by JWT.

Parameter name Type Description
token
Required
string JWT from Xsolla Login.
pictureData
Required
byte[] User profile picture in the binary format.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Delete User Picture

Method name in Documentation: Delete User Picture.

Call "DeleteUserPicture" method to delete the profile picture of the authenticated user by JWT.

Parameter name Type Description
token
Required
string JWT from Xsolla Login.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Check User Age

Method name in Documentation: Check User's Age.

Call "CheckUserAge" method to checks user’s age for a particular region. The age requirements depend on the region. Service determines the user’s location by the IP address.

Parameter name Type Description
dateOfBirth
Required
string User's birth date in the YYYY-MM-DD format.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Get User Email

Method name in Documentation: GetUserEmail.

Call "GetUserEmail" method to get the email of the authenticated user by JWT.

Parameter name Type Description
token
Required
string JWT from Xsolla Login.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Auth with Social Network Access Token

Method name in Documentation for JWT and OAuth 2.0: [Auth via Access Token of Social Network].

Call "AuthWithSocialNetworkAccessToken" method to authenticate the user with the access token using social network credentials.

Parameter name Type Description
accessToken
Required
string Parameter oauth_token_secret received from the authorization request. Required for Twitter only.
AccessTokenSecret
Required for Twitter only
string Parameter oauth_token_secret received from the authorization request.
providerName
Required
string Name of the social network connected to the Login in Publisher Account.
payload
Required
string Custom data. The value of the parameter will be returned in the user JWT payload claim.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.
Auth via Provider Project

Method name in Documentation: Authentication via Provider Project.

Call "AuthViaProviderProject" method to exchange the provider JWT by the client JWT.

Parameter name Type Description
accessToken
Required
string Parameter oauth_token_secret received from the authorization request. Required for Twitter only.
platformProviderName
Required
string Name of the provider project.

Set up events processing:

Event name Description
onSuccess
Required
Successful operation callback.
onError
Optional
Failed operation callback.

In-Game Store Methods

Catalog Formation

Get Catalog

Method name in Documentation: Get virtual items list.

Call the “GetCatalog” method to obtain the full list of virtual items added to your Store. Provide logic for processing parameters received in the onSuccess callback.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
locale
Optional
string Response language (e.g. item name, item description). Two-letter lowercase language code per ISO 639-1.
currency
Optional
string Currency which the prices are shown in (USD by default). Three-letter currency code per ISO 4217.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request for getting a list of virtual items is successfully completed. It sends the StoreItems object with the corresponding data.
onError
Optional
Callback triggered if an error occurs during the request for a list of virtual items. See the error description for more details.
Get Item Groups

Method name in Documentation: Get items groups list.

Call the “GetItemGroups” method to obtain the full list of item groups added to your Store. Provide logic for processing parameters received in the onSuccess callback.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
locale
Optional
string Response language (e. g. item name, item description). Two-letter lowercase language code per ISO 639-1.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request for getting a list of groups is successfully completed. It sends the Groups object with the corresponding data.
onError
Optional
Callback triggered if an error occurs during the request for a list of virtual items. See the error description for more details.
Get Items In Group

Method name in Documentation: Get items list by specified group.

Call the “GetGroupItems” method to obtain the full list of items in the specified group. Provide logic for processing parameters received in the onSuccess callback.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
groupExternalId
Required
string Group Code from your Publisher Account.
locale
Optional
string Response language (e.g. item name, item description). Two-letter lowercase language code per ISO 639-1.
currency
Optional
string Currency which the prices are shown in (USD by default). Three-letter currency code per ISO 4217.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request for getting a list of virtual items is successfully completed. It sends the StoreItems object with the corresponding data.
onError
Optional
Callback triggered if an error occurs during the request for a list of virtual items. See the error description for more details.

Cart Operation

Note: Cart only works with items which prices are in real currency.

Creating Cart

Method name in Documentation: Get current user's cart.

Call the “CreateNewCart” method to create a new cart for virtual items to be purchased. As a result, you will receive an identifier of the newly created cart which will be used later for adding/removing items.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request for creating a new cart is successfully completed. It sends the Cart object which contains a unique identifier within the project.
onError
Optional
Callback triggered if an error occurs during the request for a list of virtual items. See the error description for more details.
Add Item to Cart

Method name in Documentation: Update cart line item by cart ID.

Call the “UpdateItemInCart” method to add a certain virtual item to the cart or change its current quantity. It can be used for both increasing and decreasing the number of items in the cart.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
cartId
Required
string Identifier of the cart in which the item is added/updated.
itemSku
Required
string Identifier of the item which is added/updated in the specified cart.
quantity
Required
int New quantity value of the item that is added/updated in the cart.

Set up events processing:

Event name Description
onSuccess
Optional
Callback triggered when the request for adding the virtual item to the cart or updating its quantity is successfully completed.
onError
Optional
Callback triggered if an error occurs when adding a virtual item to the cart or updating its quantity. See the error description for more details.

Note that the system allows you to set an item quantity equal to zero. In this case the item will be added to the receipt of your purchase. To prevent it, check that there are no products with the quantity equal to zero in the cart.

Removing Item from Cart

Method name in Documentation: Delete cart line item by cart ID.

Call the “RemoveItemFromCart” method to remove a virtual item from the cart.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
cartId
Required
string Identifier of the cart in which the item is added/updated.
itemSku
Required
string Identifier of the item which is added/updated in the specified cart.

Set up events processing:

Event name Description
onSuccess
Optional
Callback triggered when the request for removing the virtual item from the cart is successfully completed.
onError
Optional
Callback triggered if an error occurs during the removing of the virtual item from the cart. See the error description for more details.
Getting Cart Items List

Method name in Documentation: Get cart by ID.

Call the “GetCartItems” method to obtain the full list of virtual items stored in the specified cart. Provide logic for processing parameters received in the onSuccess callback.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
cartId
Required
string Identifier of the cart to get the content of.
locale
Optional
string Response language (e.g. item name, item description). Two-letter lowercase language code per ISO 639-1.
currency
Optional
string Currency which the prices are shown in (USD by default). Three-letter currency code per ISO 4217.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request for getting a list of virtual items from the cart is successfully completed. It sends the CartItems object with the corresponding data.
onError
Optional
Callback triggered when an error occurs during the getting of the list of virtual items from the cart. See Error description for more details.
Clearing Cart

Method name in Documentation: Delete all cart line items by cart ID.

Call the ClearCart method to remove all the content of the specified cart.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
cartId
Required
string Identifier of the cart to get the content of.

Set up events processing:

Event name Description
onSuccess
Optional
Callback triggered when the request for clearing the cart is successfully completed.
onError
Optional
Callback triggered when an error occurs during the clearing of the cart. See Error description for more details.

Inventory Management

Getting Inventory Items

Method name in Documentation: Get the current user's inventory.

Call the “GetInventoryItems” method to obtain the full list of virtual items added to your inventory. Provide logic for processing parameters in the onSuccess callback.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
locale
Optional
string Response language (e.g. item name, item description). Two-letter lowercase language code per ISO 639-1.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request for getting the list of virtual items is successfully completed. It sends the InventoryItems object with the corresponding data.
onError
Optional
Callback triggered when an error occurs during the request for the list of virtual items. See the error description for more details.
Consume Inventory Item

Method name in Documentation: Consume item.

Call the “ConsumeInventoryItem” method to consume an item from the player inventory. Provide logic for processing parameters in the onSuccess callback.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
item
Required
ConsumeItem Item for consuming.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request for item consume is successfully completed.
onError
Optional
Callback triggered when an error occurs during the request for item consume. See the error description for more details.

Note that StoreAPI allows you to consume only one item now (quantity = 1). If you want to consume more than one item, you must call this method several times.

Payment Methods

Item Purchase

Method name in Documentation: Create order with specified item.

Call the “ItemPurchase” method to initiate a quick purchase of the specified virtual item without adding it to the cart.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
itemSku
Required
string Identifier of the item to be purchased.
purchaseParams
Optional
purchaseParams Extra parameters allowing to specify a currency, locale, and country of purchase.

Set up events processing:

Event name Description
onSuccess
Optional
Callback triggered after the initiation of the purchase. It receives the PurchaseData object with the order identifier. Order ID can be used to track its status.
onError
Optional
Callback triggered when an error occurs during the purchase of a virtual item. See the error description for more details.
Item Purchase for Virtual Currency

Method name in Documentation: Create order with specified item purchased by virtual currency.

Call the “ItemPurchaseForVirtualCurrency” method to initiate a quick purchase of the specified virtual item by virtual currency without adding it to the cart.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
itemSku
Required
string Identifier of the item to be purchased.
priceSku
Required
string Purchase currency identifier.
purchaseParams
Optional
purchaseParams Extra parameters allowing to specify a currency, locale, and country of purchase.

Set up events processing:

Event name Description
onSuccess
Optional
Callback triggered after the initiation of the purchase. It receives the PurchaseData object with the order identifier. Order ID can be used to track its status.
onError
Optional
Callback triggered when an error occurs during the purchase of a virtual item. See the error description for more details.
Cart Purchase

Method name in Documentation: Create order with all items from particular cart.

Call the “CartPurchase” method to initiate a purchase of all items in the cart.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
cartId
Required
string Identifier of the cart which content should be purchased.
purchaseParams
Optional
purchaseParams Extra parameters allowing to specify a currency, locale, and country of purchase.

Set up events processing:

Event name Description
onSuccess
Optional
Callback triggered after the initiation of the purchase. It receives the PurchaseData object with the order identifier. Order ID can be used to track its status.
onError
Optional
Callback triggered when an error occurs during the purchase of the cart content. See the error description for more details.
Checking Order Status

Method name in Documentation: Get order.

Call the “CheckOrderStatus” method to check if the purchase has already been processed.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
orderId
Required
int Identifier of the order to be verified.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request for checking the order status is successfully completed.
onError
Optional
Callback triggered when an error occurs during the purchase of the cart content. See the error description for more details.

Virtual Currencies

Getting Virtual Currencies

Method name in Documentation: Get virtual currency list.

Call the “GetVirtualCurrencyList” method to obtain the full list of virtual currencies added to your store. Provide logic for processing parameters in the onSuccess callback.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
locale
Optional
string Response language (e.g. item name, item description). Two-letter lowercase language code per ISO 639-1.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request for getting the list of virtual items is successfully completed. It sends the VirtualCurrencyItems object with the corresponding data.
onError
Optional
Callback triggered when an error occurs during the request for the list of virtual items. See the error description for more details.
Getting a Balance of Virtual Currencies

Method name in Documentation: Get the current user's virtual balance.

Call the “GetVirtualCurrencyBalance” method to obtain a balance of virtual currencies in player inventory. Provide logic for processing parameters in the onSuccess callback.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
locale
Optional
string Response language (e.g. item name, item description). Two-letter lowercase language code per ISO 639-1.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request for getting the list of virtual items is successfully completed. It sends the VirtualCurrenciesBalance object with the corresponding data.
onError
Optional
Callback triggered when an error occurs during the request for the list of virtual items. See Error description for more details.
Getting Virtual Currency Packages

Method name in Documentation: Get virtual currency package list.

Call the “GetVirtualCurrencyPackagesList” method to obtain the full list of virtual currency packages added in your store. Provide logic for processing parameters in the onSuccess callback.

Parameter name Type Description
projectId
Required
string Project ID from your Publisher Account.
locale
Optional
string Response language (e.g. item name, item description). Two-letter lowercase language code per ISO 639-1.

Set up events processing:

Event name Description
onSuccess
Required
Callback triggered when the request for getting the list of virtual items is successfully completed. It sends the VirtualCurrencyPackages object with the corresponding data.
onError
Optional
Callback triggered when an error occurs during the request for the list of virtual items. See the error description for more details.