In-App Purchases (specifically Android and the restore workaround)

Hi, I’ve put together quite a few Corona games but never dived into the in-app purchase aspect. Now I’ve got an app that does and I’m simply not understanding  the restore workaround for Android. 

My app is making purchases…they are managed, non-consumable purchases and there are 4 for the app. But I’m trying to put together a “restore purchases” button and not getting anywhere. The corona Tutorial only makes reference to a single purchased item (isPaid)…what happens when you have multiples…how does a single “restore()” call return product info for each of the individual items?

Any help on clearing this up would be greatly appreciated…this is the last item holding up the launch of the app.

Thanks,

Todd

Android does not return a “restore” event, it restores a “purchase” event.  There should be one event for each purchase if I remember correctly.

Thanks for the quick reply.

Yes, that’s the line I keep reading in the tutorials, but I’m still not sure how to make any working sense of it. 

So basically I call store.restore(), then the workaround in the tutorial appears to simply set the transaction state to ‘restore’ (faking it on Android based on a 5 minute time stamp)…

then what…??

…check the transaction.productIdentifier for each product…what am I looking for to tell me that one product has been purchased in the past, but another hasn’t?

Thanks,

Todd

Hi Todd, I’m not sure what the tutorial says, but here’s what happens. When you call store.restore(), your transaction listener will get a series of callbacks, one for each managed/non-consumable product that the user previously purchased. On iOS, the transaction status that your listener receives will be “restored”, whereas on Android it will be “purchased”. In either case, it’s then your listener’s job to unlock the content based on the productIdentifier. (It seems like your confusion may have been thinking that your listener will get a callback for all products. That’s not the case. It’ll only get a callback for the ones that the user previously purchased.) - Andrew

Thanks Andrew, that was exactly my confusion (not knowing exactly what was getting returned). I think that clears things up for me. I’ll give it a shot. 

Thanks very much,

Todd

That appears to have done it.

Thanks,

Todd

Android does not return a “restore” event, it restores a “purchase” event.  There should be one event for each purchase if I remember correctly.

Thanks for the quick reply.

Yes, that’s the line I keep reading in the tutorials, but I’m still not sure how to make any working sense of it. 

So basically I call store.restore(), then the workaround in the tutorial appears to simply set the transaction state to ‘restore’ (faking it on Android based on a 5 minute time stamp)…

then what…??

…check the transaction.productIdentifier for each product…what am I looking for to tell me that one product has been purchased in the past, but another hasn’t?

Thanks,

Todd

Hi Todd, I’m not sure what the tutorial says, but here’s what happens. When you call store.restore(), your transaction listener will get a series of callbacks, one for each managed/non-consumable product that the user previously purchased. On iOS, the transaction status that your listener receives will be “restored”, whereas on Android it will be “purchased”. In either case, it’s then your listener’s job to unlock the content based on the productIdentifier. (It seems like your confusion may have been thinking that your listener will get a callback for all products. That’s not the case. It’ll only get a callback for the ones that the user previously purchased.) - Andrew

Thanks Andrew, that was exactly my confusion (not knowing exactly what was getting returned). I think that clears things up for me. I’ll give it a shot. 

Thanks very much,

Todd

That appears to have done it.

Thanks,

Todd