Need help with consume products for Construct 2 with Cocoon IAP


I need help with consume products for Construct 2. On app start, first purchase is being made successfully but if I purchase the same product second time (Consume Product) without asking any payment details it prompts “Purchase Success” and adds points. I need to make purchases as many times as possible.

Please take a look the code from below.

After purchase is successful, this code with be executed.


Code for purchase

Please help.

Sudeep Vundurty


Hi Sudeep. Ive only recently experimented with Cocoon InApp, before that I was using Cranberrygame’s Cordova iAP.

One thing I noticed with the Cocoon InApp plugin, was that in my game the condition ‘On Consume Purchase Completed’ didnt seem to trigger at all. The equivalent condition in Cordova iAP does trigger as expected.

Im not sure if that could be preventing your code from working how you’d expect?


Hi @lukasinspace
Thanks for responding. Even I used Cranberrygame’s plugin for IAPs earlier. It is giving build crashes these days. May be the plugin is depreciated. Now, I switched to Cocoon where I removed all Cranberrygame’s plugin and started using Cocoon C2 plugins. Onething I’m missing with Cocoon IAP is consume product event. It doesn’t seem to trigger at all.

You mentioned :A super useful trick that @AndreasR showed me is how to use the consume purchase action to remove the purchased iAP from the game. That way you can test the iAP works multiple times." on a Scirra forum. I though you might help me with multiple purchases or consume product event.

@andy_reitberger Can you please help me. Sorry for budding you again. I need to release an important update but the game switching to Cocoon has halted it as I’m completely new to Cocoon.



Ok so you discovered the condition ‘On Consume Purchase Completed’ doesn’t trigger? Same for me.

I found the action to consume a product DOES work (eg: ‘Consume Product: StarPack1 x 1’ should be ok I think).

Would it work for your game if you moved the actions from under ‘On Consume Purchase Completed’ and repositioned them after the consume action?

So your code for purchase would look something like:

Is Product "StarPack1" purchased (yes)
>Consume product: "StarPack1"
>Set Purchase to ""
>Add 400 to Stars
>Set item "Stars" to Stars
etc etc

Not sure if this helpful…


@lukasinspace I did exactly the same as you suggested. It looks like consume product isn’t working (May be I used it in a wrong way).

Is Product “StarPack1” purchased (yes)

Consume product: “StarPack1”

This event is not working. When I try to repurchase the product, it is simply adding stars without asking for payment (it does for the first time).


You mean the action ‘consume product’ isn’t working for you right? Well that action does work in my game, I have it linked to a button. So the events are just:

On touched - Consume Product ‘removeads’

I notice in ur images you have the ‘restore purchases’ action disabled. Is there a reason for that? What happens if that’s enabled?

Maybe you could arrange things slightly differently. Instead of consuming the iAP at the point when it’s purchased a second time, you could consume it just after it’s purchased the first time? Would that work?


@lukasinspace Yes, the consume product isn’t working. The reason for disabling ‘restore purchases’ is -> On start of layout, ‘on product purchase success’ events are triggering, which shouldn’t happen.

How to do this?
“Instead of consuming the iAP at the point when it’s purchased a second time, you could consume it just after it’s purchased the first time?”

@andy_reitberger Do you have any idea?


@lukasinspace Hey it is working now.

Thanks for your advice
"Instead of consuming the iAP at the point when it’s purchased a second time, you could consume it just after it’s purchased the first time?"

I did exactly as you said. It’s working now.

Thanks alot man.


Thats great well done! How did you you achieve it in the end? I was imagining setting a variable to 1 after first purchase, then having an event to say something like, when variable = 1, trigger once, consume purchase and set variable back to 0.


@lukasinspace I removed consume product event at the product purchase button and simply moved the consume event to ‘On purchase complete’ event. See this

Also check this.

Do you how to prevent app from sleeping? Earlier when I used XDK I’ve achieved that but I don’t how to do on Cocoon.


That’s the only way how you should do it :wink:
Consume it right after the purchase was completed.
This is the same way I do it in my games.



Hey @andy_reitberger, do you how to prevent app from sleeping?



if you use Canvas+ this is implemented automatically, if WebView+ install the plugin “Cordova PowerManagement” by cranberrgame and run “Aquire” on start of the layout.



Hey @andy_reitberger, Thanks
alot. Do I need to add any git link on Cocoon side?


Hi @sudeepmailin

You’re welcome. Yes please install this plugin.



@andy_reitberger Thanks lot. :grinning:


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.