When using “Slow test card, approves after few minutes” method on purchase testing, the transaction state become error with reason iap.REASON_UNSPECIFIED. After 3-5 minutes, transaction state become iap.TRANS_STATE_PURCHASED.
Same with “Slow test card, declines after few minutes”, the transaction state also become error with reason iap.REASON_UNSPECIFIED. But after 3-5 minutes, the API does not give any information if the pending transaction is fail/error.
I use this listener code for testing Google play IAP Billing :
local function buy_listener(self, transaction, error)
pprint(transaction)
if error == nil then
if transaction.state == iap.TRANS_STATE_PURCHASING then
print("Purchasing...")
elseif transaction.state == iap.TRANS_STATE_PURCHASED then
print("Purchased!")
print("transaction id : " .. transaction.ident)
elseif transaction.state == iap.TRANS_STATE_UNVERIFIED then
print("Unverified!")
elseif transaction.state == iap.TRANS_STATE_FAILED then
print("Failed!")
elseif transaction.state == iap.TRANS_STATE_RESTORED then
print("Restored")
end
elseif error then
print(error.error)
if error.reason == iap.REASON_USER_CANCELED then
print("Reason User Canceled")
elseif error.reason == iap.REASON_UNSPECIFIED then
print("Reason Unspecified")
end
end
end
Expected behaviour
On method “Slow test card, approves after few minutes”, the transaction state should become PENDING. After few minutes, transaction state becomes PURCHASED
On method “Slow test card, declines after few minutes”, the transaction state should become PENDING. After few minutes, transaction state becomes FAILED or error
If someone is having the same issue, you are probably using iap.finish() or iap.acknowledge() while you also have auto_finish_transactions set to true in the game.project
In that case, you are tyring to finish the purchase twice. Once auto_finish_transactions is set to false you should not see the error anymore.