In app purchase not responding

local store = require( "plugin.google.iap.v3" ) store.init("google", storeTransaction ) local function storeTransaction( event ) local transaction = event.transaction if ( transaction.state == "purchased" ) then --handle a successful transaction here print( "productIdentifier", transaction.productIdentifier ) print( "receipt", transaction.receipt ) print( "signature:", transaction.signature ) print( "transactionIdentifier", transaction.identifier ) print( "date", transaction.date ) elseif ( transaction.state == "cancelled" ) then --handle a cancelled transaction here elseif ( transaction.state == "failed" ) then --handle a failed transaction here end --tell the store that the transaction is complete! --if you're providing downloadable content, do not call this until the download has completed store.finishTransaction( event.transaction ) end local function onContinueBtn( event ) if ( event.phase == "began" ) then store.purchase("getmygem.1") end return true end

The code was good, I made a first purchase and successful, but when I restart the app and try to do a purchase, it is not responding like nothing, no error message or anything,

Please help

Your code is pretty simple, but I don’t see where you are consuming the purchase.

https://docs.coronalabs.com/guide/monetization/IAP/index.html#consuming-items-google

Perhaps that is the issue? BTW there is a module/soon-to-be-plugin called IAP Badger that can handle all of this for you:

https://forums.coronalabs.com/topic/59137-iap-badger-a-unified-approach-to-in-app-purchases/

so I will use :

store.consumePurchase( { "product1"}, transactionCallback )

instead of :

store.purchase("product1")

?

You would actually use the purchase() call, as you normally would. Then, some time later (I normally set a timer AND have a call to consume IAP every time a user leaves the “store” module) call consumePurchase().

local store = require( "plugin.google.iap.v3" ) store.init("google", storeTransaction ) local function storeTransaction( event ) local transaction = event.transaction if ( transaction.state == "purchased" ) then --I call the consumePurchase() since the purchase is successful, is this right? store.consumePurchase() elseif ( transaction.state == "cancelled" ) then --handle a cancelled transaction here elseif ( transaction.state == "failed" ) then --handle a failed transaction here end store.finishTransaction( event.transaction ) end local function onContinueBtn( event ) if ( event.phase == "began" ) then store.purchase("getmygem.1") end return true end

Good Day, thanks for the reply, can you check the above code if its correct, if not, can you provide me a working code for it, sorry but I am new in using IAP, this is actually my first time to use this plugin, many thanks in advance :slight_smile:

I suggest you use IAP Badger because it makes IAP easier to implement.

Hi Alex the IAP Badger is great, thanks for the help, really save me :slight_smile:

Your code is pretty simple, but I don’t see where you are consuming the purchase.

https://docs.coronalabs.com/guide/monetization/IAP/index.html#consuming-items-google

Perhaps that is the issue? BTW there is a module/soon-to-be-plugin called IAP Badger that can handle all of this for you:

https://forums.coronalabs.com/topic/59137-iap-badger-a-unified-approach-to-in-app-purchases/

so I will use :

store.consumePurchase( { "product1"}, transactionCallback )

instead of :

store.purchase("product1")

?

You would actually use the purchase() call, as you normally would. Then, some time later (I normally set a timer AND have a call to consume IAP every time a user leaves the “store” module) call consumePurchase().

local store = require( "plugin.google.iap.v3" ) store.init("google", storeTransaction ) local function storeTransaction( event ) local transaction = event.transaction if ( transaction.state == "purchased" ) then --I call the consumePurchase() since the purchase is successful, is this right? store.consumePurchase() elseif ( transaction.state == "cancelled" ) then --handle a cancelled transaction here elseif ( transaction.state == "failed" ) then --handle a failed transaction here end store.finishTransaction( event.transaction ) end local function onContinueBtn( event ) if ( event.phase == "began" ) then store.purchase("getmygem.1") end return true end

Good Day, thanks for the reply, can you check the above code if its correct, if not, can you provide me a working code for it, sorry but I am new in using IAP, this is actually my first time to use this plugin, many thanks in advance :slight_smile:

I suggest you use IAP Badger because it makes IAP easier to implement.

Hi Alex the IAP Badger is great, thanks for the help, really save me :slight_smile: