2

I had a refunded non-consumable acknowledged purchase, using Google play billing 2.1.0

Purchase.PurchasesResult purchasesResult = billingClient.queryPurchases(BillingClient.SkuType.INAPP);

for(purchase in purchasesResult)

purchase.getPurchaseState() return 1

but purchase.toString() purchaseState return 0

I use Purchase.PurchaseState.PURCHASED to check for state but it return 1

Don't know what is the number for the real PURCHASED state or the refunded state

yayaya
  • 65
  • 4
  • Maybe it will help you. See this link: [Detect refunded managed in-app purchase android](https://stackoverflow.com/questions/57802500/detect-refunded-managed-in-app-purchase-android-iap-2-0-3/62733257#62733257) – kitfist0 Jul 04 '20 at 19:09
  • Ha, I'm literally running into that right now. If you look at the code it seems extremely broken...not sure how on earth this is supposed to qualify for spec. "case 4: return 2; default: return 1; }" My case is a simple account hold scenario: purchase is still returned, but getPurchaseState() is returning 1 which is OK, even though I would expect 0 (unknown) or 2 (pending) when there is an issue with payment. – TahoeWolverine Oct 28 '20 at 21:57

1 Answers1

0

I had the same issue

What worked for me? or a work around can be. handling the JSON response manually-

Purchase purchase = purchases.get(0);   //"purchases" is the list of purchases returned

boolean isPurchased = false;
try {
JSONObject jsonObject = new JSONObject(purchase.getOriginalJson());
int purchaseState = (int) jsonObject.get("purchaseState");
                            
isPurchased = purchaseState == Purchase.PurchaseState.PURCHASED;
                                        
log.d(TAG, "DEBUGLOGS isExistingSubscriber() jsonObject.get(purchseState)- " + jsonObject.get("purchaseState"));
} catch (JSONException e) {
   throw new RuntimeException(e);
}

Hope it helps!