Google IAP V3 Consumables Working? Syntax?

Today I am calling the store.consumePurchase from inside my transactionCallBack of the store.purchase (I test if the purchase was successful and if the product is a consumable one. If so, I call the store.consumePurchase).

Google also recommends that you call a consumeProduct on your app launch but I am not doing that right now.

Ok, that makes sense Renato.  So when you finally call store.consumePurchase, do you just resend the same productSKU in a table as the sample in the Corona docs suggest, like so:

store.consumePurchase( {“productSku”} )

or do you call it with a sku and a listener, like the Corona docs syntax suggests, like so:

store.consumePurchase( “productSku”, listener )

or, do you do something more like what Google’s docs seems to suggest and retrieve some kind of transaction identifier from the initial purchase and then send it with the consumePurchase call, something like so:

store.consumePurchase( “transaction.identifier”)

or

store.consumePurchase( {“transaction.identifier”})

Sorry I need you to spell it out for me, I just really don’t understand how this is supposed to work.

Thanks for your help!

-Stephen

1st option

store.consumePurchase( { productSku } )

Awesome, Thanks.  I’ll give it a go.

Ugh.  I’ve tried every permutation of consumePurchase using the product SKU I can think of, and none of them work.  Every bit of official Google documentation on consume purchases I’ve found says you need to pass in the purchase token, not the SKU.  Google doesn’t make this easy to test either since once you make the purchase, if you don’t correctly consume it you will of course lose the purchase token with no way to set it as consumed.   To test it again you have to cancel the purchase from the merchant wallet, which took about 12 hours last time I did it.

I would really appreciate some input from someone at Corona Labs since, in the least, your own documentation is inconsistent and there are no sample apps that exercise the consumePurchase functionality using the V3 plugin.

Stephen,

Corona functions usually wraps the native function and so they can modify the parameters of the functions (specially to make the function consistent among all platforms). Therefore, always prefer to follow Corona documentation instead of the native/3rd party provider.

The product consume function is working for me, so it is probable that you are making some mistake on your code or there is some bug in your Corona version. Share you code and Corona version here so we can take a look on it.

You can consume a product anytime. So, you don’t have to keep canceling the purchase on your wallet. Just do a store.restore() and Google will send you all the products that you have. That way you can get all the info that you would have got after the purchase.

I just tested my code on a different user account and was able to perform a consumePurchase using just the sku.  That is a relief, I thought I was going crazy.  

I think something got messed up with the original account I was testing on, where after I had used one of the static Android SKUs to test with it could no longer get correct information from my production SKUs, and the app would crash if I tried to do a consume.  I thought it was my consume code causing the crash, but when I happened to test previously working restore purchases code that also crashed the app and got me suspicious that there was something wrong with the account.  Who knows, maybe I broke google  :rolleyes:

Anyway, Renato, thanks again for your help.  

Glad that you solved.

I read somewhere in the forum about a problem using the Google default SKU, maybe there is indeed a bug with Google IAP v3 and Google default SKUs.

Yeah, here’s a thread on stack overflow where one of the answers alludes to the  android.test.purchased default SKU causing problems with his production SKUs.  He had to remove the fake product from being owned to remove the problems with his production SKUs.  Successfully consuming a purchase would be a way to unown it, which was the very thing I was unable to do because of the strange behavior! 

http://stackoverflow.com/questions/7070573/android-in-app-billing-security-java-says-signature-verification-failed/

That sounds very close to what recently happened to me too: http://forums.coronalabs.com/topic/47831-google-iap-v3-fatal-exception-from-storeinit/ I got the strong impression that the static SKU’s aren’t working “quite right”.

@davebollinger,

Yes, I believe your issue is the same or related.  Except for me the “not working quite right” was really, really broken behavior.  Some of the links you posted in your thread allude to fixes, but none of them are doable from a Corona SDK app as far as I can tell.  I think the only thing I can do is trash the test user account permanently, and never, ever use the android.test.purchased SKU again, which is a real shame since it is a useful way to test IAP.  I guess CL could make some kind of fix but that seems unlikely given how esoteric the bug is.  

I would really love to see a more “Coronafied”  solution that handles IAP (and consumables) in a truly cross platform way.  The current system with Google V3 as a plugin, Apple as non-plugin and with slightly different syntax for purchases has been time consuming to test and get working.

-Stephen

I think we are going forward on this direction. I don’t know if you noticed, but the Google IAP v3 plugin has the same syntax of the Amazon. Only Apple nows that has just one slight different syntax when calling the purchase. I believe in the future, Apple IAP may become a plugin and be equal to others in term of syntax.

Of course, there is no solution if a 3rd party as Google comes and creates a new function as consumeProduct, changing how they manage the products. That is something that we need to live with.

Just to update, today my google account that was formerly exhibiting strange behavior and crashing during IAP is now working again. I didn’t change my code.  It seems like most of the problems I have with google IAP are fixed by simply waiting between 15 minutes and 24 hours.  I’m still going to try to avoid using the android.test.purchased SKU in the future, but at least it didn’t permanently bork my test account.