Inapp Restore for android corona sdk?

时间:2013-07-02 11:18:01

标签: android corona in-app-billing

在我的应用程序中,我使用in-app purchase.it购买完美。但是当我删除我的应用程序并再次安装时。恢复选项返回失败状态。如何获得恢复状态或如何使用响应代码来恢复事务恢复.i通过网络搜索他们告诉

store.restore() 

这不适用于Android,然后如何获得购买项目列表。

1 个答案:

答案 0 :(得分: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()