Cancel and refund ALL google play subscriptions - google-play

We have an app in the Google Play Store that we will no longer support in the future.
Users were able to buy subscriptions for the app's content.
We want to cancel all running subscriptions and refund the users.
The Google Play Developer Api offers the revoke method that expects the details (subscription id, token) for a single subscription and will cancel & refund that subscription.
We would have to do that for a couple of thousands of users (probably via a script).
Is there a better way to revoke all subscriptions?
Has someone probably faced a similar scenario?

I did not find a method of revoking all subscriptions at once so I wrote a little program that reads subscription data from a file and revokes them, one after another.
You can check it out here: https://github.com/asco33/reimburser

Related

Cancel All Subscriptions in Google Play

We currently try to cancel all subscriptions of an app in Google Play. We already contacted the Google Play support, but they told us that there are only two ways to do this:
Manually for every subscriptions in the UI
Using the Google Play API
For the API we need the purchase token of each subscription. I couldn't find a way to get all purchase tokens. The only way I found to get a purchase token is by manually requesting it through the UI.
We need to cancel a lot of subscriptions, so manually clicking around in the UI is no option for us. Is there a way to get all purchase tokens? Or is there a different way to cancel all subscriptions?
If anyone has the same problem, as of right now, it seems it's not possible to cancel all subscriptions using the Google Play API.
We have built a webhook for real-time developer notifications. So for every subscription renewal that is triggered, we immediately revoke the subscription and refund the payment. This seems to work, but is far from great.

How to process RTDN from Google Play?

My server receives a real-time developer notifications (RTDN) from Google Play. Now what?
How to check whether RTDN by Google Play comes from Google, not from a hacker? Suppose I use purchases.products.get API to check it. Then a hacker could send me repeated RTDN, what would lead my server into thinking that purchase happened two times (when it was really one time).
I want my server to top the user account on every purchase from my app. I want the amount of purchase to be arbitrary (specified by the user). Should I include the amount in dollars into product productId/SKU like: credit-$0.78?
Also, it is unclear how to determine the installation ID of the app (a UUID I store in app data on installation) for which the purchase was done. Should I include the UUID in productId/SKU?
Quoting https://developer.android.com/google/play/billing/security
A special case of sensitive data and logic that should be handled in the backend is purchase verification. After a user has made a purchase, you should do the following:
Send the corresponding purchaseToken to your backend. This means that you should maintain a record of all purchaseToken values for all purchases.
Verify that the purchaseToken value for the current purchase does not match any previous purchaseToken values. purchaseToken is globally unique, so you can safely use this value as a primary key in your database.
Use the Purchases.products:get or Purchases.subscriptionsv2:get endpoints in the Google Play Developer API to verify with Google that the purchase is legitimate.
If the purchase is legitimate and has not been used in the past, you can then safely grant entitlement to the in-app item or subscription.
[skipping about verification of subscriptions]
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 is encoded and secure, each publish made to a Cloud Pub/Sub topic contains a single base64-encoded data field.
Note: You must call the Google Play Developer API after receiving Real-time developer notifications to get the complete status and update your own backend state. These notifications tell you only that the purchase state changed. They do not give you complete information about the purchase.
The Google Play Developer API is a server-to-server API that complements the Google Play Billing Library on Android. This API provides functionality not available in the Google Play Billing Library, such as securely verifying purchases and issuing refunds to your users.

Handling free period within active Apple / Google Play subscription?

Our product owner wants to grant users a month's free subscription in exchange for inviting another user. We handle subscriptions using App Store / Google Play. Is there any way to give a user a discount for one whole month within an active subscription? Another idea is just to postpone the next payment by one month. I can't find suitable solutions to our case in Google / Apple documentation.
Any help / suggestions much appreciated!
With Google, you can use the defer API to postpone the next payment
With Apple, you can provide an offer code to offer a free period to your user

Play & App Store Webhooks / Server Side Code on subscription start and cancel

I need to add server side logic when a user buys and cancels a subscription. To me this seems like a basic feature that many apps probably use. However as it turns out it's not that simple to setup up the need webhooks.
My App will be available on android and iOS, so I will need to configure both, which is why I thought about using RevenueCat. But it turns out, this is a paid feature for $110/month, which is way too much for a/my new app. This is probably the biggest time saver for RevenueCat compared to using the official InApp Purchases packages, so I don't see why they would make it a paid feature.
Anyways what the best way to handle webhooks with the Play Store and the App Store? Any Guides and Tipps would be very helpful!
Apple and Google both offer server-to-server notifications that will notify you when a subscriber cancels.
Apple guide: Enabling Server-to-Server Notifications
Google guide: Real-time developer notifications
If you have your own user Ids, they won't be present in these server notifications so on your server you can save the user Id along with the transaction identifier of their original purchase. That way when a notification comes in you can look up the user from the transaction identifier and flag them as cancelled.
Alternatively, the RevenueCat API is included on their free plan so you can periodically poll their GET /subscribers endpoint to get the latest subscription status for a user. This obviously won't be real-time, but may be enough for your use-case.
Update: I decided to solve this issue similar as #enc_life suggested with the RevenueCat API. For validation the purchase, I send a request to my server, that checks with if the user actually bought the subscription. For canceling the subscription, I execute a function everyday on my server, that checks for all subscribers if the subscription is still valid.

how can I get list of the users data in google play subscriptions

Our app has already implemented in-app purchase.
But, we previously don't keep track of it, and only relies on the google's service whether a user's level is premium or regular.
Now, we want to track it in our server as well.
Is it possible to get the users data who've bought our subscriptions? (especially his/her email)
Based from the following documentations, there is no currently existing method to get a list of your app's subscriber's.
Google Play Developer - API Reference
In-app Subscriptions
Currently existing features with Google Play Developer API is that, it offers an HTTP-based API that lets you perform such tasks as:
Remotely query the validity of a specific subscription at any time
Cancel a subscription
Defer a subscription's next billing date
Refund a subscription payment without canceling the subscription
Refund and revoke a subscription
The API is designed to be used from your backend servers as a way of securely managing subscriptions, as well as extending and integrating subscriptions with other services.
For complete information, you may go through Google Play Developer API.

Resources