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.

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.
Clone this wiki locally