google IAP

Hi,

i receive the answer “invalidProducts 1 (…product id)”. The store parameters are true (store.isActive,store.canMakePurchases,store.canLoadProducts)

Here is my code:

    1. the shop lua archive

[lua]

    buyableProducts={products array}

    local validProducts, invalidProducts = {}, {}
    local store = require (“plugin.google.iap.v3”)
    function transactionCallback( ev )
        local transaction = ev.transaction
        for i,v in pairs(ev) do
            print(i,v)
        end
        store.finishTransaction(transaction)
    end  
    function loadProductsCallback( event )
        validProducts   = event.products
        invalidProducts = event.invalidProducts
        for i,v in pairs(validProducts) do
            print(“validProducts”,i,v)
        end
        for i,v in pairs(invalidProducts) do
            print(“invalidProducts”,i,v)
        end
    end
    store.init ( “google”,transactionCallback )
    store.loadProducts( buyableProducts, loadProductsCallback )

[/lua]

   2. build.settings

[lua]  

   settings = {
    plugins={
            [“plugin.google.iap.v3”]=
            {
                publisherId=“com.coronalabs”,
                supportedPlatforms={android=true},
            },
        },
    orientation = {
        default = “portrait”,
        supported = { “portrait” }
    },
    
    – Android permissions
    android={
        versionCode=“11”,
        usesPermissions={
        ‘com.android.vending.BILLING’,
        ‘android.permission.VIBRATE’,
        ‘android.permission.INTERNET’,
        ‘android.permission.WRITE_EXTERNAL_STORAGE’,
        ‘com.android.vending.CHECK_LICENSE’,
        },
    },    
}

[/lua]

   3. i have also written the license key in config lua

[lua]

   application = {    
    content = {

    },
    license={
        google={
            key=“my key”,
            },
        },
    }
[/lua]

Any ideas? What could cause the problem?

 
 

Hi @Giorgio P,

What does this look like in your actual code? What does the products array look like?

[lua]

buyableProducts={products array}

[/lua]

I can’t know what you’ve set this variable as, so it’s hard to diagnose the issue.

Thanks,

Brent

Hi Brent,

the buyableProducts array is an array of productIdentifiers, (buyableProducts={“product1”,“product2”,“product3”}).

PS: I have tested the app on samsung galaxy tab GT-P7501 with Android version 4.0.4 and on mobile phone Huawei Y330 with Android version 4.2.2. My Corona version is 2015.2551 (2015.2.5), i have also tried with the Corona version 2015.2541.

Hi Giorgio,

You may test out a minor restructuring where the “loadProducts()” call isn’t made until after the store successfull initializes (“store.init()”). In other words, instead of loading products on the line directly following init(), let the init() complete, then load your products and see if that produces a different response. Also, I’d suggest wrapping it within a “.canLoadProducts” check.

Naturally, I assume all of the products are fully operational and appear within the Google Play Dev console…

Best regards,

Brent

Hi Brent,

Thank you for your quick answers. Finally there was a problem with my test account, but now google IAP works.

Hi @Giorgio P,

What does this look like in your actual code? What does the products array look like?

[lua]

buyableProducts={products array}

[/lua]

I can’t know what you’ve set this variable as, so it’s hard to diagnose the issue.

Thanks,

Brent

Hi Brent,

the buyableProducts array is an array of productIdentifiers, (buyableProducts={“product1”,“product2”,“product3”}).

PS: I have tested the app on samsung galaxy tab GT-P7501 with Android version 4.0.4 and on mobile phone Huawei Y330 with Android version 4.2.2. My Corona version is 2015.2551 (2015.2.5), i have also tried with the Corona version 2015.2541.

Hi Giorgio,

You may test out a minor restructuring where the “loadProducts()” call isn’t made until after the store successfull initializes (“store.init()”). In other words, instead of loading products on the line directly following init(), let the init() complete, then load your products and see if that produces a different response. Also, I’d suggest wrapping it within a “.canLoadProducts” check.

Naturally, I assume all of the products are fully operational and appear within the Google Play Dev console…

Best regards,

Brent

Hi Brent,

Thank you for your quick answers. Finally there was a problem with my test account, but now google IAP works.