Hello!
I'm having an issue with purchasing items, where PlayFab.PurchaseItem actually purchases several instances of an item and spends the player's currency for no reason whatsoever. My code is simple and should work perfectly according to the logic. I really need some help, as I'm releasing my game in a week, and this is the only thing left to fix.
Answer by Brendan · Nov 03, 2017 at 02:16 AM
Testing in my own sample title, I can't reproduce what you describe. One call to PurchaseItem results in one purchase of the item, for the correct price from the catalog. Can you please provide us the following specifics, so that we can review the logs:
TitleID is 1F03
PlayFab ID of the test user:
ItemID: TrailColorOrange
Time: 4:41 PM
Reviewing the logs, I'm seeing two distinct calls from the client to PurchaseItem at that time - one at 2017-11-03 15:41:09.358 UTC and the next at 2017-11-03 15:41:09.375 UTC. How specifically is the call being made in your code? Either the call is being sent twice in a row, or there's a retry that is firing immediately.
I have a function called BuyItem that gets called if the item you're buying is not in your inventory. Attached are images of both the switch function for the buttons and the BuyItem function.
First picture is one of the cases of the button function, in this case, for the Dark Red color for Skis.
Second picture is the BuyItem function I've made. The button in one of the arguments was just my logic that the second purchaseitem was happening because the button stays pressed, so I made its onclick listener disappear, but it did not fix the problem.