Gestión de compras

Follow the step-by-step tutorials below to get going with the basic SDK features.

Visualización del catálogo de artículos

This tutorial shows how to use the SDK methods to display the following items in an in-game store:
  • virtual items
  • groups of virtual items
  • bundles
  • packages of virtual currency
Código fuente
Consulte el código fuente de estos ejemplos en GitHub.

Before you start, configure items in Publisher Account:

  1. Configure virtual items and groups of virtual items.
  2. Configure packages of virtual currencies.
  3. Configure bundles.

The logics and interface in the examples are less complicated than they will be in your application. A possible item catalog in an in-game store implementation option is described in the demo project.

Nota

The example of every item in a catalog shows:

  • item name
  • item price

You can also show other information about the item if this information is stored in an in-game store.

Crear widget para la página del catálogo

  1. Go to Content Browser and create a UI directory.
  2. In the contextual menu, go to User Interface > Widget Blueprint.
  3. In the widget blueprint, add the following UI elements:
    • buttons for switching between displays of items and virtual currency packages
    • a display area for groups of items
    • a display area for the list of items
    • a display area for the list of virtual currency packages

The following picture shows an example of the page structure.

  1. Open a level blueprint:
    1. Choose a level in Content Browser.
    2. In the main menu, go to Blueprints > Open Level Blueprint.
  2. Implement widget display when the level is started. To do this, add nodes as shown below. In the CreateWidget node, specify the created widget.

Añadir control de eventos de widget para la página de catálogo

  1. In the Hierarchy panel, select a button for switching to the list of items.
  2. In the Details panel, click the + icon near the On Clicked event.
  1. In the Hierarchy panel, select a button for switching to the list of virtual currency packages.
  2. In the Details panel, click the + icon near the On Clicked event.
  1. Open a Graph view.
  2. Implement logic for switching between the lists. To do this, add the nodes as shown in the following picture.

Implementar la visualización de grupos de artículos virtuales

Crear clase para grupo de artículos

  1. Go to Content Browser. There, in the contextual menu, click Blueprint Class.
  2. In the All classes section, select Object and click Select.
  3. Use BP_ItemGroupData as a class name.
  4. Open a blueprint of a created class.
  5. In the My Blueprint panel, click Add New and select Variable.
  6. In the Details panel:
    1. Specify GroupData in the Variable Name field.
    2. Select XsollaItemGroup in the Variable Type field.
    3. Check Instance Editable and Expose on Spawn boxes.

Crear widget para grupo de artículos

  1. Go to Content Browser and create a UI directory and, in the contextual menu, go to User Interface > Widget Blueprint.
  2. In the widget blueprint, add an element for the name of the item group.

The following picture shows an example of the widget structure.

  1. Open a Graph view.
  2. Click Class settings.
  3. In the Details panel, go to Interfaces > Implemented interfaces.
  4. Click Add and select UserObjectListEntry. This is a standard UE interface that allows the UI primitive to implement a behavior normal for the element of the list.
  5. Implement logic for creating a group of items:
    1. Add the EventOnListItemObjectSet node to create an element of the list and initialize the widget.
    2. Pass the value from the object that contains data about the group to the element with the name of the group. To do this, add nodes as shown in the following picture.
    1. Implement logic for showing all items with the All category. To do this, edit a blueprint as shown in the following picture.
  1. Implement logic for highlighting a group of items that is selected in the list. To do this, add nodes as shown in the following picture.

Añadir lista de grupos de artículos a la página del catálogo

  1. Open the catalog page widget blueprint.
  2. Add the List View element to the item groups display area.
  3. In the Details panel, select a previously created class for an item group in the Entry Widget Class field.
  4. Implement logic for adding items to groups:
    1. Open a Graph view.
    2. Link an UpdateItemGroups SDK method call connected with the XsollaLoginSubsystem object to the EventConstruct node and add passing of data entered by users.
    3. Implement logic for adding items to the group. The action should be done while processing a successful update of local cache of virtual item groups. To do this, add nodes as shown in the following picture.
  1. Implement logic for showing all items with the All category. To do this, edit a blueprint as shown in the following picture.

Implementar la visualización de artículos virtuales

Crear clase para un artículo

  1. Go to Content Browser. There, in the contextual menu, click Blueprint Class.
  2. In the All classes section, select Object and click Select.
  3. Use BP_CatalogItemData as a class name.
  4. Open a blueprint of a created class.
  5. In the My Blueprint panel, click Add New and select Variable.
  6. In the Details panel:
    1. Specify CatalogItem in the Variable Name field.
    2. Select StoreItem in the Variable Type field.
    3. Check Instance Editable and Expose on Spawn boxes.

Crear widget para un artículo

  1. Go to Content Browser and create a UI directory. In the contextual menu, go to User Interface > Widget Blueprint.
  2. In the widget blueprint, add the following UI elements:
    • item name
    • item price

The following picture shows an example of the widget structure.

  1. Open a Graph view.
  2. Click Class settings.
  3. In the Details panel, go to Interfaces > Implemented interfaces.
  4. Click Add and select UserObjectListEntry. This is a standard UE interface that allows the UI primitive to implement a behavior normal for the element of the list.
  5. Implement logic for creating a group of items:
    1. Add the EventOnListItemObjectSet node to create an element of the list and initialize the widget.
    2. Pass the values from the object that contains data about the item to the elements with the name of the item and its price. To do this, add nodes as shown in the following picture.

Añadir lista de artículos a la página del catálogo

  1. Open the catalog page widget blueprint.
  2. Add the List View element to the items list display area.
  3. In the Details panel, select a previously created class for an item in the Entry Widget Class field.
  4. Implement logic for adding items to groups:
    1. Open a Graph view.
    2. Link an UpdateVirtualItems SDK method call connected with the XsollaLoginSubsystem object to the EventConstruct node and add passing of data entered by users.
    3. Implement logic for adding items to the group. The action should be done while processing a successful update of local cache of virtual item groups. To do this, add nodes as shown in the following picture.
Nota
The offset and limit parameters of the UpdateVirtualItems method are not required. Use them to implement pagination — a page-by-page display of items in the catalog. The maximum number of items on the page is 50. If the catalog has more than 50 items, pagination is necessary.
  1. Implement logic for adding items to groups. To do this, add nodes as shown in the following picture.

Implementar la visualización de artículos virtuales por grupos

  1. Open the catalog page widget blueprint.
  2. In the Hierarchy panel, select the list of item groups.
  3. In the Details panel, click the + icon near the On Item Clicked event.
  1. Open a Graph view.
  2. Implement logic for filtering items by groups. To do this, add nodes as shown in the following picture.
Nota
Items are filtered by a unique group identifier. The All category doesn’t have an identifier, that’s why the filter resets and shows all items.

Implementar la visualización de lotes

In this instruction, bundles and virtual items are shown in one list. Moreover, we use the same widget to display a single bundle or item.

Añadir lista de lotes en la página del catálogo

  1. Open a catalog page blueprint.
  2. Open a Graph view.
  3. Complete logic for adding bundles to a list. Add the UpdateBundles SDK method callback alongside with the UpdateVirtualItems method callback as shown in the following picture.

Completar un widget de artículos

  1. Open an item widget blueprint.
  2. Add a button for viewing bundle content near the item name.

The following picture shows an example of the widget structure.

  1. Open a Graph view.
  2. Complete logic for creating an item by adding a display condition for a bundle content viewing button. The example is in the following picture.

Añadir lógica para visualizar el contenido del lote

  1. In the blueprint for the item widget, open a Designer view.
  2. In the Hierarchy panel, select a button for viewing bundle content.
  3. In the Details panel, click the + icon near the On Clicked event.
  1. Open a Graph view.
  2. Implement logic for displaying bundle content (a list of items in the bundle and the quantity of every item in the bundle). To do this, add nodes as shown in the following picture.

Implementar la visualización de paquetes de monedas virtuales

Crear una clase para el paquete de moneda virtual

  1. Go to Content Browser. There, in the contextual menu, click Blueprint Class.
  2. In the All classes section, select Object and click Select.
  3. Use BP_VcPackItemData as a class name.
  4. Open a blueprint of a created class.
  5. In the My Blueprint panel, click Add New and select Variable.
  6. In the Details panel:
    1. Specify PackItem in the Variable Name field.
    2. Select VirtualCurrencyPackage in the Variable Type field.
    3. Check Instance Editable and Expose on Spawn boxes.

Crear widget de paquete de moneda virtual

  1. Go to Content Browser and create a UI directory. In the contextual menu, go to User Interface > Widget Blueprint.
  2. In the widget blueprint, add the following UI elements:
    • package name
    • package price

The following picture shows an example of the widget structure.

  1. Open a Graph view.
  2. Click Class settings.
  3. In the Details panel, go to Interfaces > Implemented interfaces.
  4. Click Add and select UserObjectListEntry. This is a standard UE interface that allows the UI primitive to implement a behavior normal for the element of the list.
  5. Implement logic for creating a group of items:
    1. Add the EventOnListItemObjectSet node to create an element of the list and initialize the widget.
    2. Pass the value from the object that contains data about the package to the element with the name and a price of the package. To do this, add nodes as shown in the following picture.

Agregar la lista de paquetes de moneda virtual a la página del catálogo

  1. Open the catalog page widget blueprint.
  2. Add the List View element to the display area for the list of virtual currency packages.
  3. In the Details panel, select a previously created class for a virtual currency package in the Entry Widget Class field.
  4. Implement logic for adding packages to the list:
    1. Open a Graph view.
    2. Link an UpdateVirtualCurrencyPackage method call connected with the XsollaStoreSubsystem object to the EventConstruct node and add passing of data entered by users.
    3. Implement logic for adding a package to the list. The action should be done while processing a successful update of local cache of virtual currency packages. To do this, add nodes as shown in the following picture.
Nota
The offset and limit parameters of the UpdateVirtualCurrencyPackage method are not required. Use them to implement pagination — a page-by-page display of items in the catalog. The maximum number of items on the page is 50. If the catalog has more than 50 items, pagination is necessary.
¿Te ha resultado útil este artículo?
¡Gracias!
¿Hay algo en lo que podamos mejorar? Mensaje
Lo sentimos
Por favor, cuéntanos por qué no te ha resultado útil este artículo. Mensaje
¡Gracias por tu mensaje!
Nos ayudará a mejorar tu experiencia.
Ocultar

Vender artículos virtuales a cambio de moneda real

This instruction shows how to use the SDK methods to implement selling of virtual items for real currency.

Before you start, implement a display of virtual items in a catalog. In the following example, we describe how to implement purchasing of virtual items. Configuration for other item types is similar.

The logic and interface in the examples are less complicated than they will be in your application. A possible implementation option for selling items for real currency and displaying a catalog of items is described in the demo project.

Código fuente
Consulte el código fuente de estos ejemplos en GitHub.

Completar widget de página del catálogo

  1. Open the catalog page widget.
  2. Open a Graph view.
  3. To open a payment page in a browser:
    1. Implement receiving of a payment token:
      1. Add the InitiatePurchase node and connect the FetchPaymenToken SDK method call linked to the XsollaStoreSubsystem object to the added node.
      2. To the FetchPaymenToken method, pass the SKU of a purchased item and a user authorization token.
Nota
You can use one of the following tokens:
    1. Call the LaunchPaymentConsole SDK method linked to the XsollaStoreSubsystem object and pass a payment token to it.

Example of the payment page opening implementation:

  1. Implement a purchase status check after closing the browser window:
    1. To track the browser closing event, subscribe to the BrowserClosed event.
    2. To check the purchase status, call the CheckOrder SDK method and pass an authorization token and order number to it.
Nota
Implementation of logic for adding purchased items to the inventory isn’t required — it’s done automatically.

Example of a purchase status check implementation:

Mejorar la clase de datos del artículo

  1. Open the BP_CatalogItemData blueprint.
  2. In the My Blueprint panel, click Add New and select Variable.
  3. In the Details panel:
    1. Specify CatalogWidget in the Variable Name field.
    2. In the Variable Type field, select W_StoreCatalog.
    3. Check the Instance Editable and Expose on Spawn boxes.

The result is that every element of the list will contain a link to a parent widget and will be able to call its methods.

Realizar la adición de lista de artículos a la página del catálogo

  1. Open a blueprint of a catalog page widget.
  2. Open a Graph view.
  3. Edit the logic for filling out the list of items as shown in the following picture.

Completar widget para un artículo

  1. Open a widget blueprint for an item.
  2. Add a button for purchasing an item.

The following picture shows an example of the widget structure.

  1. In the Hierarchy panel, select a button for purchasing an item.
  2. In the Details panel, click the + icon near the On Clicked event.
  1. Open the Graph view.
  2. Implement logic for clicking a button for purchasing an item. To do this, add the nodes as shown in the following picture.

As a result, when clicking the button for purchasing an item, a payment page opens in the browser according to the logic implemented in the catalog page widget.

¿Te ha resultado útil este artículo?
¡Gracias!
¿Hay algo en lo que podamos mejorar? Mensaje
Lo sentimos
Por favor, cuéntanos por qué no te ha resultado útil este artículo. Mensaje
¡Gracias por tu mensaje!
Nos ayudará a mejorar tu experiencia.
Ocultar

Vender artículos virtuales a cambio de moneda virtual

This instruction shows how to use the SDK methods to implement selling of virtual items for virtual currency.

Before you start, implement a display of virtual items in a catalog.

Nota
In the following example, we describe how to implement purchasing of virtual items. Configuration for other item types is similar.
Código fuente
Consulte el código fuente de estos ejemplos en GitHub.

The logic and interface in the examples are less complicated than they will be in your application. A possible implementation option for selling items for real currency and displaying a catalog of items is described in the demo project.

To implement selling of virtual items for virtual currency:

  1. Add logic for purchasing an item to the widget for the catalog page.
  2. Add a mechanism to an item class to initiate the logic for purchasing an item.
  3. Refine adding a list of items to the catalog page.
  4. Add a purchase button to the widget for an item.
  5. Add the logic of buying for virtual currency to the widget for an item:
    1. Open a blueprint of the widget for an item.
    2. Go to the Graph view.
    3. Add nodes as shown below.

This will result in a virtual currency price that is specified for an item will display in the widget and is used to purchase the item. If an item is priced in multiple virtual currencies, the first virtual currency in the list will be used for display and purchase.

¿Te ha resultado útil este artículo?
¡Gracias!
¿Hay algo en lo que podamos mejorar? Mensaje
Lo sentimos
Por favor, cuéntanos por qué no te ha resultado útil este artículo. Mensaje
¡Gracias por tu mensaje!
Nos ayudará a mejorar tu experiencia.
Ocultar

Visualización de artículos en el inventario

This tutorial shows how to use the SDK methods to display items in the user inventory.

The logics and interface in the examples are less complicated than they will be in your application. A possible item catalog in an in-game store implementation option is described in the demo project.

Código fuente
Consulte el código fuente de estos ejemplos en GitHub.

Crear widget para la página del inventario

  1. Go to Content Browser and create a UI directory.
  2. In the contextual menu, go to User Interface > Widget Blueprint.
  3. In the widget blueprint, add the display area for the list of items.

The following picture shows an example of the inventory structure.

  1. Open a level blueprint:
    1. Choose a level in Content Browser.
    2. In the main menu, go to Blueprints > Open Level Blueprint.
  2. Implement the widget display when the level is started. To do this, add nodes as shown below. In the CreateWidget node, specify the created widget.

Crear clase para un artículo

  1. Go to Content Browser. There, in the contextual menu, click Blueprint Class.
  2. In the All classes section, select Object and click Select.
  3. Use BP_UserInventoryItemData as a class name.
  4. Open a blueprint of a created class.
  5. In the My Blueprint panel, click Add New and select Variable.
  6. In the Details panel:
    1. Specify UserInventoryItem in the Variable Name field.
    2. Select InventoryItem in the Variable Type field.
    3. Check Instance Editable and Expose on Spawn boxes.

Crear widget para un artículo

  1. Go to Content Browser and create a UI directory and, in the contextual menu, go to User Interface > Widget Blueprint.
  2. In the widget blueprint, add the following UI elements:
    • item name
    • item feature:
      • for subscriptions — subscription status (active or expired)
      • for consumable items — quantity of items
      • for nonconsumable items — no feature is displayed

The following picture shows an example of the widget structure.

  1. Open a Graph view.
  2. Click Class settings.
  3. In the Details panel, go to Interfaces > Implemented interfaces.
  4. Click Add and select UserObjectListEntry. This is a standard UE interface that allows the UI primitive to implement a behavior normal for the element of the list.
  5. Implement logic for creating an item:
    1. Add the OnListItemObjectSet node to create an element of the list and initialize the widget.
    2. Pass the value from the object that contains data about the item to the element with the name of the item. To do this, add nodes as shown in the following picture.
    1. Implement logic for defining an item type by passing the data about the item according to its type to the element with the item features. To do this, add nodes as shown in the following picture.
    1. Add logic for defining the subscription expiration time. To do this, add nodes as shown in the following picture.

Añadir lista de artículos a la página del inventario

  1. Open the inventory page widget blueprint.
  2. Add the List View element to the item list display area.
  3. In the Details panel, select a previously created class for an item group in the Entry Widget Class field.
  4. Implement logic for adding items to groups:
    1. Open the Graph view.
    2. Link an UpdateInventory and UpdateSubscriptions consecutive SDK methods call connected with the XsollaInventorySubsystem object to the EventConstruct node as shown in the following picture:
    1. Implement logic for filling out the list of items. To do this, add nodes as shown in the following picture.
¿Te ha resultado útil este artículo?
¡Gracias!
¿Hay algo en lo que podamos mejorar? Mensaje
Lo sentimos
Por favor, cuéntanos por qué no te ha resultado útil este artículo. Mensaje
¡Gracias por tu mensaje!
Nos ayudará a mejorar tu experiencia.
Ocultar

Visualización del saldo de moneda virtual

This tutorial shows how to use the SDK methods to display the balance of virtual currency in your app.

In the example, we show virtual currencies and their balance in the user inventory. Therefore, you should implement display of items in the user inventory before you start.

The logics and interface in the examples are less complicated than they will be in your application. A possible item catalog in an in-game store implementation option is described in the demo project.

Código fuente
Consulte el código fuente de estos ejemplos en GitHub.

Crear clase para la visualización de saldo

  1. Go to Content Browser. There, in the contextual menu, click Blueprint Class.
  2. In the All classes section, select Object and click Select.
  3. Use BP_VcBalanceItemData as a class name.
  4. Open a blueprint of a created class.
  5. In the My Blueprint panel, click Add New and select Variable.
  6. In the Details panel:
    1. Specify VcBalanceItem in the Variable Name field.
    2. Select VirtualCurrencyBalance in the Variable Type field.
    3. Check Instance Editable and Expose on Spawn boxes.

Crear widget para la visualización del saldo

  1. Go to Content Browser and create a UI directory and, in the contextual menu, go to User Interface > Widget Blueprint.
  2. In the widget blueprint, add the following UI elements:
    • virtual currency name
    • virtual currency quantity

The following picture shows an example of the widget structure.

  1. Open a Graph view.
  2. Click Class settings.
  3. In the Details panel, go to Interfaces > Implemented interfaces.
  4. Click Add and select UserObjectListEntry. This is a standard UE interface that allows the UI primitive to implement a behavior normal for the element of the list.
  5. Implement logic for adding a virtual currency to the list:
    1. Add the EventOnListItemObjectSet node to create a list element and initialize the widget.
    2. Pass the values from the object that contains data about the virtual currency to the elements with the name of the virtual currency and its quantity. To do this, add nodes as shown in the following picture.

Completar widget para la visualización del inventario

  1. Open the inventory page widget blueprint.
  2. Add the List View element to the virtual currency list display area.
  3. In the Details panel, select a previously created class for balance display in the Entry Widget Class field.
  4. Implement logic for filling out the list of virtual currencies:
    1. Open a Graph view.
    2. Link an UpdateVirtualCurrencyBalance method call connected with the XsollaInventorySubsystem object to the EventConstruct node.
    3. Implement logic for filling out the list of virtual currencies. The action should be done while processing a successful update of the local cache of the virtual currency balance. To do this, add nodes as shown in the following picture.
¿Te ha resultado útil este artículo?
¡Gracias!
¿Hay algo en lo que podamos mejorar? Mensaje
Lo sentimos
Por favor, cuéntanos por qué no te ha resultado útil este artículo. Mensaje
¡Gracias por tu mensaje!
Nos ayudará a mejorar tu experiencia.
Ocultar
¿Te ha resultado útil este artículo?
¡Gracias!
¿Hay algo en lo que podamos mejorar? Mensaje
Lo sentimos
Por favor, cuéntanos por qué no te ha resultado útil este artículo. Mensaje
¡Gracias por tu mensaje!
Nos ayudará a mejorar tu experiencia.
Valore esta página
Valore esta página
¿Hay algo en lo que podamos mejorar?

Prefiero no responder

¡Gracias por tu mensaje!
Última actualización: 10 de Octubre de 2023

¿Has encontrado una errata u otro error de texto? Selecciona el texto y pulsa Ctrl+Intro.

Informar de un problema
Nos esforzamos por ofrecer contenido de calidad. Tus comentarios nos ayudan a mejorar.
Déjanos tu correo electrónico para que te podamos responder
¡Gracias por tu mensaje!