How do I Restore Purchases for In Game Currency using IAP?

Get help using Construct 2

Post » Tue Mar 29, 2016 1:59 am

Recently my app was rejected from the iOS store again because it did not include a restore purchases button. The only IAPs in my game are a few consumable options to buy more in game currency but they are saved to the local storage. How do I make a restore purchases button? Also what would it do in my game?

***EDIT*** Okay so after making a restore purchases button and playing around with the restore action, the restore purchases button in my game adds on the amount of coins that the player has bought but it continuously adds on coins even if the device wasn't switched or if the restore purchases button is being clicked over and over again. For example, when I buy 1000 coins, I can click the restore purchases buttons as many times and it will continue adding 1000 coins. How do I test if the device was switched? I'm testing in testflight if that helps.

Also, some possible solutions I've tried to think up is adding a variable that prevents the player from clicking the restore purchases button more than once and then resetting the restore purchases button to make it clickable again when the player buys a new product but I'm almost certain this wouldn't work. Has anyone found a solution or knows how to use the restore purchases action?

It's been almost two months of troubleshooting the IAP object so I'm desperate for answers. Any help is appreciated.
B
37
S
14
G
3
Posts: 263
Reputation: 4,270

Post » Sat Apr 02, 2016 3:59 am

bump
B
37
S
14
G
3
Posts: 263
Reputation: 4,270

Post » Sat Apr 02, 2016 6:46 am

I've not used the IAP but it sounds like you need a variable to control how many times the IAP previous purchase amount can be added into your events.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,228
Reputation: 44,888

Post » Sun Apr 03, 2016 5:51 am

@Colludium that would make sense but the restore purchases button is only applicable when the player somehow deletes his local storage data like by uninstalling or reinstalling the app or switching to a new phone. I'm not sure how I would detect that.
B
37
S
14
G
3
Posts: 263
Reputation: 4,270

Post » Sun Apr 03, 2016 7:22 am

I read it that the problem you had was continuous / repeated adding of restored coins. So, you need a condition event to prevent that from happening more than once (by using a variable somewhere that changes when the restore action takes place).
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,228
Reputation: 44,888

Post » Sun Apr 03, 2016 11:20 pm

Just have a variable in your localstorage that checks if its a new install or not, if it is, he can restore his coins, else not.

A simple boolean would be fine.

In my example, players can buy skins for a character ingame and this is the part that checks if he has the purchase IF the value is not in the array.
Image
B
25
S
11
G
9
Posts: 136
Reputation: 6,657

Post » Mon Apr 04, 2016 11:09 pm

@Wishy that sounds like it would work but how would I test if its a new install or not?
B
37
S
14
G
3
Posts: 263
Reputation: 4,270

Post » Tue Apr 05, 2016 2:18 pm

I test it by having a reset button in my game, which clears all data, resets global variables and removes localstorage.
I usually also remove my app-cache and data before trying a fresh install.

If you mean, how does the game know it's a fresh install, well, because the variable/array is empty.

You could also make a variable "IsFreshInstall" set to 0 after the game has started (and have it saved in localstorage).
So the next time the game is started it will know it's not a fresh install.
like this:
Image
B
25
S
11
G
9
Posts: 136
Reputation: 6,657

Post » Tue Apr 05, 2016 5:39 pm

@Wishy thank you. That's very helpful to know. I'm working on incorporating it right now :)
B
37
S
14
G
3
Posts: 263
Reputation: 4,270

Post » Fri Apr 15, 2016 11:59 pm

@Wishy if I set IsFreshInstall to 0 on start of layout and then tested if it was equal to 1, wouldn't it always be equal to 0 making it impossible to restore purchases? For instance, I'm saying If IsFreshInstall is 1 and On clicked button then restore purchases but IsFreshInstall is always 0.
B
37
S
14
G
3
Posts: 263
Reputation: 4,270

Next

Return to How do I....?

Who is online

Users browsing this forum: Artcadev, ignaciosimo and 53 guests