Skip to main content

Steam (via PlayFab)

This guide explains how to configure Steam payments in combination with PlayFab, viable on Standalone platforms running the Steam Client (Windows or Mac).

danger

Please note that PlayFab removed support for PlayFab-hosted Steam payments in their Economy V2 integration. Support in SIS will be removed soon too.

Prerequisites

You will need to register for a Steamworks developer account, where you are able to publish your game to the Steam ecosystem.

In order to publish your game in Steam, you will have to pay the "Steam Direct Fee" for creating an unique AppID that acts as an identifier for your game. Note that the application you create in Steamworks needs to be of type Game, otherwise the in-game overlay popup for authorizing payments will not show up!

PlayFab-Steam-Integration010

Additionally, since Steam payments are passed through the player's account on PlayFab, it is required that you've gone through the PlayFab integration guide 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.

info

In the sample login scene shipped with our PlayFab extension, the user is automatically signed into PlayFab using the currently active Steam account. Feel free to use this scene or adapt it for your game.

Create Web API Key

Steam payments are a separate add-on 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.

PlayFab-Steam-Integration110

  • Enter the AppID that has been assigned for your application in Steamworks
  • Create a Publisher Web API Key for your app group. Here is the official documentation on what Web API Keys are for. Under User & Permissions > Manage Groups you should already have a group named Everyone (WebAPI). Open the Group and make sure that:
  1. Your user is a member of the group with Admin permissions
  2. Your app and package is assigned to this group. The package ID can be found by navigating to Apps & Packages > View Packages
  3. On the right side, after clicking on "Create WebAPI Key" it is displayed below

PlayFab-Steam-Integration020

PlayFab-Steam-Integration030

  • On PlayFab, enter the Web API Key and enable "Use Steam Payments sandbox endpoint for test transactions"

PlayFab-Steam-Integration120

Importing Steam SDK in Unity

As a third-party Steam SDK, Steamworks.NET is a reliable solution. Head over to its installation page and download & import its latest unitypackage file (from GitHub releases).

  • As written in the SDK's "Unity Instructions", open the steam_appid.txt in your project's root folder and replace the number with your own Steam App ID
  • In the SteamManager script on line 99, replace AppId_t.Invalid with your own Steam App ID
  • Restart Unity

Next, add the SteamManager script to a new empty game object named SteamManager in your first login scene. If you do not have an own PlayFab login scene yet, you can use the login sample scene which is shipped with our PlayFab Extension package and do it there. This script is responsible for establishing a connection between your game binaries and the Steam network on launch.

PlayFab-Steam-Integration200

Optional: while you're at it, you could add an #IF PLAYFAB_STEAM define at the very top of the SteamManager 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 Project Settings.

Lastly, open Simple IAP System's Project Settings and set Standalone = Playfab Steam.

PlayFab-Steam-Integration210

Create in-app purchases

For a summary and best practices for using Steam Microtransactions, please refer to Steam's documentation. First we have to define what products we would like to sell. In Steamworks, go to Dashboard > Your App > Edit Steamworks Settings > Community > Inventory Service. Scroll down to the bottom to find a list of Item Definitions. An example of a JSON product schema can be found in Steam's Inventory Schema Documentation, or directly by going here.

PlayFab-Steam-Integration130

Below is an example of a valid JSON product schema:

  • replace the App ID with your own
  • it is recommended to start with an itemdefid (product ID) of 100 and increment by 100 for each product
{
"appid": "<YOURAPPID>",
"items": [
{
"itemdefid": "100",
"type": "item",
"name": "My Item 1",
"price": "1;VLV500",
"description": "My Item 1"
},
{
"itemdefid": "200",
"type": "item",
"name": "My Item 2",
"price": "1;VLV1000",
"description": "My Item 2"
}
]}

After uploading your JSON, the list of Item Definitions should be populated. Since Simple IAP System connects to PlayFab which then uses the Steam API to initiate a purchase, the product IDs need to be the same everywhere: SIS, PlayFab and Steam. Open IAP Project Settings in Unity and define your IAPs.

PlayFab-Steam-Integration230

Do the same in PlayFab.

PlayFab-Steam-Integration140

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 - mostly this will not work. Because of that, it is recommended to just Build - not Build & Run your game with Unity. After you've created the build, move it to your \Steam\steamapps\common\<game folder> Steam games 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.

PlayFab-Steam-Integration300

Then, run it from within Steam - the Steam Overlay should show up at launch, as expected. To verify this, press Shift-Tab.

PlayFab-Steam-Integration310

Trying to buy a product should then invoke the native Steam Overlay with the purchase dialog.

PlayFab-Steam-Integration320

If you are making a new test build later, make sure to replace the existing executable in that steamapps directory directly (so that you don't have to re-link it) and launch it from Steam as before.

Unsolved Errors

If you can’t see any products or if the Steam purchase Overlay does not show up at all, you may have some issues with your Unity/Steamworks settings and/or errors on the device.

As a summary, please verify that all of the following points have been met:

  • your Steamworks app is of type "Game" (not Application since that does not support the overlay)
  • on PlayFab, the Steam addon setting has the correct app ID and Web API Key (check spaces too)
  • in Steamworks, your app and package was added to the group with that Web API Key
  • the steam_appid.txt file in your project's root folder contains the correct app ID
  • you have uploaded Items to the Steam Inventory Service using a JSON file (with the correct app ID)
  • in-app product identifiers in the SIS Project Settings matches the ItemDefIds added in Steamworks
  • in-app product identifiers in the PlayFab catalog matches the ItemDefIds added in Steamworks
  • Standalone billing selection in the SIS Project Settings is set to "Playfab Steam"
  • you have placed the SteamManager script into your first game scene and start it from there
  • you have deployed the files at your Steam app location under "\Steam\steamapps\common\< game folder >"
  • you are logged in with your developer account when launching the Steam app
  • you have added the game to and starting from Steam (not Play Mode in Unity editor)
  • if the Steam Overlay (Shift-Tab) still does not open, recheck all app IDs entries!
info

Please note that in case of issues with this process, I am not able to guess or remotely debug the exact cause for you. Since a major part of this guide is not written for Simple IAP System in particular, there is a high chance that your issue has been experienced by many, many other developers before and is covered somewhere already - debug your device, do a Google search for the error message and look out for popular PlayFab or Steamworks developer threads!

tip

If you need help with the app setup, testing process or solving issues with your app's connection to PlayFab or Steam, I am providing extended support for this via a PREMIUM support purchase.

Please add me to your Steamworks partner account so I am able to verify all points above and do a test build. Navigate to Users & Permissions > Manage Users > Invite User:

PlayFab-Steam-Integration400

Explanation of required permissions:

  • Manage Users: view and edit the Web API Key
  • Edit App Metadata: view and edit Inventory and Economy settings
  • Publish App Changes To Steam: publish changes in above categories

After the invite and my acceptance, you will receive an additional email notification to approve my user.