Item already owned error on buying a previously refunded purchase - android

I am testing the refund workflow for my in-app purchases. I am verifying the purchase receipt using the Google Play Developer API https://developers.google.com/android-publisher/api-ref/purchases/products/get. If a user has asked for a refund of the purchase, this API returns the purchaseState as 1 which is correct. At that point, I remove the purchase from my app and the user can no longer avail the benefits of the in-app purchase. But now if a user wants to buy the in-app purchase again, I get the Item already owned error while buying it.
I am not sure how to allow the user to buy the in-app purchase again. I can consume the item once the purchase is reported as canceled in which case I don't get the Item already owned error but I don't think that would be the correct thing to do though.
Please let me know how to handle this use-case.

Related

Inapp purchases failing to acknowledge

I'm having some trouble dealing with the new inapp billing library (version 4)
Ever since I updated the billing library in my app some user purchases are failing to be acknowledged, therefore they get refunded within 3 days, while other work just fine.
My theory is that because of the app only sending an acknowledge request once when a SKU is bought, said request might sometimes fail and the thing remains unacknowledged. That'd explain why some purchases are working and other aren't, getting refunded in the process.
I thought of writing a condition that always sends an acknowledge request whenever a SKU is purchased but isn't acknowledged as a possible solution. This would always send an ackowledge request as long as it's purchased and not acknowledged, therefore if the acknowledge request fails it'd just send it again until it's approved.
I was wondering if successfully processed inapp purchases failing to acknowledge is common?
Check it https://developer.android.com/google/play/billing/integrate#process play billing document, you use to subscription package to acknowledge
Once a user completes a purchase, your app then needs to process that purchase. In most cases, your app is notified of purchases through your PurchasesUpdatedListener. but there are cases where your app is made aware of calling BillingClient.queryPurchasesAsync() as described in Fetching purchases.
Your app should process a purchase in the following way:
Verify the purchase.
Give content to the user, and acknowledge delivery of the content. Optionally, mark the item as consumed so the user can rebuy the item.
To verify a purchase, first, check that the purchase state is PURCHASED. If the purchase is PENDING, then you should process the purchase as described in Handling pending transactions. For purchases received from onPurchasesUpdated() or queryPurchasesAsync(), you should further verify the purchase to ensure legitimacy before your app grants entitlement. To learn how to verify a purchase properly, see Verify purchases before granting entitlements.
Once you've verified the purchase, your app is ready to grant entitlement to the user. After granting entitlement, your app must then acknowledge the purchase. This acknowledgment communicates to Google Play that you have granted entitlement for the purchase.

How to verify the acknowledgement logic in google play in app purchase?

Per doc
Once you've verified the purchase, your app is ready to grant entitlement to the user. After granting entitlement, your app must then acknowledge the purchase. This acknowledgement communicates to Google Play that you have granted entitlement for the purchase.
Note: If you do not acknowledge a purchase within three days, the user automatically receives a refund, and Google Play revokes the purchase.
We know after Google Play Billing Library 3.0, we must acknowledge the purchase within 3 days. Otherwise, the purchase will be automatically refunded by google play.
The acknowledge logic is done on our server-side, we want to double-check the acknowledge logic through fetching the refunded purchase due to the acknowledgment issue. For example, our server does acknowledge one purchase successfully. Does the refund of this purchase still happen? One solution is to retrieve the refunded purchase data from google play and check whether the acknowledgment is done on our server-side.
However, per google play support guys, we could Not fetch those refunded purchases due to the acknowledgement issues through Voided Purchase.
Is there any way to verify the acknowledgement logic in google play in-app purchase? Or anything am I missing?

How to Restore inApp purchase in Android?

How do I restore inApp purchase if the user has already bought the app?
The problem is that if a user first purchases then uninstalls the app then re-installs the app, the user must have to buy that product again.
InApp purchases made for Managed products is always managed by google.
Once a user buys it, it remains in his purchase list unless it is consumed by making InApp SDK API consume call.
So make the inapp products as Managed product and restore the purchases by making getPurchases() call. Even if the payment dialog is invoked it will show "User already own this item".

In App Billing, further testing

I got my current app in test with some items to testpurchase. And I´ve done that now but I need to do further testing on those items. Is there a way to simply "restore" those purchases so that I dont get that error "You already own this item" ?
There is a way:
Once an in-app product is purchased, it is considered to be "owned".
In-app products in the "owned" state cannot be purchased from Google
Play. You must send a consumption request for the "owned" in-app
product before Google Play makes it available for purchase again.
Consuming the in-app product reverts it to the "unowned" state, and
discards the previous purchase data.

Refund to In App Purchase on Android

I have an in app purchase that unlocks part of the app for a year. Its setup as Annual Subscription.
Temporarily running a promotion unlocking premium as one-time purchase.
One of the users emailed me and wanted to take advantage of the promotion. So I'm thinking Cancel / Refund his Subscription, and ask him to purchase again as one-time purchase.
My question is what happens after I cancel / refund his subscription order, does IAB still consider it a valid purchase or not ?
What happens when you queryInventory, is it no longer returned as his purchase or is it stilled returned and I have to handle the status somewhere in code?
You have to do it in your Google Wallet Merchant. Read this Google Documentation:
Once an order is refunded - on a non-rooted device - the order will be invalid if queried. IAB considers it as a purchaseState==2 (2 is refunded according to Table 4 in here). Note that the developer will be in charge to handle refunded items. Read this question.

Categories

Resources