I am testing in app purchase on Android.
I wanted to test the negative scenarios, so I’ve used a card which I cannot pay electronically.
I’ve received an error message from google, saying that I cannot use this card, but the transaction state I got was “purchased”.
Here’s the whole scenario I got and every transaction state I’ve received:
-
Use a card I cannot use online
-
Use a card with no money on it
-
Use a card attached to another account
-
Use a valid card with money on it
In google wallet, I can see 2 cancelled operations and one submitted fine [I cannot see the operation for a card attached to another account].
In my code, I log every call to the in app purchase handler to see the transaction state, and here’s the list I got after these 4 operations:
I/Corona ( 8676): ARCHER INFO =?:0 !!! TRANSACTION !!! cancelled I/Corona ( 8676): ARCHER INFO =?:0 !!! TRANSACTION !!! cancelled I/Corona ( 8676): ARCHER INFO =?:0 !!! TRANSACTION !!! cancelled I/Corona ( 8676): ARCHER INFO =?:0 !!! TRANSACTION !!! cancelled I/Corona ( 8676): ARCHER INFO =?:0 !!! TRANSACTION !!! cancelled I/Corona ( 8676): ARCHER INFO =?:0 !!! TRANSACTION !!! cancelled I/Corona ( 8676): ARCHER INFO =?:0 !!! TRANSACTION !!! cancelled I/Corona ( 8676): ARCHER INFO =?:0 !!! TRANSACTION !!! purchased I/Corona ( 8676): ARCHER INFO =?:0 !!! TRANSACTION !!! cancelled I/Corona ( 8676): ARCHER INFO =?:0 !!! TRANSACTION !!! cancelled I/Corona ( 8676): ARCHER INFO =?:0 !!! TRANSACTION !!! purchased I/Corona ( 8676): ARCHER INFO =?:0 !!! TRANSACTION !!! cancelled I/Corona ( 8676): ARCHER INFO =?:0 !!! TRANSACTION !!! cancelled I/Corona ( 8676): ARCHER INFO =?:0 !!! TRANSACTION !!! purchased
That is not something I would expect to happen.
Especially that I have purchased the app only once.
It seems that after a “purchased” call I can get “cancelled” call, is this correct? Is this valid?
I used to do nothing on “cancelled” and unlock my game on “purchased”. Now I think I have to lock the game on “cancelled”.
Here’s my code of the in app purchase handler:
local function handleInAppPurchase(event) local transaction = event.transaction if waitingPopup then waitingPopup:close() waitingPopup = nil end log:info("!!! TRANSACTION !!! %s", tostring(transaction.state)) if transaction.state == "purchased" then if transaction.productIdentifier == ARCHER.storeRemove then [...cut...] end elseif transaction.state == "restored" then if transaction.productIdentifier == ARCHER.storeRemove then [...cut...] end elseif transaction.state == "cancelled" then Popup.simplePopup(ARCHER.l("purchaseCancelled")) if transaction.productIdentifier == ARCHER.storeRemove then [...cut...] end elseif transaction.state == "failed" then log:info("errorType: %s", tostring(transaction.errorType)) log:info("errorString: %s", tostring(transaction.errorString)) Popup.simplePopup(ARCHER.l("purchaseFailed")) if transaction.productIdentifier == ARCHER.storeRemove then [...cut...] end elseif transaction.state == "refunded" then if transaction.productIdentifier == ARCHER.storeRemove then [...cut...] end end store.finishTransaction(transaction) end
In other words, I only expected this function to be called once after it was initialized. It seems it can be called multiple times if user performs multiple operations.
BTW. I expected “failed” events when I was unable to pay with my card. weird.