How to detect refund with google billingclient library - android

I was wondering how to detect a refund, or any type of cancelation of an in-app purchase(not a subscription and not a consumable).
I'm currently making my test and when I refund a test in google like that :
The purchase is still present in billingClient.queryPurchaseHistoryAsync() (even in queryPurchase()).
How can I detect such changes and how can I disable my app for refunded users?
Thanks in advance.

I do understand your concern regarding refunded items.
If you offer in-app products, you can use the Voided Purchases API to request a list of voided purchases for your in-app products. When a user requests a refund for in-app purchases, you can see what was purchased and take back the refunded digital goods from that user.
To protect you app from refund abuse please use the Protect your apps from refund abuse help guide, for the best practises in protecting your app’s in-app products.

Have to tried this function
PurchasesUpdatedListener
Listener interface for purchase updates which happen when, for example, the user buys something within the app or by initiating a purchase from Google Play Store.
void onPurchasesUpdated (int responseCode,
List<Purchase> purchases)
Implement this method to get notifications for purchases updates. Both purchases initiated by your app and the ones initiated by Play Store will be reported here.
OnPurchasesUpdated on developer.android

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?

Need clarity on implementing a subscription app

I've developed an Android app and need clarity on what is required to offer it, via Google Play Store, as a subscription app (i.e. offer use of the app for a monthly fee). For now, no in-app purchases or in-app subscriptions are planned; the only subscription is for use of the app itself. All of the documentation I've read about subscriptions from the Google Play Store seems only to discuss in-app subscriptions.
My questions:
1) Is an overall app subscription treated/processed the same as an in-app subscription (i.e. via the app)?
2) If not, what portions of the Google documentation/guides on subscriptions do I implement? Everything that isn't expressly mentioned as being for in-app subscriptions/purchases?
3) Do I need a back-end server to manage/track app subscription info, or can subscriptions at the app level be managed via Google Play Console?
4) Is there a guide/example/tutorial somewhere that clearly explains how to implement what seems like a basic solution, a subscription app with no in-app purchases?
Examples of what I found during research:
Create a subscription - Play Console Help indicates:
Create a subscription
Using Google Play Billing, you can offer in-app products that charge users for content or services on a recurring basis, known as subscriptions. Subscriptions can include items like a collection of apps, games, or other content for a recurring fee within your app on Google Play.
In Google Play Console, subscriptions are only mentioned (from what I can see) under Store presence->In App Products->Subscriptions
I reviewed other questions on SO related to subscriptions, but virtually all appear to be focused on in-app subscriptions. One exception was Implementing a Yearly Subscription. Per the answer from GNUzilla, I understand the need to create a payment profile in Play Console. The second part of GNUzilla's answer references the now deprecated AIDL interface, so I instead reviewed the guide page for its replacement, Use the Google Play Billing Library | Android Developers. However, this also appears focused on in-app subscriptions. For example,
Enable the purchase of an in-app product
...
To start a purchase request from your app, call the launchBillingFlow() method from the UI thread. Pass a reference to a BillingFlowParams object containing the relevant data to complete the purchase, such as the product ID (skuId) of the item and product type (SkuType.INAPP for a one-time product or SkuType.SUBS for a subscription).
Is an overall app subscription treated/processed the same as an in-app subscription (i.e. via the app)?
There is no such app subscription feature Google has implemented. It always will be in-app subscriptions. User will download the app free/paid and login/signup into the app then the developer will show the subscriptions plan based upon the business case.
If not, what portions of the Google documentation/guides on subscriptions do I implement? Everything that isn't expressly mentioned as being for in-app subscriptions/purchases?
In-App subscriptions. Check here https://developer.android.com/google/play/billing/billing_subscriptions
Do I need a back-end server to manage/track app subscription info, or can subscriptions at the app level be managed via Google Play Console?
Yes, you need the backend for managing the real-time notifications. If you don't want to have the backend then you will miss lots of scenarios like your app don't what is the current subscription status. It is also good from a security point of view to verify the purchase in the backend.
Is there a guide/example/tutorial somewhere that clearly explains how to implement what seems like a basic solution, a subscription app with no in-app purchases?
You can check google documentation here. In the future, I will also publish the blog regarding this.

Detect In-app Products after it was consumed

Using In-app Products, we can detect if user own a product by it's sku, if he is connected with same Google account as payment was made. But if we consume this in-app product, so it's not owned anymore, how can we know this user paid for this in-app product? As per their docs there is no way.
Only implementing own backend logic but the problem is that we have to implement auth to remember user's state (how many sku does he consume).
Yeah, when they are consumed, they are gone.
In this case you want to use non-consumable products for in app purchases. These remain to be coupled with the Google Account. With this, whenever we are retrieving the list of bought products of a user, the library will return the product if it was previously bought on that Google Account. Basically it is never consumed and remains coupled to the account.
By using these non-consumable products, we can easily 'restore' purchases for users when they have a new device for example. But non-consumable products are a one-time buy and are more used for 'unlocking' some content or features. As result, it cannot be used to see 'how many' times it was bought, as it's just a one-time buy.

How to verify user purchased premium version using in app product in android?

I have developed an app in which I want to give a premium version of an app with ad removal and some extra features in-app products.
So, my question is how to verify if a user had purchased already; Then, when a user opens the app, I know if I should give them a premium interface.
Here's the documentation overview for In App Billing, where it says:
Google Play tracks and manages the ownership information of managed products. When a user purchases a managed product, Google Play stores the purchase information for each product on a per-user basis. This enables you to later query Google Play at any time to restore the state of the products a specific user has purchased. This information is persistent on the Google Play servers even if the user uninstalls the application or if they change devices.
To provide premium content, you'll need to create a managed product that doesn't get consumed in the app when the user purchases it. In order to query the user's in-app purchases, send a getPurchases() request, that will return all the current un-consumed products owned by the user.
If you find the premium content in this response, you know the user has purchased it and can grant them the premium interface.
Google Play Billing AIDL is now deprecated and will be removed in a future release. To implement Google Play Billing features, use the Google Play Billing library and to get purchases details for all the items bought within your app use: queryPurchases(skuType).

How to verify purchase of a Play Store app (vs. verifying in-app purchases)

The documentation at https://developer.android.com/google/play/billing/gp-purchase-status-api.html describes how to verify in-app purchases and subscriptions. But it's unclear how to verify the purchase of the app itself.
Is there a programmatic way to accomplish this? Preferably in a way that ties back to the device ID on which the app was purchased?

Categories

Resources