question

tinytap avatar image
tinytap asked

is there plan to support 'Purchase Item' api on serverside?

Are you guys plan to support server api for 'Purchase Item'? Suppose that we purchase item using client api and that item has abilities then as I worked around it should call 'UpdateUserInventoryItemCustomData' from the client again. so it takes longer time in mobile network situation. But if 'PurchaseItem' is also server api then we can make it together in server side using CloudScript. plus it takes small time because server to server ping-pong.

Brian Choi

apis
10 |1200

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

brendan avatar image
brendan answered

It's in our backlog, but not in our schedule (https://docs.microsoft.com/en-us/gaming/playfab/roadmap/). I would recommend liking the existing Feature Request for this, to try to help with prioritization: https://community.playfab.com/idea/5965/allow-purchaseitem-from-server-api-or-allow-getsto.html

10 |1200

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

Citrus Yan avatar image
Citrus Yan answered

At server-side, you can combine the Server/GrantItemsToUser and SubtractUserVirtualCurrency API to simulate the “Purchase Item” process, and use UpdateUserInventoryItemCustomData afterward.

Or, this approach might also works:

  1. Continue to use Client/PurchaseItem.
  2. Set up a Rule that acts on the player_inventory_item_added event by running a CloudScript Function that calls the UpdateUserInventoryItemCustomData API to add the custom data for that specific item. Every time an item is added to the player’s inventory, it automatically runs a CloudScript to update the custom data, and, you can also add some conditions to help filter out some items that “has no abilities”.
10 |1200

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

Redmond Urbino avatar image
Redmond Urbino answered

This worked for us. The client passes the client session ticket to the azure function. Using that session ticket, the server can call PlayfabClientApi.PurchaseItem.

10 |1200

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

Priel Gaier avatar image
Priel Gaier answered

@Redmond Urbino
i've encoutared the same issue, does the server still can't call server.PurchaseItem or is it just named differentaly?Also the server can't get store items and i need to check the prices and verify them on the server before the player can make any purchases. Have you encoutered the same issue?

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.