In my game, you can use virtual currency(gold coins) to buy items(for example clothes, weapons,...). You can get virtual currency on three different ways:
1) Collect gold coins when in the levels, after you finished the level, the gold coins will be added to your PlayFab account.
2) You can win gold coins if you get the first, second or third rank in a weekly leaderboard on PlayFab.
3) You can make in-app purchases(only consumable products) with real money(for example 1 USD = 1000 gold coins) to get gold coins. The gold coins should be added immediately to the PlayFab account after you did the purchase.
I'm new to PlayFab and I have not yet implemented 1), 2), 3) to my game because I'm not sure how to implement the virtual currency and real money in-app purchases.
Until now I have just tested in-app purchases in the Apple App Store and Google Play. The user can purchase the 1000 gold coins in my game and they are added in my game to the user's current amount of gold coins. But PlayFab doesn't know if the user made an in-app purchase and I don't know how to add the 1000 gold coins to the user's PlayFab account. How can I connect PlayFab with Apple/Google so that PlayFab knows that the user made an in-app purchase?
Is it possible to add the obtained gold coins(after an in-app purchase or after a level is finished) immediately to the user's PlayFab account without saving the amount of gold coins in a save game file on the users's device?
For example, if the user has no internet connection at this moment(when he finished the level), then there would be a button to retry sending the data to PlayFab or the user could just continue to play but his gold coins that he got in this level would be lost forever.
I know that I could save the amount of gold coins in a save game file on the user's device and later(for example when the user starts the game again) I could upload the amount of gold coins to the user's PlayFab account. But I think that wouldn't be a good idea because the user could manipulate his save game file(for example he could just add 5000 coins) and then a wrong/cheated amount of gold coins would be added to his PlayFab account.
How can I add virtual currency to a PlayFab account so that the user can not easily cheat?