In App Purchases (IAP) store.init() freezes the application.

Hi RadekS,

I have the key in my config.lua,

But yet the issue is observed.

I tired every possible way to solve this, even there is no response from corona staff.

I am stuck in this issue since 4 days.

Please paste your “config.lua” and “bulid.settings”. Of course change your real production keys with dummy ones.

On my side I have:

in config.lua:

   license =
    {
        google =
        {
            key = “zxlqR7gjmPrTHWnKgUFuyyHqFr6GfNXoT7wg0lOdvtKa7kO…”,
            policy = “All rights reserved. Copyright by Szwarcsoft 2014”,
        },
    },

in build.settings:

    android =
    {
        versionCode = “4”,
        googlePlayGamesAppId = “403…”,
        usesPermissions =
        {
            “android.permission.INTERNET”,   
            “com.android.vending.BILLING”,
        },
    },

as well it would be good if you could paste your code where you init the store.

Without that - it will be hard to help you out.

We need a bug report filed.

Rob

Hi,

here is my config.lua and build.settings.

And what is that   googlePlayGamesAppId = “403…”, in your build.settings.

[lua]

---------------config.lua-----------------

application =
{

     license = {
        google =
        {
            key = “MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCg…”,
        },
    },

    content = {
        showRuntimeErrors = true,.
        width = 720,
        height = 1280,
        scale = “zoomStretch”,
        fps = 60, 
    }
}


--------build.settings--------

settings = {
    orientation = {
        default = “landscapeRight”,
        supported =
                {
                        “landscapeLeft”, “landscapeRight”
                },
    },
    
    iphone =
    {
        plist=
        {
            UIStatusBarHidden=true,
            UIViewControllerBasedStatusBarAppearance = false,
            CFBundleIconFile = “Icon.png”,
            CFBundleIconFiles = {
               “Icon.png”,
               “Icon@2x.png”,
               “Icon-76.png”,
               “Icon-76@2x.png”,
               “Icon-72.png”,
               “Icon-72@2x.png”,
               “Icon-512.png”,
               “Icon-512@2x.png”
            },
            UIApplicationExitsOnSuspend = false,     
             FacebookAppID = “25634XXXXXXXXX”,
            UIAppFonts={ “customfont.ttf”,“CALIBRI.TTF”,“CALIBRIB.TTF”,“comic.ttf”,“comicbd.ttf”,“minya_nouvelle_rg.ttf”,“chinacat.TTF”,“Doctor Soos Light.ttf” },
            CFBundleURLTypes =
            {
                {
                    CFBundleURLSchemes =
                    {
                           “fbXXXXXXXXX”,-- replace XXXXXXXXX with your facebook appId

                    }
                }
            }
        }
        },
        android =
    {
    usesExpansionFile = true,
        versionCode = “16”,
        usesPermissions =
        {
            “android.permission.RECORD_AUDIO”,
            “android.permission.INTERNET”,
              “com.android.vending.BILLING”,
             “com.android.vending.CHECK_LICENSE”,
             “android.permission.WRITE_EXTERNAL_STORAGE”
      
    },
    },
    
    – enable the admob plugin
    plugins =
    {
        
        [“plugin.google.play.services”] =
        {
            publisherId = “com.coronalabs”
        },
        
           [“CoronaProvider.analytics.flurry”] =
        {
            publisherId = “com.coronalabs”,
        },
        
        [“facebook”] =
          {
           publisherId = “com.coronalabs”,
          },

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

    },    
}
[/lua]

IMHO looks ok. Please next time post it in codes tag, it’s completely unreadable that way.

In your config.lua you have this line:

showRuntimeErrors = true,.

That period on the end shouldn’t be there.  Though I’m not sure if it would cause issue with IAP v3.

Are you seeing any errors in your android device console log (adb logcat   and don’t filter just Corona messages)???

Have you put in any print statements to see where you’re getting to?

Rob

Hi @Rob,

I removed the showRuntimeErrors = true, but the issue is still observed.

I can trace my code till store.init(), where i have printed some lines and checked through adb logcat Corona:v *:s.

The lines after store.init are not called at all.

And there are no error on the console.

Hi rohan,

That’s Serkan from the Linkedin group. I’m using the latest public release (with a pro account) by the way.

I don’t know if it affects anything related to IAP v3 but maybe you should remove the version code line from android settings. Also, maybe you should first define content tag and then the google key in the config.lua

Can you post a sample code for how you handle transactionCallback function?

Hi Serkan,

First i was using the public release, as it was not working i downloaded the

daily build as of now I am using 2014.2520 (2014.12.13) PRO Version.

I checked removing the version code, still the issue is observed.

And what do you mean by “first define content tag and then the google key in the config.lua”, i didn’t get it.

Here is my transactionCallback, but for your information the transactionCallback is not called, as it get stucks at store.init().

[lua]

function transactionCallback( event )
    local infoString
    native.setActivityIndicator(false)
    buttonTaped=false;
    print("transactionCallback: Received event " … tostring(event.name))
    print("state: " … tostring(event.transaction.state))
    print("errorType: " … tostring(event.transaction.errorType))
    print("errorString: " … tostring(event.transaction.errorString))
    if event.transaction.state == “purchased” then
        infoString = “Transaction successful!”
        print(infoString)
        print("receipt: " … tostring(event.transaction.receipt))
        print("signature: " … tostring(event.transaction.signature))
        unlockFeature(event);
    elseif  event.transaction.state == “restored” then
        infoString = “Restoring transaction:” …
                            "\n   Original ID: " … tostring(event.transaction.originalTransactionIdentifier) …
                            "\n   Original date: " … tostring(event.transaction.originalDate)
        print(infoString)
        print("productIdentifier: " … tostring(event.transaction.productIdentifier))
        print("receipt: " … tostring(event.transaction.receipt))
        print("transactionIdentifier: " … tostring(event.transaction.transactionIdentifier))
        print("date: " … tostring(event.transaction.date))
        print("originalReceipt: " … tostring(event.transaction.originalReceipt))
        unlockFeature(event);
        if(not productRestored)then
            productRestored=true;
            native.setActivityIndicator(true)
            timer.performWithDelay(1000, function(e)
            native.showAlert( “Success”, “Your purchsed product/s is restored.”, { “OK” } ,goToPrevScene)
              native.setActivityIndicator(false)
              buttonTaped=false;
            end)
        end
    elseif  event.transaction.state == “refunded” then
        infoString = “A previously purchased product was refunded by the store.”
        print(infoString … "\nFor product ID = " … tostring(event.transaction.productIdentifier))
    elseif event.transaction.state == “cancelled” then
        infoString = “Transaction cancelled by user.”
        print(infoString)
    elseif event.transaction.state == “failed” then        
        infoString = "Transaction failed, type: " …
            tostring(event.transaction.errorType) … " " … tostring(event.transaction.errorString)
        print(infoString)
        timer.performWithDelay(500, function(e)
           local alertStart =
            native.showAlert( “Error”, “Purchase failed. Please try again.”, { “OK” } )   
            end)
    else
        infoString = “Unknown event”
        print(infoString)
        timer.performWithDelay(500, function(e)
           local alertStart =
            native.showAlert( “Error”, “Purchase failed. Please try again.”, { “OK” } )   
            end)
    end
    store.finishTransaction( event.transaction )
end

[/lua]

~Thanks

I asked it because of the store.init(“google”, transactionCallback) call. Can you post a full sample on how you call, how you declare the product list, what the functions in the sample code do etc.?

From my past experience, I can tell native.setActivityIndicator() may cause freeze errors. I don’t know the exact proper way to use it but it can cause freezes when you use it in the same method etc. (as I recall). Can you comment out all activityIndicator calls?

Also, what does unlockFeature(event) do and why do you call it with (event)? 

First the line:

showRuntimeErrors = true,

was not the problem.  It was the (".") period on the end.  As far as reading the console log it’s important that you do not use:
 

adb logcat Corona:v *:s

Instead use:

adb logcat

When you the first method, you filter out all messages except from the Corona activity.  IAP is using Google Play and you’re missing potential messages from there about why you’re not working.