question

Esteban Feldman avatar image
Esteban Feldman asked

[Unity] Play Store In App Purchases, In Game Currency and Playfab

Hi, new to Playfab...

Have some doubts on how to implement the whole In App Purchases and In Game Currency with Playfab.

In my game you can buy bundle of coins from the Play Store that then can be used to spend in game to buy things like extra lives, extra balls etc...


The player can also Collect Coins (free) in Game, he earn them in gameplay.

So, until now, I was just using Unity IAP to manage the purchases and I was adding the coins to the user Wallet locally in the device, now I want to make this cross device based on User Google Play Service ID so when the user either deletes the Game and installs it again, or he goes to a new device, he can retrieve whatever he purchased.

I was able to link Google Play Service with Playfab but I'm really confused on how to proceed with the Virtual Currency in Playfab.

Sorry it's kind of vague... but I can't really understand how to link the results of purchases from Google Play services using Unity IAP with Playfab and then keep a record of what the user spent in game etc...

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

·
brendan avatar image
brendan answered

I'd recommend reviewing these tutorials on our virtual currency and economy system: https://api.playfab.com/docs/tutorials#landing-commerce.

I think the confusion you're encountering is that you're attempting to force-fit your existing currency into the PlayFab service. What you should do is define the VC in our service, define the Catalog items for purchasing the VC, and then use receipt validation (or one or more of the non-receipt validation flows) to purchase the VC.

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

Esteban Feldman avatar image Esteban Feldman commented ·

@Brendan Hi, thanks for your answer, yeah I figured I got it kind of backward.

One thing I'm trying to figure out is when I add the coins purchased to the amount the Player already have in the backend (Game) ... Does applying the receipt will return me the total in the Players inventory? Or should I keep a local cache of the bundle coins qty to know how many to add to his local (game) inventory of coins?

Thanks.

0 Likes 0 ·
brendan avatar image brendan Esteban Feldman commented ·

Neither. I'd recommend calling GetUserInventory after the receipt validation has completed.

1 Like 1 ·
Esteban Feldman avatar image Esteban Feldman brendan commented ·

That makes sense.

Now in my game the user can collect coins... so what would be the way to add those "collected" coins to the inventory?

Thanks.

1 Like 1 ·
Show more comments
Esteban Feldman avatar image Esteban Feldman commented ·

@Brendan

If it's the former, you would use Server/AddUserVirtualCurrency from 
your custom game server or Cloud Script, so that you can have server 
authoritative logic to protect the call from abuse.

Sorry, this part I don't understand... When you mean to use server logic it would be something in the like of, the player collected 56 coins... execute a cloud script sending 56 and the currency type as parameter that will AddUserVirtualCurrency in the server?

0 Likes 0 ·
brendan avatar image brendan Esteban Feldman commented ·

Yes, I literally mean you could use a Cloud Script call to AddUserVirtualCurrency to add the coins, if it's a VC. But the point is that you could have logic in the script to check things like whether the score the player reported is reasonable, or when the last time was that the player reported a score, to make sure they're not just cheating by calling the Cloud Script directly.

1 Like 1 ·

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.