Google Play IAP event.transaction.state == "purchased" never gets called

Okay in an epic change of events it’s working now…What did I do? Absolutely nothing. 

I just kept putting orders though and then after like 10 orders it started working. The next 5 went through just fine. Really confusing, but oh well it works :slight_smile:

Thanks for everyone’s help.

Thanks for the log output.  The “PendingNotificationService” log message at the end is the “purchased” notification be broadcasted by the Google Play app.  So, that’s a good sign that the notification was successfully sent to your device.

Also, you haven’t ever hacked your APK and changed its AndroidManifest.xml file, have you?

Or… are you a Corona Enterprise user?

I ask because in both cases, you might be missing a BroadcastReceiver in your AndroidManifest.xml file that is needed to receive notifications from Google.  (It is there for all Corona Simulator builds.)

Hah!  We both posted at the same time!

I’m glad it’s working for you.  I’m wondering if it was some kind of caching issue with the Google Play app.  I’m not really sure.

Okay I’m seeing strange results. Sometimes I will make a purchase and everything will work just fine other times I will make the same purchase and I will get 5+ listener calls. They all have the same data returned (orderID, productID etc) but the resquest numbers are different. Any idea on why randomly products will return a bunch of success calls?

This is the response

D/Finsky(4328): [1] MarketBillingService.sendResponseCode: Sending response RESULT\_OK for request 5628181007854239765 to wheel.slots.leetcom.com. D/Finsky(4328): [1] MarketBillingService.sendResponseCode: Sending response RESULT\_OK for request 1700531723790948464 to wheel.slots.leetcom.com. D/Finsky(4328): [1] MarketBillingService.sendResponseCode: Sending response RESULT\_OK for request 582475236503027374 to wheel.slots.leetcom.com. D/Finsky(4328): [1] MarketBillingService.sendResponseCode: Sending response RESULT\_OK for request 2698016979307428823 to wheel.slots.leetcom.com. D/Finsky(4328): [1] MarketBillingService.sendResponseCode: Sending response RESULT\_OK for request 3489384765658278205 to wheel.slots.leetcom.com. D/Finsky(4328): [1] MarketBillingService.sendResponseCode: Sending response RESULT\_OK for request 5368633466355141703 to wheel.slots.leetcom.com. D/Finsky(4328): [1] MarketBillingService.sendResponseCode: Sending response RESULT\_OK for request 875961568349548605 to wheel.slots.leetcom.com. D/Finsky(4328): [1] MarketBillingService.sendResponseCode: Sending response RESULT\_OK for request 8999392674353360692 to wheel.slots.leetcom.com. D/Finsky(4328): [1] MarketBillingService.sendResponseCode: Sending response RESULT\_OK for request 1439908923599180228 to wheel.slots.leetcom.com.

This is  what the above returned 9 times. What is strange is there are 9 orders returned in the orders object. I only purchased 1 order though.

I/Corona(7091): ~~~~~~~~APP STORE~~~~~~~~ transactionCallback: Received event storeTransaction I/Corona(7091): ~~~~~~~~APP STORE~~~~~~~~ state: purchased I/Corona(7091): ~~~~~~~~APP STORE~~~~~~~~ errorType: none I/Corona(7091): ~~~~~~~~APP STORE~~~~~~~~ errorString: I/Corona(7091): ~~~~~~~~APP STORE~~~~~~~~ Transaction successful! I/Corona(7091): ~~~~~~~~APP STORE~~~~~~~~ receipt: {"nonce":-7696189100248259916,"orders":[{"notificationId":"-4611826006870453728","orderId":"12999763169054705758.1366811113029972","packageName":"wheel.slots.leetcom.com","productId":"double\_payouts","purchaseTime":1367034727000,"purchaseState":0,"purchaseToken":"zltwxsvzxdtfwirsrrhtrvkc"},{"notificationId":"7162215564741436666","orderId":"12999763169054705758.1367189289214852","packageName":"wheel.slots.leetcom.com","productId":"double\_payouts","purchaseTime":1367035693000,"purchaseState":0,"purchaseToken":"epcjznbnikjdlrevhvuwjbdx"},{"notificationId":"-8412612498536890168","orderId":"12999763169054705758.1321995054202457","packageName":"wheel.slots.leetcom.com","productId":"double\_payouts","purchaseTime":1367035772000,"purchaseState":0,"purchaseToken":"cgggkhqypyzgzgivyqdmubny"},{"notificationId":"-395483000777125701","orderId":"12999763169054705758.1331697714566000","packageName":"wheel.slots.leetcom.com","productId":"double\_payouts","purchaseTime":1367037734000,"purchaseState":0,"purchaseToken":"gkmsyfqvoygzuginummivlyd"},{"notificationId":"2278988028017084230","orderId":"12999763169054705758.1346107916484550","packageName":"wheel.slots.leetcom.com","productId":"double\_payouts","purchaseTime":1367037812000,"purchaseState":0,"purchaseToken":"ryhwlrgkrnxxxmxyazxzqgzv"},{"notificationId":"8366231144424214981","orderId":"12999763169054705758.1390432587546936","packageName":"wheel.slots.leetcom.com","productId":"double\_payouts","purchaseTime":1367038058000,"purchaseState":0,"purchaseToken":"afnlvmoidnezygjuoyladqia"},{"notificationId":"180569651592993847","orderId":"12999763169054705758.1391895778016296","packageName":"wheel.slots.leetcom.com","productId":"double\_payouts","purchaseTime":1367038154000,"purchaseState":0,"purchaseToken":"fulkvxelvnbwmvyiabgdjvax"},{"notificationId":"-5533012885893683259","orderId":"12999763169054705758.1313748973204732","packageName":"wheel.slots.leetcom.com","productId":"jackpot\_500k","purchaseTime":1367038183000,"purchaseState":0,"purchaseToken":"qtwevcemaghczevwlyfvifom"},{"notificationId":"-6963194004359951465","orderId":"12999763169054705758.1387536113005002","packageName":"wheel.slots.leetcom.com","productId":"jackpot\_500k","purchaseTime":1367038234000,"purchaseState":0,"purchaseToken":"xefankpofgilpkgrxdpezwxy"}]} I/Corona(7091): ~~~~~~~~APP STORE~~~~~~~~ identifier:8366231144424214981 I/Corona(7091): ~~~~~~~~APP STORE~~~~~~~~ signature: LGH7glkLEtxzcwHKXVts4h1ah5G+YJUGDcyDzO7F5OTH0xnL2/5NkRZGHW7VwX+YCvZuPiOJF9wZ1qc6DRJcTZecAAw3aqSND8uUsS85mVht4GfVF7gmDxii59zwzORHDg/zCPsQghUNLpT5aaRWCsqDmpeMlBrd7KLcN+lHypdm4uAYgSWUyTpyE/Trr10SfSTl/3Cb3NI5OF1Mnp46XytuI6/zVoobPWZjYOgzyCS0LWo6U8irXguL/8S2avF5VugOk7zYnGJwJAWzBjisuTTsTg8EnmC3DqJv5CKT9TwAAElK73NbGmkrdPXpHYKUBX5+Mw3UgglqRUJQEtWfig==

Not sure what to make of any of this but I just uninstalled the app and reinstalled it. I then made 1 purchase and let it sit for 20 minutes or so after the purchase. The listener was called successfully 10 times and then a few minutes later the listener was called successfully 8 times. 

I’m so confused on what’s going on with this thing. Anyone have any ideas on why the listener is getting called so many times after 1 purchase?

Also the 18 purchases that come through aren’t even the right purchases. It’s a different sku all together.

EDIT: I think I figured it out there was an error parsing the data so store.finishTransaction(event.transaction) was never getting called. I’m not sure what this function does exactly but once I added that it seems to be working correctly now. Does that just tell google that we’ve received the item?

That’s my understanding of what store.finishTransaction() does, but I’m not 100% sure so don’t hold me to that. I think it just notifies iTunes / Google Play that you have successfully received confirmation of the purchase, in case the user lost their connection or something during the purchase process.

The store.finishTransaction() function sends a confirmation to Google that your app has successfully received the purchase notification.  If you do not send this confirmation, then Google Play will repeatedly send that purchase notification to your app until it does, which accounts for the duplicate events that you are seeing.  This is a safety mechanism on Google’s part in case your app fails to respond for whatever reason, such as if it crashed or had an error in the middle of a transaction.

Please note that you should only call store.finishTransaction() after you have saved the purchase to file/database.  Otherwise you risk putting the app in a bad state where Google thinks the product has been purchased, but the app fails to unlock the purchased item.

Also, if you set up Corona to display runtime errors, it would make it a lot easier/faster to debug these kind of things.

http://docs.coronalabs.com/guide/basics/configSettings/index.html#debug

Anyways, I’m glad you go it working!

I submitted a bug request for this seeing as how their sample is doing the same thing. I wonder how long it will take to fix. I was so close to launch too, but now the app is on hold waiting for this =/

Same here! Right before the google play store changes all of my iap where working fine…now they are not. Not even the sample iap Code completes the purchase.

Glad I’m not the only one. Hopefully we can get someone to confirm this or at least confirm the fact that they’ve read this post.

@dmglakewood are your iap for iOS working ok?

Haven’t tried it on an iOS device yet

The “cancelled” listener works if you press the back button during checkout. If google play says “payment successful”… when returning to the game the activity indicator remains on and nothing else is called. You have to then restart the game. Is this also what everyone else is experiencing?

What is your bug ID #

Hi Rob, 

I opened one as well…

Case 22927

My bug ID is 22833

Yep that’s exactly what I’m seeing as well.

I’m getting the same bug.

Strangely, I still had the old store showing up until about an hour ago, and was trying to fix a different bug (I’m getting the “invalidClient” response when testing). Then at some point in the middle of testing the Google Play popup changed from the full screen one to a popup (which got my hopes up thinking I’d fixed my own bug) and now there is no “purchased” response.

Yeah google has bee pushing the new store out to everyone over the past week or two. Slowly but surely every corona app that allows in app purchases will no longer work. I think this is a HUGE bug as a lot of apps no a days rely on IAP as their only source of revenue . Not only that but if someone spends 1$ to but something in a game and it doesn’t work, do you think they will try it again?

Okay got a reply to my bug

"Hi,

Turns out we needed to find an Android device with the updated version
of Google Play.  We have recreated the problem and will be looking into
it.  Thanks for filing the bug."