Xsolla::Cart::XsollaCart

Public Functions

Name
static voidGetCartItems (Action< Cart > onSuccess, Action< Error > onError, string cartId =null, string locale =null, string currency =null)
Returns a list of items from the cart with the specified ID or from the cart of the current user. For each item, complete data is returned.
static voidFillCart (List< CartFillItem > items, Action onSuccess, Action< Error > onError, string cartId =null)
Fills the cart with the specified ID or the cart of the current user with items. If there is already an item with the same SKU in the cart, the existing item position will be replaced by the passed value.
static voidUpdateItemInCart (string itemSku, int quantity, Action onSuccess, Action< Error > onError, string cartId =null)
Updates the quantity of a previously added item in the cart with the specified ID or in the current user cart. If there is no item with the specified SKU in the cart, it will be added.
static voidRemoveItemFromCart (string itemSku, Action onSuccess, Action< Error > onError, string cartId =null)
Removes the item from the cart with the specified ID or from the cart of the current user.
static voidClearCart (Action onSuccess, Action< Error > onError, string cartId =null)
Removes all items from the cart with the specified ID or from the cart of the current user.
static voidRedeemPromocode (string promocode, string cartId, Action< Cart > onSuccess, Action< Error > onError)
Redeems a promo code. After activating the promo code, the user gets free items and/or the price of the cart is reduced.
static voidGetPromocodeReward (string promocode, Action< PromocodeReward > onSuccess, Action< Error > onError)
Returns a list of items that can be credited to the user when the promo code is activated. Allows users to choose from several available items.
static voidRemovePromocodeFromCart (string cartId, Action< RemovePromocodeFromCartResult > onSuccess, Action< Error > onError =null)
Removes a promo code from a cart. After the promo code is removed, the total price of all items in the cart will be recalculated without bonuses and discounts provided by a promo code.
static voidCreateOrder (Action< OrderData > onSuccess, Action< Error > onError, string cartId =null, PurchaseParams purchaseParams =null, Dictionary< string, string > customHeaders =null)
Creates an order with items from the cart with the specified ID. Returns the payment token and order ID. The created order will get a new order status.
static voidCreateOrderWithFreeCart (Action< OrderId > onSuccess, Action< Error > onError, string cartId =null, PurchaseParams purchaseParams =null, Dictionary< string, string > customHeaders =null)
Create order with particular free cart. The created order will get a done order status.
static voidPurchase (Action< OrderStatus > onSuccess, Action< Error > onError, string cartId =null, Action< BrowserCloseInfo > onBrowseClosed =null, PurchaseParams purchaseParams =null, Dictionary< string, string > customHeaders =null, PlatformSpecificAppearance platformSpecificAppearance =null, SdkType sdkType =SdkType.Store)
Launches purchase process for the cart with the specified ID or for the cart of the current user. This method encapsulates methods for creating an order, opening a payment UI, and tracking the order status.
static voidPurchaseFreeCart (Action< OrderStatus > onSuccess, Action< Error > onError, string cartId =null, PurchaseParams purchaseParams =null, Dictionary< string, string > customHeaders =null, SdkType sdkType =SdkType.Store)
Launches purchase process for the free cart with the specified ID or for the free cart of the current user. This method encapsulates methods for creating an order and tracking the order status.

Public Functions Documentation

function GetCartItems

Copy
Full screen
Small screen
1static void GetCartItems(
2    Action< Cart > onSuccess,
3    Action< Error > onError,
4    string cartId =null,
5    string locale =null,
6    string currency =null
7)

Returns a list of items from the cart with the specified ID or from the cart of the current user. For each item, complete data is returned.

Parameters:

  • onSuccess Called after local cache of cart items was successfully updated.
  • onError Called after the request resulted with an error.
  • cartId Unique cart identifier.
  • locale Defines localization of item’s text fields. Two-letter lowercase language code . Leave empty to use the default value.
  • currency The currency in which prices are displayed (USD by default). Three-letter currency code per ISO 4217 . Check the documentation for detailed information about currencies supported by Xsolla .

More about the use cases .

function FillCart

Copy
Full screen
Small screen
1static void FillCart(
2    List< CartFillItem > items,
3    Action onSuccess,
4    Action< Error > onError,
5    string cartId =null
6)

Fills the cart with the specified ID or the cart of the current user with items. If there is already an item with the same SKU in the cart, the existing item position will be replaced by the passed value.

Parameters:

  • items Item for filling the cart. If there is already an item with the same SKU in the cart, the existing item position will be replaced by the passed value.
  • onSuccess Called after cart is successfully filled.
  • onError Called after the request resulted with an error.
  • cartId Unique cart identifier.

More about the use cases .

function UpdateItemInCart

Copy
Full screen
Small screen
1static void UpdateItemInCart(
2    string itemSku,
3    int quantity,
4    Action onSuccess,
5    Action< Error > onError,
6    string cartId =null
7)

Updates the quantity of a previously added item in the cart with the specified ID or in the current user cart. If there is no item with the specified SKU in the cart, it will be added.

Parameters:

  • itemSku SKU of item for purchase.
  • quantity Quantity of purchased items.
  • onSuccess Called after successfully adding a new item to the cart.
  • onError Called after the request resulted with an error.
  • cartId Unique cart identifier.

More about the use cases .

function RemoveItemFromCart

Copy
Full screen
Small screen
1static void RemoveItemFromCart(
2    string itemSku,
3    Action onSuccess,
4    Action< Error > onError,
5    string cartId =null
6)

Removes the item from the cart with the specified ID or from the cart of the current user.

Parameters:

  • itemSku Item SKU to delete.
  • onSuccess Called after successfully removing an item from the cart.
  • onError Called after the request resulted with an error.
  • cartId Unique cart identifier.

More about the use cases .

function ClearCart

Copy
Full screen
Small screen
1static void ClearCart(
2    Action onSuccess,
3    Action< Error > onError,
4    string cartId =null
5)

Removes all items from the cart with the specified ID or from the cart of the current user.

Parameters:

  • onSuccess Called after successful cart clearing.
  • onError Called after the request resulted with an error.
  • cartId Unique cart identifier.

More about the use cases .

function RedeemPromocode

Copy
Full screen
Small screen
1static void RedeemPromocode(
2    string promocode,
3    string cartId,
4    Action< Cart > onSuccess,
5    Action< Error > onError
6)

Redeems a promo code. After activating the promo code, the user gets free items and/or the price of the cart is reduced.

Parameters:

  • promocode Unique code of promocode. Contains letters and numbers.
  • cartId Unique cart identifier. The current user cart will be updated if empty.
  • onSuccess Called after successful promocode redemption.
  • onError Called after the request resulted with an error.

More about the use cases .

function GetPromocodeReward

Copy
Full screen
Small screen
1static void GetPromocodeReward(
2    string promocode,
3    Action< PromocodeReward > onSuccess,
4    Action< Error > onError
5)

Returns a list of items that can be credited to the user when the promo code is activated. Allows users to choose from several available items.

Parameters:

  • promocode Unique code of promocode. Contains letters and numbers.
  • onSuccess Called after successfully receiving promocode rewards.
  • onError Called after the request resulted with an error.

More about the use cases .

function RemovePromocodeFromCart

Copy
Full screen
Small screen
1static void RemovePromocodeFromCart(
2    string cartId,
3    Action< RemovePromocodeFromCartResult > onSuccess,
4    Action< Error > onError =null
5)

Removes a promo code from a cart. After the promo code is removed, the total price of all items in the cart will be recalculated without bonuses and discounts provided by a promo code.

Parameters:

  • cartId Cart ID. The current user cart will be updated if empty.
  • onSuccess Called after the promo code has been successful removed from cart.
  • onError Called after the request resulted with an error.

More about the use cases .

function CreateOrder

Copy
Full screen
Small screen
1static void CreateOrder(
2    Action< OrderData > onSuccess,
3    Action< Error > onError,
4    string cartId =null,
5    PurchaseParams purchaseParams =null,
6    Dictionary< string, string > customHeaders =null
7)

Creates an order with items from the cart with the specified ID. Returns the payment token and order ID. The created order will get a new order status.

Parameters:

  • onSuccess Called after the order was successfully created.
  • onError Called after the request resulted with an error.
  • cartId Unique cart identifier.
  • purchaseParams Purchase parameters such as country, locale, currency, and quantity.
  • customHeaders Custom HTTP request headers.

More about the use cases .

function CreateOrderWithFreeCart

Copy
Full screen
Small screen
1static void CreateOrderWithFreeCart(
2    Action< OrderId > onSuccess,
3    Action< Error > onError,
4    string cartId =null,
5    PurchaseParams purchaseParams =null,
6    Dictionary< string, string > customHeaders =null
7)

Create order with particular free cart. The created order will get a done order status.

Parameters:

  • onSuccess Called after server response.
  • onError Called after the request resulted with an error.
  • cartId Unique cart identifier.
  • purchaseParams Purchase parameters such as country, locale, currency, and quantity.
  • customHeaders Custom HTTP request headers.

More about the use cases .

function Purchase

Copy
Full screen
Small screen
 1static void Purchase(
 2    Action< OrderStatus > onSuccess,
 3    Action< Error > onError,
 4    string cartId =null,
 5    Action< BrowserCloseInfo > onBrowseClosed =null,
 6    PurchaseParams purchaseParams =null,
 7    Dictionary< string, string > customHeaders =null,
 8    PlatformSpecificAppearance platformSpecificAppearance =null,
 9    SdkType sdkType =SdkType.Store
10)

Launches purchase process for the cart with the specified ID or for the cart of the current user. This method encapsulates methods for creating an order, opening a payment UI, and tracking the order status.

Parameters:

  • onSuccess Called after the order transitions to the ‘done’ status.
  • onError Called after the request resulted with an error.
  • cartId Unique cart identifier.
  • onBrowseClosed Called after the browser is closed. The event is tracked only when the payment UI is opened in the built-in browser. External browser events can’t be tracked.
  • purchaseParams Purchase parameters such as country, locale, and currency.
  • customHeaders Custom HTTP request headers.
  • platformSpecificAppearance Additional settings of payment UI appearance for different platforms.
  • sdkType SDK type. Used for internal analytics.

More about the use cases .

function PurchaseFreeCart

Copy
Full screen
Small screen
1static void PurchaseFreeCart(
2    Action< OrderStatus > onSuccess,
3    Action< Error > onError,
4    string cartId =null,
5    PurchaseParams purchaseParams =null,
6    Dictionary< string, string > customHeaders =null,
7    SdkType sdkType =SdkType.Store
8)

Launches purchase process for the free cart with the specified ID or for the free cart of the current user. This method encapsulates methods for creating an order and tracking the order status.

Parameters:

  • onSuccess Called after the order transitions to the ‘done’ status.
  • onError Called after the request resulted with an error.
  • cartId Unique cart identifier.
  • purchaseParams Purchase parameters such as country, locale, and currency.
  • customHeaders Custom HTTP request headers.
  • sdkType SDK type. Used for internal analytics.

More about the use cases .

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: October 27, 2026

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!
We couldn't send your feedback
Try again later or contact us at [email protected].