2

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

store.restore() 

这在 android 中不起作用然后如何获取购买的项目列表。

4

1 回答 1

2

在 Google Play Marketplace 中,项目没有“恢复”状态。所有购买的物品都将归入“已购买”状态。当您进行恢复时,您应该清除保存到文件/数据库的所有购买 - 除了消耗品购买 - 并将返回的恢复购买视为正常购买。

在 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()
于 2013-10-18T17:18:34.130 回答