Type Function Library store.* Return value none Revision Current Public Release (2013.2076) Keywords Sample code /CoronaSDK/SampleCode/Store/InAppPurchase See also
Users who wipe the information on a device or buy a new device, may wish to restore previously purchased items without paying for them again. The
store.restore() API initiates this process.
In iOS, the transaction state of restored items will be
"restored" and, in this case, your app may use the
originalDate fields of the transaction object.
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.
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()