Purchases work fine for both Android and iOS so I know the setup is correct for everything in general.
The problem is with restore. It works for iOS with “restored” state.
For android im using the “purchased” state to do the same.
Issue is store.restore() just does not get any response from google for me for v2 , do I need to migrate to v3 to get it working or is there something else that im missing? Below are code excerpts
if store.availableStores.apple then store.init("apple", transactionCallback2) print("Using Apple's in-app purchase system.") elseif store.availableStores.google then store.init("google", transactionCallback) print("Using Google's Android In-App Billing system.") purchaseID = string.lower(purchaseID) else print("In-app purchases is not supported on this system/device.") end store.purchase( {purchaseID} )
function transactionCallback( event ) local transaction = event.transaction if ( transaction.state == "purchased" or transaction.state == "restored" ) then --handle a successful transaction here print( "productIdentifier", transaction.productIdentifier ) print( "receipt:", transaction.receipt ) print( "signature:", transaction.signature ) print( "transactionIdentifier", transaction.identifier ) print( "date", transaction.date ) elseif ( transaction.state == "cancelled" ) then --handle a failed transaction here end store.finishTransaction( event.transaction ) end
if store.availableStores.apple then store.init("apple", transactionCallback2) print("Using Apple's in-app purchase system.") elseif store.availableStores.google then store.init("google", transactionCallback) print("Using Google's Android In-App Billing system.") else print("In-app purchases is not supported on this system/device.") end store.restore();
First of all, Apple wants the store.restore() function attached to a user activated button and not automatically triggered.
Secondly, it’s possible your restore is firing off before the store is initialized. Why not put the restore call inside of a timer.performWithDelay() for a second or two.
Another question that might solve my problem if I misunderstood it, the result returned by store.restore(), I know it fires off the listener for iOS for each purchase individually. For google billing v2, does it do the same or is the listener fired off only once with a table of the list of purchases ?
That might be the reason why I am not able to compare the returned product identifiers to my saved ones and unlock purchases
First of all, Apple wants the store.restore() function attached to a user activated button and not automatically triggered.
Secondly, it’s possible your restore is firing off before the store is initialized. Why not put the restore call inside of a timer.performWithDelay() for a second or two.
Another question that might solve my problem if I misunderstood it, the result returned by store.restore(), I know it fires off the listener for iOS for each purchase individually. For google billing v2, does it do the same or is the listener fired off only once with a table of the list of purchases ?
That might be the reason why I am not able to compare the returned product identifiers to my saved ones and unlock purchases