store.finishTransaction() is not working properly

hey klaus and d8, easy. calm down.

I have experienced strange behavior with my account too at that time. I took build 984, builded, released. and all worked fine. same did ingemar. i am still not sure if this is a corona thing, i doubt.
[import]uid: 90610 topic_id: 35459 reply_id: 141168[/import]

Chill people, let’s solve problem.

  1. The [blockcode]cancelled [/blockcode] is happening to me, because I cancelled it.

  2. I have managed and unmanaged items.

  3. I create my app in the Android Developer Console new design
    Let’s provide every bit of knowledge together and solve problem.

[import]uid: 143031 topic_id: 35459 reply_id: 141170[/import]

In my case, i used unmanaged items, and old design Developer Console [import]uid: 86585 topic_id: 35459 reply_id: 141197[/import]

In my case, i used unmanaged items, and new design Developer Console [import]uid: 15448 topic_id: 35459 reply_id: 141198[/import]

Dr.Klaus,
I think your in-app purchase issue is different than topfuncoolgames’ issue. So, I’ll respond to you on your forum thread so as not to cause confusion on this thread.

topfuncoolgames,
Since this is your forum thread, I’m going to focus on your canceled notification issue here.

I’ve looked up your issue on Google’s issue database and I believe I’ve found a similar issue here…
http://code.google.com/p/marketbilling/issues/detail?id=29

One commenter on that page indicated that removing all test users and adding a new test user account to the Android Developer page worked-around this problem. This sounds familiar to me because I remember another Corona developer having a similar issue. Like his test gmail account was being flagged as fraudulent by Google Checkout. So, you may want to try testing with a different account to see if this works-around this issue. Although, I seriously hope this does not happen to real customer accounts.

Also, how long does it take for the purchase notification to be received by your Lua listener? Is it near immediately or does it take a couple of minutes? I ask because I’m wondering if the Google Play purchase requests are timing out and its the Google Play app on your Android device that is generating all of the canceled notifications.

Today, I also double checked our code to make sure that we are handle in-app billing notifications and finishing/confirming those notifications correctly. I even compared against Google’s newest sample code (their Dungeons app) and current documentation. Everything appears to be fine on our end (I spent a few hours confirming this today). As long as the transaction that you are receiving in Lua has a “event.transaction.identifier” string, then the [lua]store.finishTransaction()[/lua] function will send a CONFIRM_NOTIFICATIONS request to Google Play. If that identifier is nil or an empty string, then our finish function will ignore the given transaction. You may want to try printing that identifier to the log too. Just be aware that it’s normal for it to be an empty string for errors or when the end-user Backs-out of the in-app purchase window.
[import]uid: 32256 topic_id: 35459 reply_id: 141285[/import]

Hi Joshua,

Thanks for your reply.

The response from Google Play is immediate, and, yes, my phone has 2 google account linked, and both of the account were listed as test account in developer console. (although only the primary account has credit card associate to it)

The [blockcode]transaction.identifier[/blockcode] can be printed successfully.

I tried to removed the secondary account from my phone and also from developer console test user, but it still behave the same.

It would be some trouble for me to set up another test account, as I have no extra credit card to use. But, yea, will test that out with different user. [import]uid: 143031 topic_id: 35459 reply_id: 141296[/import]

Wait a minute… I just had a thought.

Could it be the Google Play app on the device that is caching purchase transactions and isn’t aware of a developers test accounts? This could explain all of these “cancelled” events since a normal user shouldn’t be able to purchase more than once.
Even if a developer cancels the purchase in their Merchant account, this info would never be propagated to the device.

If this is the case, is there a way to delete the Google Play app cache? [import]uid: 70847 topic_id: 35459 reply_id: 141297[/import]

Hi ingemar,
I did tried to clear all the Play service and Play store cache. But things still the same.

In my case, it happens to both managed and unmanaged items. So the user can actually purchase many times unmanaged item. [import]uid: 143031 topic_id: 35459 reply_id: 141313[/import]

I am getting sick of this problem. This is the exact code I tested:

[lua]local store = require “store”

local function callback(event)

local transaction = event.transaction

print("++++ " … transaction.state … " " … transaction.productIdentifier … “++++”)

if transaction.state == “purchased” then

elseif transaction.state == “restored” then

elseif transaction.state == “refunded” then

elseif transaction.state == “cancelled” then

elseif transaction.state == “failed” then

end

store.finishTransaction(transaction)

end

if store.availableStores.apple then
store.init(“apple”, callback)
elseif store.availableStores.google then
store.init(“google”, callback)
end
local widget = require “widget”

local buyBtn = widget.newButton{
label = “buy”,
onRelease = function()
store.purchase({
“net.topfuncoolgames.barfriends1.cash1”
})

end

}
buyBtn.x = 100
buyBtn.y = 100

local restoreBtn = widget.newButton{
label = “restore”,
onRelease = function()
store.restore()
end
}
restoreBtn.x = 100
restoreBtn.y = 200[/lua]
Then make 1 purchase:

this is what I got:
[blockcode]
++++ purchased net.topfuncoolgames.barfriends1.cash1++++
[/blockcode]
Then I made 2nd purchase of same item
[blockcode]
++++ purchased net.topfuncoolgames.barfriends1.cash1++++
++++ purchased net.topfuncoolgames.barfriends1.cash1++++
[/blockcode]
And you know what is the creepiest? Constantly spamming [blockcode]store.restore()[/blockcode] will return all the transaction, so user has unlimited in-game money.

Please correct me if there is something wrong with my code.

This is what I tested:

  • A 2nd test device with a new test account
  • A new app with different ID, uploaded using new developer console.

Please, someone must be able to reproduce the bug. Some us your minimal code that works (not the corona sample, too long) [import]uid: 143031 topic_id: 35459 reply_id: 141638[/import]

I can’t wait for any support from Corona anymore. So I cooked my own solution.
I stored all the transaction receipt in database, and check if the transaction happens before.

If yes, ignore it, else proceed it.

Hope this is useful. [import]uid: 143031 topic_id: 35459 reply_id: 141649[/import]

I have made this 3 days ago, as i wrote before:

>I confirm, the multiple requests of callback transaction function is happened on latest builds for google play. The temporary solution, to store reciept ids of succeded transactions in file, and compare for unique ids on every callback. [import]uid: 86585 topic_id: 35459 reply_id: 141658[/import]

Ops, sorry for not paying enough attention, as I am hoping Corona will give us official fixes. Thanks! [import]uid: 143031 topic_id: 35459 reply_id: 141661[/import]

I personally think this is more of a Google issue. I may be wrong, but I saw these issues start to happen with my IAP apps immediately after they introduced version 3 of their In-App Purchase API.
Since Corona is using version 2, I think that Google might not be handling the version 2 API calls the same way as before.

I don’t have any proof, and I don’t have any immediate projects that require IAP this month so I can do further testing. However I’ll be starting one next month, so I’ll be joining the circus then… [import]uid: 70847 topic_id: 35459 reply_id: 141664[/import]

And it seems to me that the core problem in function store.finishTransaction( transaction ), it basicly does not work and causes this repeats of old transactions again. [import]uid: 86585 topic_id: 35459 reply_id: 141669[/import]

I’m sorry that Google Play is giving you so much trouble, but to be honest, I don’t think there is anything we can “fix” on our end. I’m not trying to be difficult here, but there really isn’t much to the in-app purchase system. We just establish the connection to the Google Play app, send the requests, and receive responses/notifications according to Google’s documentation and Dungeon example. The [lua]store.finishTransaction()[/lua] function definitely works or else your purchases would not work at all… and I’ve confirmed that that function will send a CONFIRM_NOTIFICATIONS request for any transaction object that you gave it that has an identifier.

The only thing that I can think of is that you’re running into a bug with Google Play. You can see a full listing of their bugs here…
http://code.google.com/p/marketbilling/issues/list

As you can see in the link above, a lot of Android developers are frustrated with Google’s in-app purchase system too. It may very well be that Google broke something when they updated to version 3, because it was working flawlessly all last year.

The following bug reports sound like the issue that you’re running into…
http://code.google.com/p/marketbilling/issues/detail?id=94
http://code.google.com/p/marketbilling/issues/detail?id=92

Google did accept that their is a bug with refunds and cancelled purchases. Developers seem to think that there is a caching issue on the Google server end.

I think your app tracking transaction IDs is a reasonable way of working around this issue.
[import]uid: 32256 topic_id: 35459 reply_id: 141737[/import]

Hi Joshua,

I implemented In App Billing into the Google’s Dungeon sample app, for v2. I am using same current package id, and same keystore and key alias as my app.

The great thing is, it cleared all the purchases, like it called all store.finishTransaction().

Now when I back to my game compiled with Corona, there is no more unfinish transaction callback, just quiet.

But when I made 2 purchases, the list begin, n * n unfinish transactions.

This shows that the problem is from Corona side, not Google side.

1 thing worth mention: I copy and pasted the license key/public key from my Google Play console, into the Dungeon sample app, this steps seems missing from Corona IAB. [import]uid: 143031 topic_id: 35459 reply_id: 142995[/import]

I’ve experience the same issue.

Unmanaged products are reported multiple times in callback (N*N times, where N is a number of purchases before).

Steps to reproduce:

  1. Create unmanaged in-app purchase (the only way to implement consumable items so far)
  2. Purchase it first time: you’ll see one callback
  3. Purchase same item once more: you’ll see 4 callbacks

    N) You’ve now got really a lot of coins/stars/potions, other consumables

Current workaround is to store transaction history locally and process only new items. [import]uid: 199969 topic_id: 35459 reply_id: 143155[/import]

Actually it happens to managed and unmanaged. Managed products still coming back, after calling store.finishTransaction().
[import]uid: 143031 topic_id: 35459 reply_id: 143163[/import]

Dear Corona Staff,

we actually experience the same problem with in-app purchases on Android as colleagues stated above. We noticed all the shit started when we first used build 1024. Since that time, the problem appears in any daily build we use.

Seems like function store.finishTransaction( transaction ) is not working properly. With any new purchase made, we receive all the purchases user has made before. EVEN WHEN USER MAKES STORE.RESTORE(), HE RECEIVES ALL THE UNMANAGED (!!!) PURCHASES HE MADE BEFORE WITH THIS ACCOUNT. So this is definitely A BUG. Please fix it ASAP. As it is a CRITICAL BUG. We actually cannot publish a new release because of it.

Probably this can help you with identifying the bug: if we rebuild our app with stable build 971, everything is ok. finishTransaction is working properly with that build.

Kind regards,
Supreme team [import]uid: 195776 topic_id: 35459 reply_id: 143463[/import]

Everyone, we’re going to give this issue a deeper look later this week.

supremevc, if reverting to an older build works-around this issue, then that suggests that our fix in daily build #984 is responsible.
http://developer.coronalabs.com/release/2012/984/

Back in December, Google Play updated their in-app purchase system to version 3 which completely broke store.finishTransaction(), causing it to always return a failure. This means purchases did not work at all and you would never receive any payments (at least now you currently receive payments). We discovered in Google’s dungeons sample code that they’ve added a “nonce” to their CONFIRM_NOTIFICATIONS response which was not documented. When we added it to our code, it resolved the issue and allowed purchases to work again. But after downloading their newest dungeons sample code I’ve discovered that the “nonce” has been removed, matching the old behavior. Sounds like Google changed their mind again. This “might” be the cause of the issue because it’s the only discrepancy I’ve seen, although a bit surprising because extra information in Bundle object should not cause any harm.

In any case, we’ll dig into this more later this week. The important thing is for us to reproduce the problem and confirm the fix for ourselves. I don’t want to waste time guessing/speculating what the issue is. Thank you for your patience.
[import]uid: 32256 topic_id: 35459 reply_id: 143485[/import]