inapp purchases for android

Hello sir,

I am using corona from last few years and my inapps were working fine everytime.

Now from the day it is free i am not getting how it will work for me.

1: I have created an app on google play and create a product there.

2: Then in code i am using first: 

local store = require( “store” )

if ( system.getInfo( “platformName” ) == “Android” ) then

print(“plugin found here\n\n”)

store = require( “plugin.google.iap.v3” )

elseif ( system.getInfo( “platformName” ) == “iPhone OS” ) then

store = require( “store” )

end

3: Then in create scene i am using:

if ( system.getInfo( “platformName” ) == “Android” ) then

print(“initialized done here\n\n”)

store.init( transactionCallback )

elseif ( system.getInfo( “platformName” ) == “iPhone OS” ) then

store.init( “apple”, transactionCallback )

else

local alert = native.showAlert( “Ration Rush”, " Store is not available", {“Ok”} )

end

4: On clicking button, i am using

store.purchase( {“demoproduct”} ) – demoproduct is my product id.

5: Its doing nothing for me, in log cat it is showing a warning as:

I/Corona  (4291):  
W/System.err(4291):      at com.ansca.corona.CoronaLua.dispatchEvent(CoronaLua.java:100)
W/System.err(4291):      at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:148)
W/System.err(4291):      at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:87)
W/System.err(4291):      at com.ansca.corona.Controller.updateRuntimeState(Controller.java:281)
W/System.err(4291):      at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:417)
W/System.err(4291):      at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)
W/System.err(4291):      at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)

I have given all permissions in build and have given key in config also.

I am also using plugin in build as: 

[“plugin.google.iap.v3”] =

        {

            publisherId = “com.coronalabs”,

            supportedPlatforms = { android=true }

        },

Please help me and tell me whats wrong with my code and why it is not working.

Thanks in Advance

Hi @sahil19.sindh,

One potential problem is that you’ve specified the item (to purchase) within a table. v3 expects this to be one string, like this…

[lua]

store.purchase( “productID” )

[/lua]

…but not like this (your code):

[lua]

store.purchase( { “productID” } )

[/lua]

Hope this helps,

Brent

Hello Brent,

Thanks for the reply,

The thing is like i have done the same syntax and the syntax suggested by you also but the problem is not the syntax. The problem is store.init is not working fine as even after calling the store.init, when i am calling the store.purchase it is giving a warning on logcat as call store.init first before calling purchase.

Please refer to exact warning as written in above message.

Please help me in finding the issue as i have to send this project to my client and deadline is almost arrived.

Thanks in advance

Hello @sahil19.sindh,

At this time, I will need to see your entire “build.settings” file and “config.lua” file. If you need to protect your license key value, please just mark it as “XXXXXX” in the code.

Thank you,

Brent

Hi @sahil19.sindh,

One potential problem is that you’ve specified the item (to purchase) within a table. v3 expects this to be one string, like this…

[lua]

store.purchase( “productID” )

[/lua]

…but not like this (your code):

[lua]

store.purchase( { “productID” } )

[/lua]

Hope this helps,

Brent

Hello Brent,

Thanks for the reply,

The thing is like i have done the same syntax and the syntax suggested by you also but the problem is not the syntax. The problem is store.init is not working fine as even after calling the store.init, when i am calling the store.purchase it is giving a warning on logcat as call store.init first before calling purchase.

Please refer to exact warning as written in above message.

Please help me in finding the issue as i have to send this project to my client and deadline is almost arrived.

Thanks in advance

Hello @sahil19.sindh,

At this time, I will need to see your entire “build.settings” file and “config.lua” file. If you need to protect your license key value, please just mark it as “XXXXXX” in the code.

Thank you,

Brent