question

raghav22355 avatar image
raghav22355 asked

How can I make a single API call, and are there alternative methods for adding virtual currency besides 'virtual currency'?

Hey, since PlayFab doesn't have any in-app purchase verification for Oculus, I have to use an API to confirm it via Cloud Script. My JavaScript is running on my local device but not on Cloud Script; it's not waiting for the API response. So, I have decided to use Azure. I have set up a function in Azure, and it is working well.

PlayFab has the option to register a Cloud Script function to add my HTTP URL there. PlayFab will call it (why can't we just call it from the client?).

This will be one API call. But when my API call is successful, I need to add virtual currency. So, again, I need to make one more API call from Azure to PlayFab to add virtual currency.

Is there a way to cut this process? Do a single API call?

Also, "AddUserVirtualCurrency" is the option to add virtual currency. Is there any other way to add it that will be visible in the inventory history?

Please let me know

apisCloudScriptIn-Game Economygame manager
10 |1200

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

1 Answer

·
Neils Shi avatar image
Neils Shi answered

PlayFab has the option to register a Cloud Script function to add my HTTP URL there. PlayFab will call it (why can't we just call it from the client?). This will be one API call. But when my API call is successful, I need to add virtual currency. So, again, I need to make one more API call from Azure to PlayFab to add virtual currency. Is there a way to cut this process?

Exposing the function URL to players and letting them call Azure functions directly from the client has security risks (players may directly call the function to increase their currency). Register the Cloud Script function in PlayFab, and let players call API ExecuteFunction to execute the function can protect your function url from being exposed. And it will provide additional security measures (such as authentication) for your functions, players need to login first so that they can call the API ExecuteFunction. If you want to simplify the process and just call only one API (for example : let the players call the client API AddUserVirtualCurrency directly), players can cheat by adding virtual currency to their accounts directly in the client side via this API, which will affect the security of the game. So, we don’t recommend you cut this process.

Also, "AddUserVirtualCurrency" is the option to add virtual currency. Is there any other way to add it that will be visible in the inventory history?

The API AddUserVirtualCurrency is the only way to add virtual currency to players directly. Or you can add virtual currency to the bundle, then add the bundle which contain virtual currency to players via API GrantItemsToUser.

3 comments
10 |1200

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

raghav22355 avatar image raghav22355 commented ·

Hey Neils Shi,

Thanks for your response. Anyway, we have a meta API to confirm the purchase (it doesn't matter if the URL gets leaked). After using GrantItemsToUser, I even set up the price (RM), which shows up in VirtualCurrency as 100 coins for 1$. When I GrantItem to my player, the total spent number doesn't show up in the PlayFab dashboard. Is there a way to increase/update it?

Question 2: Is there a way to test the PlayFab cloud script code before uploading it locally?

Question 3: Our PlayFab ID is getting leaked every time. Is there a way to securely ship it to the game?

0 Likes 0 ·
raghav22355 avatar image raghav22355 commented ·

Hey Neils Shi,

Thanks for your response. Anyway, we have a meta API to confirm the purchase (it doesn't matter if the URL gets leaked). After using GrantItemsToUser, I even set up the price (RM), which shows up in VirtualCurrency as $1 (100 coins). When I GrantItem to my player, the total spent number doesn't show up in the PlayFab dashboard. Is there a way to increase/update it?

Question 2: Is there a way to test the PlayFab cloud script code before uploading it , on locally?

Question 3: Our PlayFab ID is getting leaked every time. Is there a way to securely ship it to the game?

0 Likes 0 ·
Neils Shi avatar image Neils Shi raghav22355 commented ·

After using GrantItemsToUser, I even set up the price (RM), which shows up in VirtualCurrency as 100 coins for 1$. When I GrantItem to my player, the total spent number doesn't show up in the PlayFab dashboard. Is there a way to increase/update it?

The API GrantItemsToUsers is used to add the specified items to user inventories, this API does not subtract the player's virtual currency, and the game manager will not record the total spend.

Is there a way to test the PlayFab cloud script code before uploading it locally?

If you want to test your Azure Function locally before deploying it, you can refer to Local debugging for Cloudscript using Azure Functions - PlayFab | Microsoft Learn。

Our PlayFab ID is getting leaked every time. Is there a way to securely ship it to the game?

In fact, PlayFab ID is not sensitive information, even if players know it, it will not help them cheat.

0 Likes 0 ·

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.