SDKs for Unity / Free items
  Back to Docs

SDKs for Unity

Free items

Free items are a type of item that users can get without spending virtual or real currency. These include:

  • Virtual items
  • Bundles
  • Virtual currency packages

Free items are only available to authorized users. Unauthorized users can only view the catalog of free items.

Examples of usage:

  • You can give away free items on important dates for your project (for example, on the day the project was founded) to reward users for their loyalty.
  • You can give away free starter packs for the game in the store to attract new users to the game.

You can limit the free giveaway of unique items if the user already has them.

To set up free items:

  1. Add free items to the catalog.
  2. Implement logic of ordering free items by users.
  3. Implement the logic of granting free items to the user.

Adding free items to catalog

Detailed instructions for creating items are available in the following documentation sections:

When creating or editing a free item, you need to select a Free item, Free package or Free bundle in the Paid or Free section.

Ordering free items by user

A user can order a free item in two ways:

  • In one click (without using the shopping cart) — one SKU in any quantity. For example, 100 identical potions.
  • Via the shopping cart — any type of items in any quantity.

Ordering free item in one click

To implement this option, call the PurchaseFreeItem SDK method when a user clicks the button in the catalog to order the free item.

The delivery of items to the user’s inventory on the Xsolla’s side occurs immediately after a successful request to this method (without the need to open Pay Station).

Ordering free items via shopping cart

In case the user buys through a shopping cart:

  • If the cart contains both paid and free items, call the Purchase SDK method of the Cart class. This method encapsulates methods for creating an order, opening a payment UI, and tracking the order status.

  • If the cart contains only free items, call the PurchaseFreeCart SDK method of the Cart class. The delivery of items to the user’s inventory on the Xsolla’s side occurs immediately after a successful request to this method (without the need to open Pay Station).

Granting free items to user

The Purchase, PurchaseFreeItem, and PurchaseFreeCart methods contain the logic for tracking the order status. When calling these methods, pass a function that is called when the order transitions to the done status in the onSuccess parameter. Update the inventory on the client side of the application using one of the following options:

Note
If you’ve configured your application’s server to handle Xsolla webhooks, you can update the data on your application’s client side when the order_paid webhook is received.
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.
Rate this page
Rate this page
Is there anything we can improve?

Don’t want to answer

Thank you for your feedback!

Useful links

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!