GooglePlayReceipt not returning correct value: google.purchaseState

There has been a problem occurring on my app. Before launching, I’ve tested countless times to make sure that after refunding a non-consumable product, the reinstalled app does not retrieve the product.

This is the line of code I’ve added which came from the script I modified from the manual sample.

if (validPurchase && p.receipt != null && p.hasReceipt && p.transactionID != null)
{ 
//Retrieve products
}

However, recently I discovered that it has changed. Even refunded products are retrieved after reinstallation. I’m assuming it is because Unity IAP could not detect the google receipt properly? The status is refunded on my dev console but when I debugged for google.purchaseState, it returned Purchased instead of Refunded.

google.purchaseState returns an enum of Purchase, Cancelled and Refunded.

Did you check the Revoke checkbox when refunding?

If the developer chooses a refund with revoke, the purchased receipt will be cleared and the user will not continue to own the item, but the user can purchase the non-consumable product again.

If the developer chooses a refund without revoke, the purchased receipt will not be cleared and the receipt will be sent when the user first initializes the IAP and is verified as a valid receipt. This means that even if a refund is made, the user will still own the item and the user cannot purchase the non-consumable product again.

Thanks for the response.Yes, revoke has been checked. I received the same results from my own test devices. They did not behave in such way previously.

EDIT: I’m using IAP version 1.20.0

Please test with 1.23.1

I’ve updated, but the results are still the same.

This is the message I can see in the logcat if it helps. It happens during initialization.

I/UnityIAP: Starting in-app billing setup.
I/UnityIAP: Billing service connected.
I/UnityIAP: invoking callback
I/UnityIAP: Checking for in-app billing 3 support.
I/UnityIAP: In-app billing version 3 supported for com.AppName
I/UnityIAP: Subscriptions AVAILABLE.
I/UnityIAP: Subscription upgrade and downgrade are AVAILABLE.
I/UnityIAP: Subscriptions information parse AVAILABLE.
I/UnityIAP: VR supported.
I/UnityIAP: onIabSetupFinished: 0
I/UnityIAP: Requesting 8 products
I/UnityIAP: QueryInventory: 8
I/UnityIAP: invoking callback
I/UnityIAP: Querying owned items, item type: inapp
I/UnityIAP: Package name: com.AppName
I/UnityIAP: Calling getPurchases with continuation token: null
I/UnityIAP: Owned items response: 0
I/UnityIAP: Sku is owned: product01
I/UnityIAP: Sku is owned: product02
I/UnityIAP: Sku is owned: product03
I/UnityIAP: Continuation token: null
I/UnityIAP: Querying SKU details.
I/UnityIAP: Querying owned items, item type: subs
I/UnityIAP: Package name: com.AppName
I/UnityIAP: Calling getPurchases with continuation token: null
I/UnityIAP: Owned items response: 0
I/UnityIAP: Continuation token: null
I/UnityIAP: Querying SKU details.
I/UnityIAP: Querying owned items' purchase history, item type: subs
I/UnityIAP: Package name: com.AppName
I/UnityIAP: Calling getPurchaseHistory with continuation token: null
I/UnityIAP: Purchase history response: 0
I/UnityIAP: Continuation token: null
I/UnityIAP: Querying owned items' purchase history, item type: inapp
I/UnityIAP: Calling getPurchaseHistory with continuation token: null
I/UnityIAP: Purchase history response: 0
I/UnityIAP: Continuation token: null
I/UnityIAP: onQueryInventoryFinished: true
I/UnityIAP: Inventory refresh successful. (response: 0:OK)
I/UnityIAP: invoking callback

product01, product02, product03 were all refunded, yet it appeared to be owned.

We are just showing the product state and receipts that are passed to us from the Google Billing API. We are planning to use the next version of their API in an upcoming IAP release, and we will include this scenario in our tests. Are these test purchases, or actual credit card purchases? I’ve also heard reports that it can take some time (24 hours) for Google to process the refunds. And if your app suddenly started behaving differently (you mentioned recently), that might imply a change on the Google end if you made no code changes. We are only a pass through service and do not handle any of the transaction processing.

These are all test purchases and the app is released.

Regarding the delay in refund process, I read that too in one of the thread here, the person claims that product.hasReceipt will return false only after 24 hours or so. However, this isn’t my current situation.

When I tested my app before publishing, I refunded several times and it was not an issue back then. product.hasReceipt returned false. Currently, what I can see, is that all the non-consumable products that were refunded are now detected as purchased and product.hasReceipt returns true.

I understand that it is quite likely to be a change on Google’s end but I was hoping there is a solution to this problem since google.purchaseState should by right get the correct value.

@sawyerbb Understood, we will test here also and see if we are seeing the same thing.

I would like to update that only old purchases on the test devices which were refunded has the said issue, when new purchases were made are refunded, hasReceipt returned false as expected. I am unsure if this is a result after updating to 1.23.1, hope this info helps your team.

Thanks for the information. I can reproduce the same situation in version 1.23.1, and we will continue to investigate.