Guide: Steam Store
Baroni last edited by Baroni
This guide explains how to configure Steam payments for use in Simple IAP System, viable on Standalone platforms running the Steam Client (Windows or Mac).
Table of Contents:
- Connecting Steam with PlayFab
- Importing Steam SDK in Unity
- Testing payments
You will need to register for a Steamworks developer account, where you are able to publish your game to the Steam ecosystem. The creation of a Steam/developer account is not something described here, so it is assumed that you already have a verified and registered Steam account.
Just know that to publish your game in Steam, you will need to pay $100 for creating a unique AppID that acts as an identifier for your game. This AppID is very important for setting up payments in Simple IAP System as well. Note that the application you create in Steamworks needs to be of type "Game" (not "Application", "Video", etc.), otherwise the in-game overlay popup for authorizing payments will not show up!
Additionally, since Steam payments are passed through the player's account on PlayFab, it is required that you've gone through our PlayFab integration guide (Full Suite) as well and understand all limitations implied by this dependency. Namely, your app needs an active internet connection at all times, in addition to providing a login system for restoring user purchases between sessions - if you are using our sample "UserLogin" scene, the latter is already handled, since it automatically signs you into PlayFab using your active Steam account.
2. Connecting Steam with PlayFab
Steam payments are a separate extension on your title's PlayFab page, which you can find in the Add-ons > Monetization tab. Click on the Steam Add-on and enter the required details to enable it within PlayFab.
Enter the AppID that has been assigned for your application in Steamworks
- Enter the Steamworks publisher web API key that can be created in your app group, as described on this page
- Enable "Use Steam Payments sandbox endpoint for test transactions"
3. Importing Steam SDK in Unity
After importing the package into your Unity project, please follow along with the other "Unity Instructions" that are written on the installation page above, specifically entering your own AppID and restarting Unity.
Next, add the SteamManager script to a new empty game object in your first login scene. If you do not have your own PlayFab login scene, you can use our "UserLogin" sample scene and do it there. This script is responsible for establishing a connection between your game binaries and the Steam network on launch.
The SteamManager script has a nice "DRM" function built in. It checks whether the Steam client is running, and will start it if it's not - via SteamAPI.RestartAppIfNecessary (more on this page). To make it work properly, open the SteamManager script, scroll down to the SteamAPI.RestartAppIfNecessary call and replace "480" with your own AppID.
This is optional: while you're at it, you could add an #IF PLAYFAB_STEAM define at the very top of the script (and an #endif at the last line), so that it only compiles for the standalone platform, when Steam has been chosen in Simple IAP System's Plugin Setup window.
Lastly, open Simple IAP System's PluginSetup window (Window > Simple IAP System > Plugin Setup) and make sure that Standalone = Playfab Steam and PlayFab Service = Full Suite is selected.
4. Testing payments
Testing Steam payments requires the Steam overlay to show up (where you are able to authorize in-app purchase transactions). The Steam overlay visibility can be a bit inconsistent at times, especially if you are launching your game right within Unity. Because of that, it is recommended to just "Build" - not "Build & Run" your game with Unity. After you created the build, move it to your \Steam\steamapps\common<game folder> directory. Log into the Steam Client with your Steamworks developer account. Press ADD A GAME > Add a Non-Steam Game and link the game executable. Then, run it from within Steam - the Steam overlay should show up at launch, as expected. If you are making a new test build, make sure to replace the existing executable in that steamapps directory (so that you don't have to re-link it) and launch it from Steam as before.