Google v3 consumePurchase Question

Hello all, I’m hoping that this will be a fairly quick answer, given the amount of people I’m sure who have this successfully working… but we have both consumables and non-consumables in our app.  From what I’ve read in Corona’s documentation, you are supposed to use:

store.consumePurchase({“ID1”,“ID2”, “etc”});

IN PLACE OF

store.purchase(“ID”);  --no brackets in .purchase

for consumables.

However, I’ve also read from other developers experiencing problems with iap, that they have used store.consumePurchase AFTER using store.purchase, and within the transactionListener method, and it supposedly has worked for them.  Can either way work, or has anyone found that it is one or the other?  Is one way necessarily better than the other?

If I read the documentation correctly for IAP V3, you need to call store.purchase() to actually buy the item.  Then you have to consume the purchase.  If you’re doing a fantasy game and your person buys a healing potion.  You would call store.consumePurchase() when they actually used the item.  This gives people a chance to request a refund for consumables (well non-managed items in Google Lingo).  Since most consumables are buying coins or some other in-game currency, you would consume it right away.  In the app I’m building now I will call store.consumeProduct() in my transaction listener if it’s a purchase event.

Rob

Thanks very much for the clarification.  I was checking out the bottom of:

http://docs.coronalabs.com/plugin/google-iap-v3/consumePurchase.html

where it had in the code example:

store.init( transactionCallback )
store.consumePurchase( {“manangedItem1”, “managedItem2”} )

I guess I was taking it too literally, thinking that you could call consumePurchase similarly to the purchase method since it was happening straight after the init in the example.

If I read the documentation correctly for IAP V3, you need to call store.purchase() to actually buy the item.  Then you have to consume the purchase.  If you’re doing a fantasy game and your person buys a healing potion.  You would call store.consumePurchase() when they actually used the item.  This gives people a chance to request a refund for consumables (well non-managed items in Google Lingo).  Since most consumables are buying coins or some other in-game currency, you would consume it right away.  In the app I’m building now I will call store.consumeProduct() in my transaction listener if it’s a purchase event.

Rob

Thanks very much for the clarification.  I was checking out the bottom of:

http://docs.coronalabs.com/plugin/google-iap-v3/consumePurchase.html

where it had in the code example:

store.init( transactionCallback )
store.consumePurchase( {“manangedItem1”, “managedItem2”} )

I guess I was taking it too literally, thinking that you could call consumePurchase similarly to the purchase method since it was happening straight after the init in the example.

elsoqo, I think that example in the official docs is confusing also.  It doesn’t seem to be the most common use case, which is to purchase first, then consume.

I’d like to see a complete example of how to implement consumables in a common use case, such as buying gold, for example.

Dave

The idea behind consume purchase is that you do it after you consume it.  If  person buys a health potion,  you can’t buy another one until that one has been consumed.  Of course Google didnt’ think about how games really work.  You may want to stock up on health potions, and this requirement to consumePurchase really limits that method of buying things. 

The work around to this is to call store.consumePurchase() in your callback listener when you make a purchase for a consumable object. 

As for the sample code at the bottom, it would be even more confusing for us to try and put in a full working sample given that purchase requests typically happen in other modules.  But you can always hit the feedback button at the bottom letting us know that the example is confusing.

Rob

elsoqo, I think that example in the official docs is confusing also.  It doesn’t seem to be the most common use case, which is to purchase first, then consume.

I’d like to see a complete example of how to implement consumables in a common use case, such as buying gold, for example.

Dave

The idea behind consume purchase is that you do it after you consume it.  If  person buys a health potion,  you can’t buy another one until that one has been consumed.  Of course Google didnt’ think about how games really work.  You may want to stock up on health potions, and this requirement to consumePurchase really limits that method of buying things. 

The work around to this is to call store.consumePurchase() in your callback listener when you make a purchase for a consumable object. 

As for the sample code at the bottom, it would be even more confusing for us to try and put in a full working sample given that purchase requests typically happen in other modules.  But you can always hit the feedback button at the bottom letting us know that the example is confusing.

Rob