Trial-based Premium

A guide on how to monetize your game using trial-based Premium

As we discussed in the What is Trail? and Setting Up Your Game articles; Trail has two components; the Trail Platform, it is represented by the The Game Manager and the Unity SDK.

πŸ“˜

This guide assumes that you are familiar with the game manager and will not discuss its different components. If you'd like to learn more about its different features we suggest you check out the Setting Up Your Game and The Game Manager articles first.

Creating a product

First, let's navigate to the Game Manager. Select your project (game) and then click on In-game purchases:

In-game purchases tab.In-game purchases tab.

In-game purchases tab.

It looks boring and empty, so let's change that by adding a new product. For the sake of this article, we'll imagine we have a single-player game, something similar to Sizeable for an example. So we'll create a product that essentially allows the player to play the full game after they've finished the demo.

First, let's click on the Create product button:

The add new product pop-up.The add new product pop-up.

The add new product pop-up.

The pop-up above will appear. Let's start by adding the item's name (we recommend using a descriptive name so the player doesn't feel confused when seeing the pop-up on Trail).

🚧

Be descriptive

It is important to be accurate and descriptive when naming your product. The name you enter will be shown to the player when buying and will appear on the receipt emailed to them.

Sizeable - Full Game is a good name because it tells the player what kind of item they are buying (the full game). A poor name would be something like Game where it might invite confusion as to whether they're paying for the full game or a portion of it.

In our case, this will simply be "Full Game" as it will unlock the full game experience for the player. Next, we add an image that represents the item -- again, it is a good idea to use the same image you're using in-game. In our case, we'll use an icon that represents our game. Finally, choosing the price tier. As mentioned in πŸ’°οΈ PaymentsKit article; Trail uses price tiers for selecting prices. For our example, we'll just pick $14.99:

The "New Product" window after adding in the information.The "New Product" window after adding in the information.

The "New Product" window after adding in the information.

πŸ“˜

Editing a product

You can edit a product after creating it by simply clicking on the created product's name. You can modify the icon and name. However, you can not modify the price tier. If you want to modify a price tier, you'll need to reach out to us on Discord

You'll notice a checkbox that says "Enable Upsell Window". We'll go through what it does in a separate article, so let's ignore it for the moment. Now click on the Add Product button:

How it looks after we added a new product.How it looks after we added a new product.

How it looks after we added a new product.

Once a product is created, it is marked as consumable and a unique product ID is generated for it, as seen in the above screenshot (last column). The product ID is very important as it is what you'll use to reference a product in code.

Displaying a product in-game

Now that we've set up a product, the next step is to show the product to the user so they can buy it. This can be done in myriads of ways and depends highly on your game. We won't get into details of how you can design or show the information to the player. Instead, we'll look at how you can obtain the information from Trail so you can use it in your design. The main piece of information you'd need from Trail is the price; the name and description of the product are most likely part of your own data already. So let's request a product price:

// Remember to initialize the SDK first.

private void RequestProductPriceFromTrail()
{
    // We tell Trail to send us the product ID
  SDK.PaymentsKit.GetProductPrice("ff148434-9d1c-11eb-b2d9-c7e44343d0cd", PriceRequestCallback);
}

// Callback that fires when the request is done
private void PriceRequestCallback(Result result, Price price)
{
    if(result.IsOK()) {
    // We then pass the price and the information to the game so it displays it for the player
    DisplayItem(itemName, itemDescription, price.ToString());
  }
  else {
    Debug.Log("Something happened when requesting price: " + result);
  }

πŸ“˜

What is price.ToString()

What price.ToString() does is combine the price and currency into one string. So in our example, it would say "3.99 Currency" where "Currency" in this case, is replaced with your regional currency (USD, Euro, etc...).

If you want to get the price amount and the currency separately, you can then use price.Amount for the amount itself and price.CurrencyISO4217 for the currency itself.

Next, the player will probably want to buy the item so we need to request a payment.

Requesting a payment

Let's go back to Unity:

// Remember you need to initialize the SDK first.

private void RequestPaymentFromTrail()
{
    // Here we request the payment.
    Trail.PaymentsKit.RequestPayment("ff148434-9d1c-11eb-b2d9-c7e44343d0cd", RequestPaymentCallback);
}

private void RequestPaymentCallback(Result result, Trail.UUID orderID, Trail.UUID entitlementID)
{
  // We check if the result of the request is good to go.
  if (result == Result.IsOK()) {
    // Purchase was successful, report it to the game backend
    MyGameBackend.ReportPurchase(userID, orderID, entitlementID);
  }
  else {
    Debug.Log("something went wrong while requesting payment: " + result);
  }
}

Let's go over the code; first, we create a Trail.UUID that is required to request the payment, similar to what we did when we wanted to get the price. Next, we send a RequestPayment using the UUID and wait for the request to finish. Once it is done, the callback RequestPaymentCallback will run. We check if the result is good to go. If so, we report it to our back end to start the next step (note that you receive both the orderID and entitlementID in the callback. If not, we print the error out so we can debug it.

Keeping the entitlement

As discussed in the πŸ’°οΈ PaymentsKit article; a consumable product produces an entitlement (basically a receipt or a contract stating the player's ownership of the items bought) so you can consume it in your backend.

However, in case your game does not have its own backend for keeping track of your players' purchases, you can - instead of consuming the entitlement - simply keep the entitlement around. You can then use the SDK method PaymentsKit.GetEntitlements at any time to check if the player has paid for access to the full game or not.