question

gordon avatar image
gordon asked

Economy V2 - Adding Virtual Currency

Hi,

If we wanted to award a player virtual currency through our backend or game servers, what is the API we should be using? The Quickstart, under "Granting Currencies" suggests to use *AddInventoryItems*.

This API expects an "ItemId". I have tried supplying:

- The id of the virtual currency

- The id of a bundle that awards currency (which works when purchasing via Steam and then redeeming)

- Another item, to test, that has nothing to do with currency.

In all cases, my JSON body for the call looks like:

{
  "Item": {
    "Id": "id-of-item"
  },
  "Entity": {
    "Id": "playfab-id-of-player",
    "Type": "master_player_account"
  },
  "Amount": 3,
  "ReturnInventory": false
}

And in all cases I'm getting a response of

{
    "code": 400,
    "status": "BadRequest",
    "error": "InvalidRequest",
    "errorCode": 1071,
    "errorMessage": "Asset (id-of-item) was not found."
}

Can you advise on what I'm doing wrong here?

10 |1200

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

Xiao Zha avatar image
Xiao Zha answered

You may change the Entity property to title player account and since you are not specifying the Item StackId , the item will be in the default stack. For better management the Items, you can specify a StackId. You can refer to Inventory Stacks - PlayFab | Microsoft Learn to have more information about Stack.

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 was able to work this out. For anyone in future encountering the same issue, I needed to use the title_player_account and not the PlayFabId, but the Player Title Id instead.

Makes some sense in hindsight.

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.