Inapp purchases failing to acknowledge - android

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.

Related

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?

Android Google Play Billing Library v2/v3: How to stop someone maliciously preventing an acknowledgement and therefore get their purchase refunded?

I've been implementing Google Play Billing Library v3, and noticed that starting v2 we must acknowledge a purchase after granting entitlement to the purchased feature, otherwise the user is refunded within 3 days. So essentially the lifecycle is something like:
User purchases something, e.g. subscription to a premium account.
The client app sends the purchase and signature to the backend so the user is entitled to the purchase, e.g. premium account.
The backend responds with a success, we then acknowledge with Google Play the purchase was entitled (otherwise a refund is given).
However, that got me thinking, what is stopping a malicious user from modifying the APK (or even blocking the network call) so that the acknowledgment call is not made, therefore the user is refunded within 3 days, but entitlement (step 2 above) is still given. What can I do the stop this within my app? How can I make sure the acknowledgment definitely goes through if the entitlement is given?
If no acknowledgement is made and after 3 days gets refunded, the purchased items query to the google servers will return an empty list, so you will know he is not entitled.
If a user keeps on purchasing the same item, and cancelling it due to not acknowledgement or other mechanisms, this should trigger Google alarms, and probably the user's payment method will be revoked. Google purchase system has many mechanisms in-place at server level to verify that purchases are genuine.

Should a purchase be acknowledge again subscription renewal?

I'm implementing google in-app billing on my app. Normally, when a subscription reaches expire time, it will be automatically renewed. A new purchase is made (with the purchase token remain the same)
So, should my app acknowledge this new purchase or can I safely ignore it?
after rereading the google play in app billing documentation (https://developer.android.com/google/play/billing/billing_library_releases_notes#2_0_acknowledge)
"For subscriptions, you must acknowledge any purchase that has a new purchase token. This means that all initial purchases, plan changes, and re-signups need to be acknowledged, but you do not need to acknowledge subsequent renewals. To determine if a purchase needs acknowledgment, you can check the acknowledgement field in the purchase."
so basically, if the subscription is renewed, i don't have to acknowledge it.
i share the answer here for anyone interested in the same topic.
You simply periodically call billingClient.queryPurchases() if you use the billing libray, or mService.getPurchases() if using the AIDL
If the user has renewed the subscription, it will return that the user owns the item, if he decides not to renew it, after the grace period, if any, it will return that he does not own the item.

Item already owned error on buying a previously refunded purchase

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.

Test subscription is revoked by GooglePlay

I'm working on a subscription renewal feature, in test mode, with testing payment methods. Problem is that we receive cancelation subscription webhook, GooglePlay makes subscription revoke. ​​
From params:
​"cancelReason": "1"
Status code from the docs,
Subscription was canceled by the system, for example, because of a
billing problem.
Also from the docs
Revoking a subscription instantly removes access to the subscription
and is usually done when you or Google suspects fraud.
Usually, it sends cancelation webhook immediately after renewal, even when it was successful, so there are cases when I got two e-mails, about renewal success and cancelation. In my case renewal called after 5 minutes (doc)
Have someone idea, what could be the reason? Is it some "Google anti-fraud system". Because for testing purpose we have short subscription period but the big price. But probably anti-fraud should not be executed when we do testing, with testing payment methods, when there is no real transaction.
The problem was, that we didn't acknowledge new subscriptions.
From the docs:
If you use the Google Play Billing Library version 2.0 or newer, you
must acknowledge all purchases within three days. Failure to properly
acknowledge purchases results in those purchases being refunded.
Regarding subscriptions:
For subscriptions, you must acknowledge any purchase that contains a
new purchase token. This means that all initial purchases, plan
changes, and re-signups need to be acknowledged, but you do not need
to acknowledge subsequent renewals.
Test acknowledging purchase with license testers:
For purchases made by license testers, the acknowledgment window is
shorter. Instead of three days, purchases are refunded and revoked if
they are not acknowledged within five minutes.
UPDATE
changes in documentation
You should also verify that purchases are properly acknowledged as
described in processing purchases. For purchases from license testers, a > purchase will be refunded after 3 minutes if your app does not
acknowledge the purchase and you will receive an email about the
cancellation. You can also check the Orders tab in the Google Play
Console to see if an order was refunded after 3 minutes.

Categories

Resources