How do I test Cordova iAP?

Get help using Construct 2

Post » Tue Dec 06, 2016 10:26 am

Im trying to set up an in-app purchase to remove ads using Cranberry's Cordova iAP.. Does anyone have experience with this?

I'm most of the way there, but I can't figure out how to enable a test mode. Ive tested the purchase once, but it doesn't reset after restarting the app.. am I able to test the in-app purchase more than once? I want to test it a few times to make sure it works properly..
Or alternatively do I need to actually publish it to production and make it public for it to work? Im pretty stuck on this.. would totally appreciate any help.

Things Ive done:
-Set up a 'managed' in-app product in Dev Console (ProductID = removeads)
-Uploaded my test apk to both Alpha and Beta.

The event system in my project looks like this:
(Im using a value loaded from localstorage into a dictionary to turn the ad system on and off.)

title screen eventsheet
On Start of Layout
>CordovaiAP > Add Product IDs "removeads"
>CordovaiAP > Request Store listing

On request store listing Succeeded
> CordovaiAP > Restore purchases (tag"removeads")

On Start of Layout
>LocalStorage > Check item "removeads" exists

LocalStorage On item "removeads" exists
>Dictionary > Add key "removeads" with value LocalStorage.Item.Value

LocalStorage On item "removeads" missing
>Dictionary > Add key "removeads" with value=0

menu event sheet
On Start of Layout
+Has product "remove" ads
> Dictionary > Add key "removeads" with value=1
> Button(purchase button) > Set invisible

On touched Button(purchase button)
>CordovaiAP > Purchase product "removeads"

On purchase product "removeads" success
>Dictionary > Add key "removeads" value =1
> Button(purchase button) > Set invisible

On purchase product "removeads" fail
>Dictionary > Add key "removeads" value=0

On end of Layout
>LocalStorage > Set item "removeads" to Dictionary.Get("removeads")

Main game eventsheet
On start of layout
+Dictionary "removeads" = 0 > enable ads group
+Dictionary "removeads" = 1 > disable ads group
B
74
S
52
G
62
Posts: 406
Reputation: 39,075

Post » Tue Dec 06, 2016 12:38 pm

I can actually answer this myself now. AndreasR helped me out with a work around.

Basically you can just make a button (sprite) which on touch calls the iAP Consume action to 'consume' your product. That clears it, allowing you to test the purchase again. Very useful trick.

"On touch Button" -> "Cordova IAP" -> "Consume Product" ->"Your Product ID".
B
74
S
52
G
62
Posts: 406
Reputation: 39,075


Return to How do I....?

Who is online

Users browsing this forum: vino7733 and 27 guests