问题
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!
回答1:
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
来源:https://stackoverflow.com/questions/59347726/why-android-billingclient-v2-slow-credit-card-test-never-cancels