mvojtkovszky / BillingHelper

Simplify the use of Google Play Billing Library (v7.0.0). Handles client connection, querying product details, owned purchases, different purchase types, acknowledging purchases, verify purchase signatures etc.
Apache License 2.0
37 stars 4 forks source link

Querying owned purchases does not set refunds as not purchased #4

Closed joseph2166 closed 9 months ago

joseph2166 commented 9 months ago

I am using the queryOwnedPurchasesOnConnected option. Everything works great.

However I am then calling initQueryOwnedPurchases() further down the line when I know a purchase has been refunded. This correctly re-fetches the owned purchases, and adds any new purchases to this.purchases.

However if a previous purchase has been refunded in the meantime this is not correctly removed from this.purchases before invoking the listener. Calls to isPurchased for the refunded product still (incorrectly) return true.

mvojtkovszky commented 9 months ago

isPurchased property directly evaluates Purchase.PurchaseState .

It might be that is it a case of Google Play caching, where it might take for up to 72 hours for it to register the refund. This can be tested by clearing Google Play cache, restarting and checking initQueryOwnedPurchases() again.

After that, this.purchases should not include a refunded purchase at all.

joseph2166 commented 9 months ago

I may be mis-reading the code, but after calls to initQueryOwnedPurchases the addOrUpdatePurchase function is eventually called with each returned purchase.

The logic in that function will add new purchases, but it won't remove old (refunded) ones.

Next time isPurchased is called on the refunded product the products variable still contains the out-of-date purchase with the incorrect Purchase.PurchaseState.

mvojtkovszky commented 9 months ago

No, you are correct.

I suppose the solution is to clear the active purchases during initQueryOwnedPurchases.

I will push an update for that.

mvojtkovszky commented 9 months ago

This issue is fixed in 2.3.0

joseph2166 commented 9 months ago

Thanks a lot - your fix worked