Can any one provide complete documentation for auto renew subscription and update status on backend using android developer notification with pub/sub?
We have to do Monthly & Yearly auto renew in app purchase subscription. If we subscribe using app,then we are getting purchase token and updating on backend.I have some query for auto renew subscription.
Please check the same as below:
1.Do we need to check subscription status at the time subscription period over using cron job? If yes,do we need to pass same purchasetoken in Purchases.subscriptions: get api?
2.If we enable developer notification for real time update on server,then we are getting notification on server. It doesn't contain any purchase information or unique user id.
Please check the below documentation :
https://developer.android.com/google/play/billing/realtime_developer_notifications
Real-time developer notifications do not provide full information about the state of the subscription, such as whether the user is currently entitled to access subscription content. When you receive the token, you should always use the purchase token to query the Google Play Developer API to get the full information and update your backend with the user's current entitlement status.
-> Will we get purchase token from realtime developer notifications?
I implemented with the help of the official implementation. I hope this helps.
Related
I'm (re) building an app for iOS and Android that has an existing subscription model (monthly and annual) through IAP.
There's already an existing app which has users subscribed, for the rebuild i'm reusing the current product/subscription IDs in Google Play Console/App Store Connect.
I'm using Cognito for login and when a (new) user subscribes I have a webhook setup that listens for events from the respective store and stores the subscription status as a claim against the user. This also works for when a user cancels/modifies their subscription, i'll get an event to the webhook and update the backend accordingly.
My problem however, is this
I need to migrate any existing users with existing subscriptions across to my new app, to for this to be a success I need:
A list of users that have an active subscription using the existing subscription/product IDs
Once I have this I can create users in Cognito and ensure their subscription status is correct, is there an endpoint/approach for each platform that allows me to get a list of users with an active subscription? Alternatively is there any event I can hook into from the subscriptions/purchases webhook that would allow me to do this?
The key is I need to make sure that any existing users that login have their subscription on the new app and for this to happen I need to know their current subscription status so I can store it against them in Cognito.
Any help is greatly appreicated
I am currently working on an application that incorporates google in-app subscriptions. It seems like google would handle most of billing and transactions, but the questions are:
1. if user's credit card is expired while the app is trying to renew a subscription, do I need to handle this case on the device or my backend server?
2. if no, would google sent notification to the user?
3. if yes, how do I check the state of user's credit card????(hopefully i don't need to)
As per the documentation:
If a recurring payment fails (for example, because the customer’s credit card has become invalid), the subscription does not renew. The
getPurchases() method does not return failed or expired subscriptions.
Recommendation: Include business logic in your app to notify your
backend servers of subscription purchases, tokens, and any billing
errors that may occur. Your backend servers can use the server-side
API to query and update your records and follow up with customers
directly, if needed.
1.Looks like it should be your server's responsibility to check with Google on daily basis or so and disable the content if subscription is not active. If payment fails due to what ever reason, Google doesn't renew the subscription automatically again, so it's as good as saying that subscription is canceled.
2.Google does notify to user.
In my android application user membership plan is upgraded using inapp subscription on monthly basis. There are 2 membership status corresponding to each user 'free' & 'premium'. If user subscribes on monthly basis, the membership status will become premium. But after 1 month the membership status goes to free.
How can we get auto subscription status from play store so that I could pass this status to the backend to upgrade the user membership status to premium.
Is there any callbacks from google play store to app or direct to the backend server to get the subscription status?
Is there any callbacks from google play store to app or direct to the backend server to get the subscription status?
No, you have to query the purchaseToken yourself using the Google Play Developer API from within your own web-server.
Upon receiving the purchaseToken on your server you should make a request to the Google Play Developer API to retrieve the expiryTimeMillis.
You should then queue a task to run again at the given expiryTimeMillis to retrieve the latest expiry date and so on until the expiryTimeMillis appears in the past indicating that the subscription has not been renewed.
If you're specifically looking for a service with webhook integration that you don't need to build yourself, I suggest checking out https://mbaasy.com. It's in beta at the moment but if you register I can get you in the beta program soon. Disclaimer: I'm the founder of mbaasy.
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?
the google api documentation states that you should call the method
getPurchases()
to know currently active subscriptions, but is there a way to get from Google the expired subscriptions too? Or should I store the subscription informations on a custom server?
I'm doing a magazine app and, even if the subscription is expired, I should be able to allow the user to re-download the issues published while the subscription was active…
Yes of course there is the way for the android application and your back end server to check your subscription details and it's expiration date and even if have access to cancel subscription manually from your server. Using "purchase-status-api", you can check it's expiration date and auto-recurring bill flag.
AFTER LOT OF SEARCH I GOT FOLLOWING LINKS,
PURCHASE-STATUS-API
AUTHENTICATION DEVELOPER DOC
GET EXPIRATION DATE FOR SUBSCRIPTION PRODUCT
REFERENCE LINKS:
MORE LINKS TO IMPLEMENT GOOGLE API
HELP TO IMPLEMENT FOR SERVER OR CLIENT SIDE GOOGLE API
Hope it will solved your problem.