Google in-app purchasing - version 3 issue

Hello all, I had an issue with using v3 of Google Play services with Corona in a particular app.

I’ve actually implemented v3 successfully in other apps, however, those apps have had only one product (one SKU).

However, in this one particular app, there are multiple (18) SKUs that need to be loaded successfully for the store.  When I try loading the table of products, I have a pop up showing me that 0 valid products were loaded and 18 invalid products, and we are unable to test purchasing seeing as how these products are, for some reason, not being loaded successfully.

Why would it be unable to load the SKUs?  I followed the documentation for Corona, I feel, pretty thoroughly, and we’re very sure everything is set up correctly in our Dev Console on Google Play,so has anyone else run into this and have a solution, or any ideas?  The license table is in my config file, and the build.settings has the plugin for v3 included as well as the permission for billing under Android.  Also using Corona build 2189.

\_G.store = require("plugin.google.iap.v3"); local STORE\_LOADING\_LIST = { "ID1", "ID2", "etc", }; local function loadProductsCallback( event ) local validProducts = (event.products or {}); local invalidProducts = (event.invalidProducts or {}); native.showAlert("TEST", "number of valid products loaded: ".. #validProducts.. " and number of invalid products : " .. #invalidProducts, {"Okay"}); end function setupMyStore(event) if (\_G.store.canLoadProducts == true) then \_G.store.loadProducts(STORE\_LOADING\_LIST, loadProductsCallback); else native.showAlert("TEST", "could not set up store", {"Okay"}); end end \_G.store.init("google", transactionCallback) timer.performWithDelay (1000, setupMyStore);

Did you happen to fix this problem? How did you do it?

Hi @orlin,

I’m not aware that this is an issue (the original post is somewhat old). If you are experiencing the same issue, then please post your code so the community can assist you.

Thanks,

Brent

This setup has worked for me in other apps, but now for some reason it is failing by reporting all the IAP products as invalid.

I’ve uploaded to production (but not published yet) a version of the app in Google Play, signed with the release key. On the device I run the same version of the app, signed with the same key.

All in-app products are set to Active in Google Play.

The Google account of the device is added as a test user account in Google Play.

In build.settings I have:

plugins =
{
    [“plugin.google.iap.v3”] =
    {
        publisherId = “com.coronalabs”,
        supportedPlatforms = { android=true }
    },
},

and also the permissions:

android =
{
    usesPermissions =
    {
        “android.permission.INTERNET”,
        “com.android.vending.CHECK_LICENSE”,
        “android.permission.WRITE_EXTERNAL_STORAGE”,
        “com.android.vending.BILLING”,
    },
}
In config.lua there is the Google Play license key for the app:

license =
{
    google =
    {
        key="<key removed for brevity>"
    },
},
    
Here’s how the store object is initialized:

local store = require(“plugin.google.iap.v3”)
store.init( “google”, transactionCallback )

There are no errors in the device log when initializing the store.

Here’s how the products are loaded, their IDs removed for brevity:

store.loadProducts( { “product1”, “product2”, “product3” } , loadProductsCallback )

And the callback:

local function loadProductsCallback( event )
    print(“Products loaded”)
    print("showing valid products: ", #event.products)
    for i=1, #event.products do
        local currentItem = event.products[i]
        products[currentItem.productIdentifier] = {}
        products[currentItem.productIdentifier].localizedPrice = currentItem.localizedPrice
    end
    
    for i=1, #event.invalidProducts do
        print("Invalid Product: " … event.invalidProducts[i])
    end
end

At this point all the products are reported as invalid.

I’m sure I’m missing something extremely stupid and will have a massive face-palm when I find it but now it looks like an insurmountable obstacle.
 

Your code looks right to me.  It may be a setup issue with making sure all your things are right with Google Play.

Rob

Found it! It looks like in IAB v3 you have to publish your app to Beta or Alpha (not Production, not Draft) in order to test your products, as described here: http://developer.android.com/google/play/billing/billing_testing.html#draft_apps

Did you happen to fix this problem? How did you do it?

Hi @orlin,

I’m not aware that this is an issue (the original post is somewhat old). If you are experiencing the same issue, then please post your code so the community can assist you.

Thanks,

Brent

This setup has worked for me in other apps, but now for some reason it is failing by reporting all the IAP products as invalid.

I’ve uploaded to production (but not published yet) a version of the app in Google Play, signed with the release key. On the device I run the same version of the app, signed with the same key.

All in-app products are set to Active in Google Play.

The Google account of the device is added as a test user account in Google Play.

In build.settings I have:

plugins =
{
    [“plugin.google.iap.v3”] =
    {
        publisherId = “com.coronalabs”,
        supportedPlatforms = { android=true }
    },
},

and also the permissions:

android =
{
    usesPermissions =
    {
        “android.permission.INTERNET”,
        “com.android.vending.CHECK_LICENSE”,
        “android.permission.WRITE_EXTERNAL_STORAGE”,
        “com.android.vending.BILLING”,
    },
}
In config.lua there is the Google Play license key for the app:

license =
{
    google =
    {
        key="<key removed for brevity>"
    },
},
    
Here’s how the store object is initialized:

local store = require(“plugin.google.iap.v3”)
store.init( “google”, transactionCallback )

There are no errors in the device log when initializing the store.

Here’s how the products are loaded, their IDs removed for brevity:

store.loadProducts( { “product1”, “product2”, “product3” } , loadProductsCallback )

And the callback:

local function loadProductsCallback( event )
    print(“Products loaded”)
    print("showing valid products: ", #event.products)
    for i=1, #event.products do
        local currentItem = event.products[i]
        products[currentItem.productIdentifier] = {}
        products[currentItem.productIdentifier].localizedPrice = currentItem.localizedPrice
    end
    
    for i=1, #event.invalidProducts do
        print("Invalid Product: " … event.invalidProducts[i])
    end
end

At this point all the products are reported as invalid.

I’m sure I’m missing something extremely stupid and will have a massive face-palm when I find it but now it looks like an insurmountable obstacle.
 

Your code looks right to me.  It may be a setup issue with making sure all your things are right with Google Play.

Rob

Found it! It looks like in IAB v3 you have to publish your app to Beta or Alpha (not Production, not Draft) in order to test your products, as described here: http://developer.android.com/google/play/billing/billing_testing.html#draft_apps