android - Android Corona sdk 的 Inapp Restore?

标签 android coronasdk in-app-billing

在我的应用程序中,我使用了应用程序内购买。它完美地购买了。但是当我删除我的应用程序并再次安装时。它的恢复选项返回到失败状态。如何获取恢复状态或如何使用响应代码来恢复事务恢复.我在网上搜索了他们告诉的

store.restore() 

这在 Android 中不起作用,那么如何获取已购买的商品列表。

最佳答案

在 Google Play 市场中,项目没有“已恢复”状态。所有购买的元素将被分组在“已购买”状态下。当您进行恢复时,您应该清除保存到文件/数据库的所有购买(消费品购买除外),并将返回的恢复购买视为正常购买。

在 Android 上,您将收到状态为“已购买”而不是已恢复的回调,符合下面的第一个 if 条件:

local store = require "store"

function transactionCallback( event )
    local transaction = event.transaction
    if transaction.state == "purchased" then
        print("Transaction succuessful!")
    elseif transaction.state == "restored" then
        print("Transaction restored (from previous session)")
        print("productIdentifier", transaction.productIdentifier)
        print("receipt", transaction.receipt)
        print("transactionIdentifier", transaction.identifier)
        print("date", transaction.date)
        print("originalReceipt", transaction.originalReceipt)
        print("originalTransactionIdentifier", transaction.originalIdentifier)
        print("originalDate", transaction.originalDate)
    elseif transaction.state == "cancelled" then
        print("User cancelled transaction")
    elseif transaction.state == "failed" then
        print("Transaction failed, type:", transaction.errorType, transaction.errorString)
    else
        print("unknown event")
    end

    -- Once we are done with a transaction, call this to tell the store
    -- we are done with the transaction.
    -- If you are providing downloadable content, wait to call this until
    -- after the download completes.
    store.finishTransaction( transaction )
end

store.init( transactionCallback )
store.restore()

关于android - Android Corona sdk 的 Inapp Restore?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17424184/

相关文章:

使用同一测试帐户在多台设备上进行 Android 应用内结算 v3 测试

android-ndk - 从 java(android) 调用 C++(cocos2dx) 方法进行应用内计费

安卓/谷歌播放 : do I really need my OWN server to manage inapp billing subscriptions?

android - 无法在 Android 中发送带附件的邮件

java - Twitter fabric,获取用户名

android - 电晕函数和变量

lua - 如果对象传递 y 值则调用函数

java - 将数组列表用于状态机

android - 如何设置描边颜色以在 Canvas 上绘制矩形?

algorithm - 使用递归方法查找接近路径或区域