google play in-app purchase notification for pub/sub topic - android

I'm trying to implement the backend of payment processor with google play in-app billing.
Google play billing api is tottally built for serveless scenario and is being a hell of a work to make it work for a normal world situation where apps have backends that need to validate and process payment logic.
i'm following this tutorial: https://developer.android.com/google/play/billing/getting-ready#configure-rtdn
but only after implementing the whole logic i read the small line
Real-time developer notifications (RTDN) is a mechanism to receive
notifications from Google whenever there is a change in a user's
entitlement within your app. RTDN leverages the use of Google Cloud
Pub/Sub, which allows you to receive data that is either pushed to a
URL that you set or is polled using a client library. These
notifications allow you to react immediately to subscription state
changes, avoiding the need to poll the Google Play Developer API. Note
that inefficient use of the Google Play Developer API can lead to API
quota restrictions.
so my logic integration is well done, the test message in play console works but google play billing is not sending the real notifications because my app deals with in-app products and not with subscriptions
then i read this tutorial https://developer.android.com/google/play/billing/rtdn-reference and it says
Note: A OneTimePurchaseNotification is sent only for some types of
one-time purchases. For more information, see Integrate.
but the link that was: https://developer.android.com/google/play/integrate goes to 404
does anyone know how to make google play console send notification for payment status on in-app purchases?
also how to get notifications for refunded purchases

OneTimeProductNotification was introduced in 2019-05-07 and its main purpose of handling cash purchases
https://developer.android.google.cn/google/play/billing/release-notes#release-2_0
As release notes says:
"This notification type is sent only for purchases associated with delayed forms of payment, such as cash"

+1 for your question becuase this is a weird scenario with lack of docs from google.
When I tested the notification from google play console by clicking "Send test notification" it works, but when I'm trying do so from my android app using testing client billing IT DOES NOT WORK!
but this screenshot says that
...for updates to your in-app products and subs...

In order to get refund purchases, you can try Voided Purchases API
The Google Play Voided Purchases API provides a list of orders that are associated with purchases that a user has voided. You can use information from this list to implement a revocation system that prevents the user from accessing products from those orders.
This API applies to one-time in-app orders and App Subscriptions.
A purchase can be voided in the following ways:
The user requests a refund for their order.
The user cancels their order.
An order is charged back.
Developer cancels or refunds order. Note: only revoked orders will be shown in the Voided Purchases API. If developer refunds without setting the revoke option, orders will not show up in the API.
Google cancels or refunds order.

Just copy and paste the below line of code to the permissions input box and then add this to the members.
google-play-developer-notifications#system.gserviceaccount.com
Next give permission to pub/sub publisher and you are good to go.
The mistake you would have done is you would have added a service account already present in your google cloud account which is not correct.
Above solution works perfectly fine for me!

Related

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.

Cancel Google Play subscription with Billing API?

Is there a way to cancel a subscription with the Google Play Billing API, specificaly using BillingClient, or I have to do it through the Google Play Developer API? Seems counterintuitive that you can't unsubscribe the same way you subscribed, but I can't find a way to do it. Help please.
BillingClient doesn't support cancellation (not too sure what Google's reasoning was on that one).
You would have to use Purchases.subscriptions:cancel. I'm not certain, but I believe only the app publisher can call that API; IOW, users can't call it on their own behalf. Clearly there must be an API that works off a user's Google Account credentials, but I don't know what it is.
An email sent by the Google Play Team on 13 Jun 2018 recommended that users be directed to manage their subscriptions in one of the following ways:
On Android, open the Google Play Store, then tap Menu > Subscriptions.
On a computer, go to play.google.com, then in the left menu click My subscriptions.
On either Android or a computer, use the URL http://play.google.com/store/account/subscriptions to open the user's list of subscriptions.
For active subscriptions, use the deep-link http://play.google.com/store/account/subscriptions?package=samplePackage&sku=sampleSKU with your package and SKU name to directly open the page to manage the user's specific subscription. Learn more about the manage subscription deep-link by checking out our documentation for subscription-specific features.

How to verify in-app purchase with no user system and no server-side on android?

I didn't find any definitive answer for my situation as all of this kind of questions revolve around server-side verification, which is irrelevant to me.
I'm trying to implement in-app billing in my app in order to offer the option of a premium upgrade. I've followed the guides in the developer documentation and done most of the work.
The problem is purchase verification:
The documentation suggests I shoud pass a developer payload to each purchase to uniquely identify the user - but my app doesn't have or need a user system - how can I uniquely identify a user without requiring user input or extra permissions?
Further and more important problem:
When the user makes a purchase, or opens the app after making a purchase in a different time, I need to verify this purchase - I don't have a server where I can send the purchase data to so it can verify it itself or using the Google Developer API.
It is my understanding that I shouldn't verify the purchase locally on the device (using the Google Developer API).
What is the best way for my situation to verify in-app purchases?
Is there a way to do it without a server? (I do not have the knowledge nor resources to have my own server)
I do not know how you would go about verifying a digital purchase without a network connection. Thankfully though, you do not need a user account system nor do you need the knowledge and resources to have a dedicated server because that is what Google Play services is meant for.
After setting up Google Play services; each user will be signed in through their Google Play account and be able to use their registered payment methods within your app when you implement the In-app Billing API. And you can test and manage all of this information from the Google Play Developer Console.

Use Purchase Status API to validate NON InApp Purchase

According to this topic: Can I use Purchase Status API to validate if app was bought via Play Store the Google Play Developer API provides a Purchase Token which can be fetched any time. So I imagine to send this purchase token to my backend server to ensure this user has already paid for my app, like it is written here: https://developer.android.com/google/play/developer-api.html#practices
Since the first comment on the posted anwer (see above first link) is, that there is no way to check if the playstore confirms the purchase I am confused.
I dont want to use InApp Purchases. I want my users to be able to buy an app and receive a piece of information for validating this google user has purchased it - in order to store set a flag in my own backend: "UserA: has_paid = true"
How can I achieve this?

Is it possible to get list of in-app purchases from Google Play API directly to my server?

I need to integrate google play in-app purchases with my server-side billing.
Any way to get list of in-app purchases via some Google Play API to my server without client app in between?
Tried to find anything relevant in documentation and all I found is status check API which gives you status of specific purchase, but I need to get list of purchases too.
Okay, it's possible via Callback functions in Integration tab of Settings page but only if you have classic Google Checkout account.
If you just registered as Android Developer — you have a different type of account and those options are unavailable for you.
No way to sign up for classic account as Google Checkout is being substituted by Google Wallet and no way to change account time once you are registered.
sarcasm on:Thank you, Google!:sarcasm off

Categories

Resources