question

gordon avatar image
gordon asked

Economy V2 Real Money Purchase Flow with Steam

Hi,

I am trying to scope out what the order of operations and associated API calls are that are required to make a real money purchase through Steam. I am trying to do this using Economy V2 since it's now the recommended approach for new titles to take.

From reading the Steam documentation for IAP (found here https://partner.steamgames.com/doc/features/microtransactions/implementation), I see the flow Steam expects is:

  1. The client will contact the game Backend (in our case, PlayFab of course), informing it of what it wants to purchase.
  2. The Backend will then call Steam's ISteamMicroTxn/InitTxn API to initiate the purchase. The Steam Client running the game will now display the purchase overlay and the user will go through the steps of purchasing.
  3. Once complete (assuming the user authorized), the client is then meant to tell its Backend to "finalize" the transaction, passing along the OrderId that was just completed.
  4. The Item is then granted to the user by the Backend.


Assuming my understanding is correct here, it is unclear to me exactly how the Economy V2 API maps to this. I am guessing/assuming, it would go like this:

  1. A call to PurchaseInventoryItems is made from the client on behalf of the player. From reading other threads on here, presumably we need to be purchasing a Bundle since that's the only type that can be mapped to an external store Id.
  2. PlayFab will then take care of calling ISteamMicroTxn/InitTxn on our behalf.
  3. The client listens for the callback telling it the player has authorized the purchase. After this, the next part isn't clear to me in terms of what we're meant to call on the PlayFab side. I assume it should be RedeemSteamInventoryItems. If so, there does not seem to be a field to specify the OrderId that the steam documentation says is needed for this step. Is this the wrong API that I'm expecting we should call here? Or, is PlayFab caching the OrderId itself, and not requiring it?
  4. Presumably the item is the granted to the user's Inventory by PlayFab

Can you help me understand/confirm whether the API calls in 1 and 3 are what we should be calling, and help clear up some of the confusion around how step 3 is intended to work?

Also, if this is correct, how does the call to PurchaseInventoryItems know to contact Steam - i.e. what dictates that it's a Steam purchase and not a different platform? Does it just know this based on how the user logged in for this session (i.e. he's logged in to PlayFab via Steam), or does the Bundle need to have exactly 1 external store mapping?

Thanks for any help you can offer

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

kylemc@microsoft.com avatar image
kylemc@microsoft.com answered

Economy v2 integration with Steam requires you to make the purchase in the Steam marketplace and then sync it into PlayFab. For example, you could purchase a virtual currency bundle in Steam and then redeem it into PlayFab. The design is much closer to the DLC flow than the MTx flow.

Downloadable Content (DLC) (Steamworks Documentation) (steamgames.com)

Economy v2 integrates with the Steam Inventory API. As long as your Steam purchases result in inventory update then they can be synced into PlayFab via the `RedeemSteamInventoryItems` API.

ISteamInventory Interface (Steamworks Documentation) (steamgames.com)

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

gordon avatar image
gordon answered

Oh, ok - thank you @kylemc@microsoft.com. I was way off, then, and it doesn't look like PlayFab ties into the MTX functionality in Steam I linked to at all! That would certainly explain the confusion.

Interestingly, though, from reading the various threads when trying to work this out, it sounded like this is how it would've worked on Economy V1 due to the StartPurchase->ConfirmPurchase flow (e.g. see question 6 on https://community.playfab.com/questions/64959/migrating-to-economy-v2.html)

I have 2 additional questions, if you don't mind:

  1. Is this then the same idea for Xbox (Microsoft Store) and PlayStation Store - i.e. that all purchasing (of currency packs) happens entirely outside of PlayFab's knowledge and then we tell it to "redeem" from that store and it'll reconcile the PlayFab Inventory with the system-specific store? Presumably, then, PurchaseInventoryItems is only meant to be used for virtual currency purchases, and not real money?
  2. How would the awarding of the actual virtual currency to the PlayFab player's inventory happen with Economy V2? Let's say I bought a 500 Gold pack from Steam in the way you said and then that purchase is redeemed into my PlayFab account via a call to RedeemSteamInventoryItems, how do we then react to that and actually issue the 500 virtual currency to the player? Is there a built in mechanism for this, or do we need to write an Azure Function that responds to some event, and grant the currency ourselves? If so, what does that look like - are there any pointers/docs to get us started down the right path there?

Thanks for your help. The documentation isn't really clear on this topic right now - I read and re-read it multiple times before asking.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

kylemc@microsoft.com avatar image
kylemc@microsoft.com answered

This is the best guidance today (and the alternate id names are incorrect :/ I'll open a bug).

Fraud prevention quickstart - PlayFab | Microsoft Learn

The short version is:

1. The design is the same for every marketplace. That was why we chose to diverge from the V1 Steam integration design. You're correct that "Purchase" is designed for transactions within PlayFab and will not initiate anything with the marketplaces.

2. Create a bundle with the VC, add a marketplace mapping (in the UX, it's an AlternateId in the API) with the value equal to the store product id (it's the "itemdefid" for Steam), call redeem, and debug it until it works :P.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

gordon avatar image
gordon answered

Hi,

Thanks once more for your help, @kylemc@microsoft.com.

For #1, this is good to know - that should make things easier.

For #2, this mostly makes sense to me now, except the "Create a bundle with the VC", which is a bit too vague to be useful in this context. I assume you mean to create a bundle, which contains an Item which, in turn, will award the currency to the player once redeemed. So, creating the bundle and adding the item to it seems relatively simple through GameManager or the API - but I do not see how to set up an item such that it would award the player currency when redeemed through the marketplace.

If there's documentation on this that I'm missing, please point me to it but I'm not seeing it right now.

I see how to create a new currency (e.g. "Gold") here.

And I see a single section about creating an item itself here.

But where are the details on how that item should be set up such that it awards the VC once redeemed? I don't see any mention of it in the schema here. Do we just give it a "price" and, since it was redeemed through the external marketplace, that price is then translated into an award of that currency amount to the player's "wallet"? I'm assuming it would work the same way as is mentioned in "Granting Currencies" here, where it says, "You can call AddInventoryItems to add currency to an Entity Wallet. By default, you need to use Title Level Entity Auth to arbitrarily add virtual currencies to a player’s inventory." - but it doesn't explain there, either, so it's not exactly clear.

Again, if I'm just missing somewhere in the docs that detail this process, please just point me to that - but so far it is not clear to me how it's supposed to work.

Thanks

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

gordon avatar image
gordon answered

I worked it out through trial and error.

For others facing similar confusion due to lack of details in the documentation (as it stands, I understand it's in preview), you need to create a Bundle in the GameManager, then under the Bundle's "Items" be sure to choose the Currency itself as the item, and then it'll let you choose how much of that to award upon purchase of this bundle.

That, combined with the matching of the Id in the Marketplace Mapping is enough to get it work.

There is one thing I still haven't fully come to terms on and that's whether the Steam item should be set up to be consumable or not, so the purchase doesn't show up as an "item" in their steam inventory, but I will test things out to see how it works.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Ahmad avatar image Ahmad commented ·

can you further explain this please?

i created an steam item

purchased it

it's now in my steam inventory

what should i do to read it through playfab

i created a placeholder item

and i created a bundle with marketplace steam and marketplace id equal to the steam item id but when i call redeem steam inventory items, nothing happens, it returns an empty response

0 Likes 0 ·
Derek Reese avatar image
Derek Reese answered

Alternate ID's documentation has been fixed: Fraud prevention quickstart - PlayFab | Microsoft Learn

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.