question

Kim Strasser avatar image
Kim Strasser asked

Saving virtual currency only on PlayFab?

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?

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

·
Sarah Zhang avatar image
Sarah Zhang answered

>> 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?

Yes, It is. PlayFab’s API calls make it easy to set in-app purchases up for your game, giving you a reliable record of all real-money purchases and ensuring that players actually get the items they’ve bought, without saving data in a save game file.

>> How can I connect PlayFab with Apple/Google so that PlayFab knows that the user made an in-app purchase? & How can I add virtual currency to a PlayFab account so that the user can not easily cheat?

Please check this blog, follow its steps to learn how to use in-app purchase in PlayFab. In the last paragraph, there is some description about preventing cheating. For more detail, refer to Getting started with PlayFab, Unity IAP, and Android.

If you would like to learn more about GooglePlay in-app purchase in PlayFab, check this question GooglePlay In-AppPurchase to PlayFab Items please.

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.

Kim Strasser avatar image Kim Strasser commented ·

I have a question about the gold coins that the user can collect in a level. After finishing a level, the collected gold coins should be added to the user's PlayFab account. For example, if the user collected 50 gold coins in a level, then the 50 gold coins should be added immediately to his current amount of gold coins(for example 1200) on PlayFab. At the end, the user would have 1250 gold coins on his PlayFab account. How can I use the API to add the 50 gold coins to the user's PlayFab account? Do you have a tutorial about that?

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Kim Strasser commented ·

We don’t have any tutorial about adding virtual currency to the user's PlayFab account. But We suggest you to use Cloud Scripts to implement it. But if you are new in PlayFab, you should learn about Cloud Script firstly. Check the docs about Cloud Script for more. And you can use server API AddUser Virtual Currency to do it.

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.