Question

My cross-platform (iOS and Android) application includes one in-app purchase. The algorithm is as follows:

  1. Performing initialization when start the application:

     if store.target == "apple" then
         store.init( "apple", transactionListener)
     elseif store.target == "google" then
         store.init( "google", transactionListener )
         restoring = true
         timer.performWithDelay( 1000, restore() )
     else
         print("In-app purchases are not supported on this system/device.")
     end
    
  2. When you click «Buy» the purchase is made, but transactionCallback returns no status.

  3. As the status is not returned, I am not able to remove the ad from application
  4. If you click «Buy» again, Google says: «You already have this application» and transactionCallback returns the status «failed»
  5. If there is no internet connection when clicking «Buy», status «failed» also returns.
  6. Option store.restore() does not work at all!

All of the above works fine on iOS!!!

What is the problem?

Was it helpful?

Solution

Please make sure that you have added proper settings in build.settings file.

settings =
{
    android =
    {
        usesPermissions =
        {
            "com.android.vending.BILLING",
        },
    },
}

If your application is in sandbox mode then you should have to test IAP by android product provide by them. Please see below product id's for your different transaction and check with purchased, canceled and item_unavailable conditions. After successful testing just replace your products with dummy ones.

-- Product IDs for the "google" Android Marketplace store.
local googleProductList =
{
    -- These product IDs are used for testing and is supported by all Android apps.
    -- Purchasing these products will not bill your account.
    "android.test.purchased",           -- Marketplace will always successfully purchase this product ID.
    "android.test.canceled",            -- Marketplace will always cancel a purchase of this product ID.
    "android.test.item_unavailable",    -- Marketplace will always indicate this product ID as unavailable.
}

Second thing is that: In the Google Play Marketplace, there is no "restored" state for items. All purchased items will be grouped under the "purchased" state. When you do a restore, you should clear all purchases saved to file/database — except for consumable purchases — and treat the returned restored purchases as normal purchases.

Please check.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top