Hi all great people,
I am currently implementing in app purchase to my game, but faced a weird behavior that I never encountered in my previous few games.
First time, when I purchase 1 item, transactionCallback 1 purchased state, I get 1 item.
Second time, I purchase another 1 item, transactionCallback 2 purchased state, I get 2 items now (plus previous item, I have 3 items)
Third time, I purchase another 1 item, transactionCallback 3 purchased state, I get 3 items. (plus previous items, I have 6 items now)
and so on…
Typically, this behavior will happen, if no store.finishTransaction(event.transaction), but in my case, I called it, and to prove the store.finishTransaction is executed, I added a print() after it. But not working.
This is a minimum viable code I tested, that shows error:
[lua]local store = require (“store”)
local count = 0
local function storeTransactionCallback(event)
if event.transaction.state == “purchased” then
count = count + 1
print("=====" … event.transaction.state … “===== " … count … " =====”)
end
store.finishTransaction(event.transaction)
end
if store.availableStores.apple then
store.init(“apple”, storeTransactionCallback)
elseif store.availableStores.google then
store.init(“google”, storeTransactionCallback)
end
local function purchase()
count = 0
store.purchase({“net.topfuncoolgames.barfriends.testitem”})
–store.restore()
end[/lua]
In the 3rd time of purchase() call, this is what it returns:
=====purchased===== 1 =====
=====purchased===== 2 =====
=====purchased===== 3 =====
Why is this happening?
[import]uid: 143031 topic_id: 35459 reply_id: 335459[/import]