Issue when purchase testing Android IAP product using "Slow test card" method

Bug Description

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

  1. On method “Slow test card, approves after few minutes”, the transaction state should become PENDING. After few minutes, transaction state becomes PURCHASED
  2. On method “Slow test card, declines after few minutes”, the transaction state should become PENDING. After few minutes, transaction state becomes FAILED or error
1 Like

Thank you for reporting this! I was not aware of slow test cards. How do you use them?

Could you please create a ticket in the extension-iap repository on GitHub so that we can start an investigation?

1 Like

That’s great. Thank you.

I still encounter the same issue when using the newest version of IAP extension.

here is my logcat when purchase testing google play products using the “Slow test card, approves after few minutes” method :

Hmm, ok, I was not able to reproduce this. Which Android OS version are you testing on?

Samsung A32 (Android 12) & Google Pixel 4 (Android 11)

We’re seeing this same issue:

 ERROR:IAPEXT: IAP error 5
09-15 14:19:39.468 21314 21545 D defold  : DEBUG:SCRIPT: IAP Error
09-15 14:19:39.468 21314 21545 D defold  : DEBUG:SCRIPT: {
09-15 14:19:39.468 21314 21545 D defold  :   error = "failed to buy product",
09-15 14:19:39.468 21314 21545 D defold  :   reason = 0
09-15 14:19:39.468 21314 21545 D defold  : }

and suspect it’s causing problems for real-life users.
I’d be really curious to know if anyone is using defold-iap in a published Android game?

I am almost 100% certain that Melsoft is using it in Family Island. Perhaps @Insality can confirm?

Does this show up in the Play Console?

I used the extension with Apple Spider, and always saw a lot of “Payment declined” from certain countries.

Don’t do any logging in production, so not sure if it’s related.