hi
I trying to add In app purchasing to my game the iap is a consumable. I keep getting You’ve already purchased this but it hasn’t been downloaded error when I try and buy for a second time.I’ve put my product code in the demo app put it on device ,tested it and it worked so I’m ruling out problems with iap on itunes connect , my test apple profile and provisioning profile . Something must be wrong with my code but I cannot see what , I am calling store.finishTransaction( transaction );
here’s the code
local inApp = {};
local store = require “store”
– Connect to store at startup, if available.
if store.availableStores.apple then
print(“Using Apple’s in-app purchase system.”)
elseif store.availableStores.google then
print(“Using Google’s Android In-App Billing system.”)
else
print(“In-app purchases is not supported on this system/device.”)
end
local listOfProducts =
{
--my product id
}
local function productCallback( event )
print(“showing valid products”, #event.products)
for i=1, #event.products do
print(event.products[i].title) – This is a string.
print(event.products[i].description) – This is a string.
print(event.products[i].price) – This is a number.
print(event.products[i].localizedPrice) – This is a string.
print(event.products[i].productIdentifier) – This is a string.
end
print(“showing invalidProducts”, #event.invalidProducts)
for i=1, #event.invalidProducts do
print(event.invalidProducts[i])
end
end
if store.canLoadProducts then
store.loadProducts( listOfProducts, productCallback )
end
–transaction
function appStoretransactionCallback( event )
local transaction = event.transaction
if transaction.state == “purchased” then
print(“Transaction succuessful!”)
print(“productIdentifier”, transaction.productIdentifier)
print(“receipt”, transaction.receipt)
print(“transactionIdentifier”, transaction.identifier)
print(“date”, transaction.date)
native.showAlert(“Notice”, “Purchasing .”, { “OK” })
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( “apple”, appStoretransactionCallback )
function inApp.buyFromAppStore()
if store.canMakePurchases then
store.purchase( listOfProducts )
else
print(“Store purchases are not available”)
end
end
return inApp
would be very grateful if anyone had any ideas whats wrong.