Microtransactions
Aka MTX, IAP, In App Purchase, cash shop, etc.
Introduction
You cannot test Steam Inventory features with App ID 480 aka Spacewars.
To test Steam Inventory features including but not limited to microtransactions, crafting, player inventory, etc. you will need to register for your app ID and configure your own Steam Inventory Items. As a result of this limitation from Valve, the sample scenes for Inventory cannot be used with App 480 in any functional form.
A common request we see is for an example in-game store or other "MTX" (micro-transaction) example.
Valve's Spacewar doesn't have a usable Steam Inventory configuration and since your store would be highly dependent on what items you have and how they are configured. The sample scene we have provided (9 Item Store Tutorial) simply contains example scripts based on this article and is meant to be a teaching tool, not a functional example.
In-Game Currency
Your in-game currency would simply be an inventory item. You would then set up "Exchange" recipes for all the items that can be "purchased" for that currency.
Unity Examples
Testing Inventory Change
So you have set up your inventory items, You are going to use full Client API so you can't simulate an end-to-end purchase. You're asking yourself ... How do I test my game logic to make sure it's handling inventory change correctly?
Start Purchase
This is done when you want to send the user to the Steam Store page so they can "check out" spending real money on some item. Note you can call Start Purchase on a single item or you can set up a shopping cart building up a collection of items and call Start Purchase on all of them.
We have constructed a tool to help you manage a shopping cart in the game. This tool is capable of adding, removing and editing the quantities of items in it, it can report the estimated total of the cart and can manage and track the purchase operation through authorization reporting issues and or successes through simple Unity events.
Manual
On your Item Definition, you will see a Start Purchase option. A similar method is available on the Data Layer, Scriptable Object and of course in the Inventory API. You simply call this method indicating the number of items you wish to start a purchase with.
If the item has a properly formatted price or price category (it cannot have both) then the item will be added to the user's Steam Store cart ready for purchase. The Steam Overlay will open showing the user this cart.
When the user completes the transaction you will be notified in two ways.
You can also start purchase on a set of items, the following is the code from our Shopping Cart tool and how it handles this use case.
Exchange
The first step in this process is the CanExchange check.
Get Item Price
Unreal Examples
Testing Inventory Change
Start Purchase
The Start Purchase function asks Steam to load a shopping cart with given items and present it to the user for payment processing. Only items that have a defined price can be purchased, only items available to this user can be purchased. Steam will process the payment from that point forward and you are not assured of getting a response. For example, a player may simply leave the cart open and never process the transaction, they may cancel the transaction, modify items in the cart, etc.
Exchange
To use the feature you first need to know what item ID you want to "craft" i.e. exchange other items for.
Next, you need to know the instance ID and count of each item you will be exchanging. You typically get the Instance IDs from the Get All Items request but you can for example cascade crafting requests.
An example of a cascaded crafting request would be to craft Iron Ore into Iron Bars and then craft the Iron Bars into an Iron Sword. That is your exchanging 1 or more Ore items for Bars and 1 or more Bars for Sword.
The following image is an example of creating the "recipe" array needed by the Exchange Items node. In this example, we assumed we needed 15 of some item and if we had 2 stacks of 10 each with IDs of 123 and 124 respectively then the below "Make Array" node would be the correct recipe.
In the example, we are using all of stack 123 and 5 from stack 124.
If you are setting up an in-game store or some similar microtransaction system you will likely want to know what the price of the item is for this user.
Notice that the event tells you the currency code and currency symbol seen for the user and that prices are returned as a whole number e.g. int64
In the case of say USD you would want to convert the price to a float and divide by 100 so that 199 becomes 1.99
The above are the relevant nodes to yield a string formatted for the user's currency assuming a cent-based currency like USD, GBP, etc. The resulting string here would look like this `$1.99" assuming a base price of 199 and a currency symbol of $
Last updated