question

moonbasedesign avatar image
moonbasedesign asked

Code strategy for adding virtual currency from IAP on Unity with PlayFab

We've got a Unity IOS/Android project using the PlayFab Legacy economy.

I'm looking for a strategy for adding virtual currency from IAP purchases. It appears that the AddUserVirtualCurrency() end point is vulnerable to hacking if it appears in client code. So far I'm calling ValidateIOSReceipt in the ProcessPurchase function of the Unity IAP Flow.

I want to use a data driven approach so I intend to put a "Payload" value into the PlayFab.CustomData field in my IAP items. I will parse this to add specific values to a player's virtual currency account.

Should I be calling a cloudscript from the OnSuccess block of the Validate Receipt function?

Thanks

In-Game Economy
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

·
Infer Wang avatar image
Infer Wang answered

You can use the (game manager->Economy-> Catalogs (Legacy)->Bundles), add the Virtual Currency and its quantity to the Bundles Contents, set the consumable by time. The users can use ValidateIOSReceipt to purchase bundles instead, after that, the virtual currency in the bundle will go to the users' inventory automatically. In this way, you don't need to use the cloudscript and custom data in the item.

2 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.

moonbasedesign avatar image moonbasedesign commented ·

Nice solution. I just tried it and it worked nicely.

Is this entirely server-side? That is, safe from client hacking?

0 Likes 0 ·
Infer Wang avatar image Infer Wang moonbasedesign commented ·

The purchase part is client side, bundle releasing content to inventory is server side. So, it's relatively safe from client hacking.

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.