Google play billing / restore issue

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.

Rob

It works fine for apple and that snippet is actually inside a button listener, android is the issue.

Fair point, ill try doing it with a delay.

Thanks

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 :frowning:

If I understand correctly, calling store.restore() on Google will return a series of transaction events for each managed product purchased.

Rob

ok so it is same as apple then, ill take a look and see if can figure out the issue with it. Thanks Rob

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.

Rob

It works fine for apple and that snippet is actually inside a button listener, android is the issue.

Fair point, ill try doing it with a delay.

Thanks

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 :frowning:

If I understand correctly, calling store.restore() on Google will return a series of transaction events for each managed product purchased.

Rob

ok so it is same as apple then, ill take a look and see if can figure out the issue with it. Thanks Rob