Hey there,
I have a few problems testing the inApp Purchases of my app.
I have an app for iOS and Android and theres one iap for “removing ads”.
Here’s my code so you can see if i do something wrong or not.
At first I create the store and productlist thing for each platform like this:
-- STORE -- local store local googleIAP = false local currentProductList = nil local appleProductList = { "removeAds", } local googleProductList = "remove\_ads" if ( system.getInfo( "platformName" ) == "Android" ) then store = require( "plugin.google.iap.v3" ) googleIAP = true currentProductList = googleProductList store.init( "google", storeTransaction ) elseif ( system.getInfo( "platformName" ) == "iPhone OS" ) then store = require( "store" ) currentProductList = appleProductList store.init( "apple", storeTransaction ) end
Later in the code I create the storeTransaction thing:
local function storeTransaction( event ) local transaction = event.transaction if ( transaction.state == "purchased" ) then purchased = true elseif ( transaction.state == "cancelled" ) then elseif ( transaction.state == "failed" ) then end store.finishTransaction( event.transaction ) end
So now when I call:
store.purchase( currentProductList )
The storeTransaction listener should start and look if the IAP was “purchased”, “cancelled” or “failed”.
In my case I only have a variable that is changing when the iap was purchased.
I uploaded the app in the play store, downloaded it and tested it.
I was able to purchase this iap but the variable doesn’t changed.
Like the listener is not working well.
Can you help me solve this problem ?
And is there maybe an easy way to test inapp purchases on Android AND on iOS without uploading it ?
I’m sure there is, but how ?
Thank you in advance!!!
Dima