Reputation: 267
In my application i used in-app purchasing.it purchased perfectly.but when i delete my app and again installed.its restore option return to failed state.how to get restore state or how to use response code to recover transaction restore.i searched over the net they told
store.restore()
this not working in android then how to get purchased item list.
Upvotes: 2
Views: 389
Reputation: 1006
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.
On Android, you will get a callback with the state 'purchased' instead of restored, matching the first if condition below:
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()
Upvotes: 2