Why is this IAP code not working.

Get help using Construct 2

Post » Tue Dec 08, 2015 12:27 pm

On startup I do an isStoreAvailable>>requestStoreListing. And then run this code:

Image

and hasProduct keeps coming back false even though the product was purchased. The purchase product part of my code worked perfect and the Google Play transaction is showing it purchased. I've checked the spelling and case of the 'fullversion' numerous times, it is correct.

What I'm trying to accomplish is to first check to see if the app is paid for by checking against the store and if that fails and the user is offline, it falls back to a stored setting. ButtonCount is a dictionary entry that records whether the product is purchased or not and saves it to local storage. When it's loaded, it sets the global DemoVersion to 1 or 0 based on 'ButtonCount' if the store is unavailable.

DebugDict is so I can figure out what it's doing.

Also, what does 'restorePurchases' do? It's not explained terribly well in the manual.
B
15
S
5
Posts: 124
Reputation: 1,687

Post » Wed Dec 09, 2015 11:37 am

I guess I've asked too many questions or they're getting too difficult. I can't seem to get an answer any more.
B
15
S
5
Posts: 124
Reputation: 1,687

Post » Sun Dec 13, 2015 1:07 am

Pretty sad when you spend 3 weeks trying to get IAP working on a finished project and still can't.
B
15
S
5
Posts: 124
Reputation: 1,687

Post » Sun Dec 13, 2015 1:33 pm

IAP conditions
Has product

"Test if a given product ID has been successfully purchased by the user. Note that in some cases this will be false for the first few seconds of the app running even if the user has purchased the item, and then later become true when the store finishes loading the store status in the background. Try to avoid using this condition before On store listing success triggers."

You could try changing the way that's triggered.

The browser object has an is online condition, not sure if it will work in a non browser setting though.

Also restore purchases is for when an app gets deleted, and reinstalled.

If you think you found a bug, make a simplified capx, and submit it to bugs.
Image ImageImage
B
166
S
49
G
154
Posts: 8,102
Reputation: 100,225

Post » Sun Dec 13, 2015 3:49 pm

Finally, someone looked and can't find anything wrong. Thanks @newt

I know that it's getting the store listing. This is in a 'loader' layout. It won't even switch to the next layout (which it it doing) until one of these conditions are true. I even know that it's finding the product as the ProductName('fullversion') comes back with the appropriate product name. And yes, I learned about the restorePurchases. It's doing that now. And I know it's realizing the product is purchased because I'm getting a 'purchase failed' error from the IAP if I try to purchase it again.

I just wanted someone else to confirm that this code looked good before I went to the headache of tracking down a bug that isn't one I created. Everyone else seems to think that the IAP is working fine yet I'm completely stuck.
B
15
S
5
Posts: 124
Reputation: 1,687

Post » Sun Dec 13, 2015 3:59 pm

Using triggers as sub events to other triggers is always iffy imo.
I would suggest using variables like:

on store listing success, set variable.success to 1
store variable.success =1
>has product version, set variable.success to 0
Image ImageImage
B
166
S
49
G
154
Posts: 8,102
Reputation: 100,225

Post » Mon Dec 14, 2015 11:57 am

I would but, the available menu items are based on whether it's purchased or not.
B
15
S
5
Posts: 124
Reputation: 1,687


Return to How do I....?

Who is online

Users browsing this forum: Ajbael, ColombageEnPLS and 8 guests