what is the minimum check to confirm a user can purchase? (and is finishTransaction required)

What is the minimum to check to confirm a user can purchase?   And is a finishTransaction required?  That is to confirm before hand what is possible, so that then for the UI you don’t show the purchase button if it’s not going to work.  (plus ensures if you did show it and the user pushed it you don’t have to explain then what happened)

Question 1:  For example would the answer be to:

a) perform store.init, then

b) store.isActive then

c) store.canMakePurchases

Question 2:  If this is correct, do I then need to actually have a listener for the init and perform the store.finishTransaction( transaction )?   That is, I haven’t actually performed any functions really on the store like ask for a list or purchase.  What would be the transaction.state that would come back from an “init” anyway?  

Question 3 - Alternatively I assume I don’t need a listener and store.finishTransaction for the “isActive” and/or “canMakePurchases” call either do I?

Hi Greg,

(1) Yes, I’d say the minimum required to get going is store.init() and store.canMakePurchases.  store.isActive isn’t a property I’ve used, but I don’t think it hurts to use it.

(2) When you call store.init(), the listener you provide doesn’t get called right then.  You’re merely telling Corona what your listener is so that it can be called later when you call other store functions.  You do need to provide one, otherwise Corona won’t know what to call when you later use store.purchase() and store.restore().

(3) You definitely do need a listener and store.finishTransaction() if you want to actually process transactions.  When you call store.purchase() or store.restore(), the listener you previously specified with store.init() will be called with the transaction status and information.  Within that listener, you must process the transaction (e.g., give the user what they bought, save it to a file) and you must call store.finishTransaction() to tell the App Store / Google Play that you processed it successfully.  (Otherwise, they;ll think it failed due to, say, a network outage, and they’ll keep sending you the same transaction again and again.)  You’re correct that store.isActive and store.canMakePurchases don’t invoke the listener.  They’re just boolean properties that you can access directly.

  • Andrew

Excellent. Thanks Andrew.

Hi Greg,

(1) Yes, I’d say the minimum required to get going is store.init() and store.canMakePurchases.  store.isActive isn’t a property I’ve used, but I don’t think it hurts to use it.

(2) When you call store.init(), the listener you provide doesn’t get called right then.  You’re merely telling Corona what your listener is so that it can be called later when you call other store functions.  You do need to provide one, otherwise Corona won’t know what to call when you later use store.purchase() and store.restore().

(3) You definitely do need a listener and store.finishTransaction() if you want to actually process transactions.  When you call store.purchase() or store.restore(), the listener you previously specified with store.init() will be called with the transaction status and information.  Within that listener, you must process the transaction (e.g., give the user what they bought, save it to a file) and you must call store.finishTransaction() to tell the App Store / Google Play that you processed it successfully.  (Otherwise, they;ll think it failed due to, say, a network outage, and they’ll keep sending you the same transaction again and again.)  You’re correct that store.isActive and store.canMakePurchases don’t invoke the listener.  They’re just boolean properties that you can access directly.

  • Andrew

Excellent. Thanks Andrew.