Corona SDK:Android 上的应用内购买不会返回状态。

我的跨平台(iOS和Android)应用程序包括一个应用内购买。算法如下:

  1. 启动应用程序时执行初始化:
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("此系统/设备不支持应用内购买。")
end
  1. 当单击“购买”时,购买已完成,但transactionCallback不返回状态。

  2. 由于状态未返回,我无法从应用程序中删除广告

  3. 如果再次单击“购买”,Google会说:“您已经拥有此应用程序”,transactionCallback返回状态“失败”

  4. 单击“购买”时如果没有互联网连接,则状态“失败”也会返回。

  5. 选项store.restore()根本不起作用!

以上所有问题在iOS上都正常工作!!!

问题在哪里?

点赞
用户2753334
用户2753334

请确保您已在 build.settings 文件中添加了适当的设置。

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

如果您的应用程序处于沙箱模式,则应使用提供的 Android 产品进行 IAP 测试。请查看以下产品 ID,以进行不同的交易并检查已购买、取消和项目不可用条件。成功测试后,请将您的产品替换为虚拟产品。

-- 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.
}

第二件事是:在 Google Play 市场中,不存在“恢复”状态的项目。所有已购买的项目将分组在“已购买”状态下。当您进行恢复时,应清除保存在文件/数据库中的所有购买,除了可消耗的购买之外,并将返回的恢复购买视为正常购买。

请检查。

2014-04-15 10:06:53