Trouble with purchasing consumables on Android devices

If user initiates purchase and goes to home screen before purchasing promt appear, then after returning to game the purchase process won’t be proceeded. Neither ProcessPurchase nor OnPurchaseFailed wouldn’t be called.

Logs from device:

12-25 12:34:24.784 17248 17317 I UnityIAP: isUnityVrEnabled = false
12-25 12:34:24.785 17248 17490 I UnityIAP: invoking callback
12-25 12:34:24.785 17248 17317 I Unity : purchase({0}): com....gems1
12-25 12:34:24.785 17248 17317 I Unity : [IAP] - Set HasActivePurchase to True
12-25 12:34:24.785 17248 17490 I UnityIAP: Querying owned items, item type: inapp
12-25 12:34:24.785 17248 17490 I UnityIAP: Package name: com.
.***
12-25 12:34:24.785 17248 17490 I UnityIAP: Calling getPurchases with continuation token: null
12-25 12:34:24.789 17248 17490 I UnityIAP: Owned items response: 0
12-25 12:34:24.789 17248 17490 I UnityIAP: Continuation token: null
12-25 12:34:24.789 17248 17490 I UnityIAP: Querying owned items, item type: subs
12-25 12:34:24.789 17248 17490 I UnityIAP: Package name: com..
12-25 12:34:24.789 17248 17490 I UnityIAP: Calling getPurchases with continuation token: null
12-25 12:34:24.794 17248 17490 I UnityIAP: Owned items response: 0
12-25 12:34:24.794 17248 17490 I UnityIAP: Continuation token: null
12-25 12:34:24.794 17248 17490 I UnityIAP: Querying owned items’ purchase history, item type: subs
12-25 12:34:24.794 17248 17490 I UnityIAP: Package name: com..
12-25 12:34:24.794 17248 17490 I UnityIAP: Calling getPurchaseHistory with continuation token: null
12-25 12:34:25.021 17248 17490 I UnityIAP: Purchase history response: 0
12-25 12:34:25.021 17248 17490 I UnityIAP: Continuation token: null
12-25 12:34:25.021 17248 17490 I UnityIAP: Querying owned items’ purchase history, item type: inapp
12-25 12:34:25.021 17248 17490 I UnityIAP: Package name: com..
12-25 12:34:25.021 17248 17490 I UnityIAP: Calling getPurchaseHistory with continuation token: null
12-25 12:34:25.348 17248 17490 I UnityIAP: Purchase history response: 0
12-25 12:34:25.349 17248 17490 I UnityIAP: Continuation token: null
12-25 12:34:25.349 17248 17490 I UnityIAP: invoking callback
12-25 12:34:25.744 17248 17490 I UnityIAP: onPurchaseProduct: com...***.gems1
12-25 12:34:25.744 17248 17490 I UnityIAP: ITEM TYPE:inapp

Plugin version: 1.22.0
Unity version: 2019.2.8f1

Did you pay before returning to the home screen? Can you purchase this product again after returning to the game?

Update: some devices, like Sony Xperia XZ3, behave differently.

Steps to reproduce:

  1. Initiate purchase
  2. Press home button before purchase confirmation window appears
  3. Wait a little
  4. Purchase confirmation window will appear surrounded by black screen
  5. Press buy
  6. Watch successful purchase message appear

After step 6 OnPurchaseFailed will be called with Unknown failure reason. ITransactionHistoryExtensions will inform about IABHELPER_BAD_RESPONSE and GOOGLEPLAY_Null data in IAB result (response: -1002:Bad response received).

Nope, I didn’t. The main step is going to home screen before paying and even pressing pay button. We are blocking UI before starting purchase and because neither ProcessPurchase nor OnPurchaseFailed doesn’t get triggered we doesn’t unblocking it. But after restarting the game, we can purchase the same product again.

After restarting game the ProcessPurchase is getting triggered and user receives his reward. But if user try to buy the same product again after step 6, after game restarting the ProcessPurchase doesn’t fire.

I think this is expected behavior.

Do you mean ProcessPurchase has never been called after the second purchase? Generally speaking, if ProcessPurchase is called after the product is purchased, then ProcessPurchase will not be called again after the next application restart.

I doubt. Why doesn’t google store purchase confirmation window appear? I think that OnPurchaseFailed should be called with UserCancelled reason at least.

Case 1. User restart the game after step 6. On next launch ProcessPurchase is called and he receives reward.
Case 2. User make second purchase of the same product after step 6 WITHOUT exiting the game. ProcessPurchase is called and he receives his reward. But on next launch he won’t receive reward from first purchase. But he pays money for both purchases and consume only the second purchase, not the first.

In general, the problem is that user wouldn’t see native purchase confirmation window at all and our game wouldn’t receive any message about it.

Sorry I did not reproduce this issue on my device (Samsung Galaxy S8), does this issue only appear on Sony devices? Can you reproduce this issue on other devices?

If you return to PurchaseProcessingResult.Complete when IAP calls ProcessPurchase to process consumable product, then the next time you start the application, the purchase will not be processed in ProcessPurchase. You should save the consumable purchases yourself in the ProcessPurchase process.

It partially reproduced on our side. Unlike on Sony device, the steps are:

  1. Initiate purchase
  2. Press home button before purchase confirmation window appears
  3. Wait as mush as you like because…
  4. …purchase confirmation window will never appear
  5. OnPurchaseFailed gets called with IABHELPER_BAD_RESPONSE and GOOGLEPLAY_Null data in IAB result (response: -1002:Bad response received) errors but atleast user won’t lose his money

Game doesn’t get broken, user doesn’t lose his money. But on other devices we can reproduce these bugs.

Update: we can reproduce it by hitting Overview button (recent apps button). But there is a low chance to reproduce it.

But it does in “Case 1. User restart the game after step 6. On next launch ProcessPurchase is called and he receives reward.”

It seems that the behavior of other devices is different from that of Sony devices in step 4. After step 3, the purchase confirmation window will appear on the Sony device but other devices will not, right?

Yup, thats right

Hi!

We found the same error. Going to share what we found in case it’s of any help to fix the issue. We found it both on android and ios. It doesn’t happen on all devices.

Steps to reproduce ios:
1 - Complete a normal purchase saving the password for later.
2 - Initiate a second purchase
3 - When the store purchase popup prompts, press the HOME button.
4 - Go back to the app, UNKNOWN failure reason appears.

Steps to reproduce Android:
1 - Initiate a purchase
2 - When the store purchase popup prompts, press the HOME button.
3 - Go back to the app, UNKNOWN failure reason appears.

Devices where we found it happen:
HTC One M8
OnePlus 6 (Android10)
iPad Pro 10"
Samsung Galaxy S4 (Android 5.0.1)
iPad Pro 12"
Huawei P20 lite
Moto E5
Samsung Galaxy S9
Samsung Galaxy Tab SM-T510

Devices where it doesn’t happen (When coming back to the app the purchase popup remains there):
Iphone X
BQ Aquaris m10
iPad Pro 2
Wiko View XL
Huawei Mediapad T3 10
Xiaomi Mi A3
Samsung note 10+

Using Unity 2018.4.19f1.
Using IAP version 1.23.3.

Hope it helps to resolve the issue.

1 Like

We are checking.

Can you try with IAP 1.23.4 ?