Why Android BillingClient v2 slow credit card test never cancels?
Asked Answered
A

3

17

I am implementing the new BillingClient library (v2.1.0) for a non-consumable in-app purchase. I am testing pending transactions with a test user. It works fine with "Credit card approves after a few minutes", but with "Slow credit card, rejects after a few minutes" the purchase state is always pending (Waited for hours after it shows as canceled on Play Console).

In order to retrieve purchae status, I am calling to mBillingClient.queryPurchases(BillingClient.SkuType.INAPP) as states in the documentation

Has anybody come across this issue before? Is it a development environment problem or does it happen for final users as well?

Thanks!

Agraffe answered 15/12, 2019 at 20:21 Comment(1)
Same issue here, its probably a bugAbessive
A
6

I also discovered that in my tests, although I also remember that using the deprecated AIDL a user of my app took 24 hours to validate the purchase. I have considered the case of the refused slow card taking hours may occur and I have done the following:

If purchase.getPurchaseState() == Purchase.PurchaseState.PENDING then I show a dialog that says: Waiting for purchase validation. Sometimes it can last several hours

If the user tries to buy the item again and billingResult.getResponseCode() == BillingClient.BillingResponseCode.ITEM_ALREADY_OWNED then I show a dialog that says: Cannot buy the item. You already own it or a previous purchase is still pending for validation

Hope it will help

Atc answered 25/12, 2019 at 16:14 Comment(0)
H
1

I had the same issue. On launchBillingFlow you get a BillingResponseCode.ITEM_ALREADY_OWNED. the purchase returns PurchaseState.PENDING. If you consumeAsync immediately after, its response is BillingResponseCode.DEVELOPER_ERROR, but after a few minutes (or whatever delay the transaction takes to fail) you can consumeAsync again then it returns BillingResponseCode.ITEM_NOT_OWNED, now you are allowed to retry the launchBillingFlow again. like Lluis Felisart said create a dialog to ask the user to clear the pending,

Heshum answered 2/8, 2020 at 15:39 Comment(1)
It doesn't seem like a good idea to consume the purchase on a non-consumable item if the purchase is still pending. Theoretically, you can consume a purchased non-consumable item this way if the timing is just right.Tripper
B
1

It actually declines a few minutes later. I realized that if you check "Order management" on Play Console you'll see it already declined.

The issue is the local cache of google play billing. I guess that updating this cache for billing tests is very low priority, you can clear it like this:

adb shell pm clear com.android.vending
Bashaw answered 7/3, 2021 at 3:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.