Android Subscriptions charge user flow - android

After read all documentation and examples, I still have open questions regarding user charge process:
Do Google Play Market send any callback to client after every successful charge with appropriate order id and other billing details?
Is it possible to configure subscription with only one trial period?
(If user will cancel subscription and then subscribe again for the
same sku, we don't want to give him trial again)
Thanks in advance

Related

How to handle subscription repurchase scenario in android in-app purchase?

I am maintaining and updating the subscription state through the real time developer notification.
When an user purchased a subscription in app, my server is called to link the purchase with the user.
Whenever user repurchases a subscription after expiry, I get a notification from Google pub-sub in my server as a "SUBSCRIPTION_PURCHASED" notification. I just don't know to which user I have to link this purchase? Since the repurchase is happening from the play store and it has no link with the app, I am unable to register the subscription to the user. Kindly please help me.
Just to clarify the different cases, even if I know that's not what you're asking for here :
whenever a subscription expires on the Play Store because of a payment issue, it enters in a grace period (if you havent deactivated this feature). If the payment method is not fixed, the subscription enters into an "account hold" period (30 days) where any payment method resolution or re-subscription will bring back the subscription. In this case, you'll receive a SUBSCRIPTION_RECOVERED S2S notification with the purchaseToken known by your server and everything should work just fine (more on this here: https://developer.android.com/google/play/billing/subscriptions#account-hold)
in your case, the user has re-purchased the subscription in another context than an "account hold", that's why you'll have an unknown purchaseToken and you won't be able to associate the subscription with any user. I'm afraid in this case, you can't do much.
The only solution for your user is to "restore" his subscription within your app. In another words, you should add a link in your Paywall which, when clicked, will retrieve the subscription from the Play Store and send them back to your server (like for a normal purchase). Your server will detect the new subscription and will linked the subscription to the correct user.
Here is an example of a Paywall with this restore link:
You could thought that it would be a good idea to always look in the Play Store for subscriptions when your app launch... and whenever your detect a subscription that isn't attached to your user, send the receipt to your server to attach the subscription to your user. It would be an error though since a same device can be used by 2 persons and one user would "steal" the subscription from the other.

Is Google Play Developer API provide any user identity data when click reSubscribe button in Play Store?

I try to develop subscription function in my app recently and the project also got a back-end server.
Now I faced a question when first subscription already ended and then try to click the reSubscribe button in Google Play Store.
After searching many documents, I know there's got a parameter 'linkedPurchaseToken' that google says it would send to our back-end server through Real-time developer notifications.
(https://medium.com/androiddevelopers/implementing-linkedpurchasetoken-correctly-to-prevent-duplicate-subscriptions-82dfbf7167da#eb81)
But the parameter only show up when old subscription not really finished(canceled but still in subscribe periods, upgrade, downgrade...etc).
How can I recognize brand new reSubscribe purchase without linkedPurchaseToken?
Is there any user identity data that I missed??
Or there has another method that App side can handle the resubscribe?
But I also call queryPurchase method to recongize the reSubscribe purchase, and I didn't see any parameters that tell me the purchase type.
queryPurchase data
Purchase. Json: {
"orderId":"GPA.3344-XXXX-XXXX-XXXXX
packageName":"net",
"productId":"net.XXXXX.XXX.XXX.cs.XXX100",
"purchaseTime":1611111184135,
"purchaseState":0,
"purchaseToken":"token...",
"autoRenewing":true,
"acknowledged":true}
Thanks for any help and advise.

Cancel in app auto renewal subscription android

I am using google in-app billing v-3 to implement auto renewal subscription process of google in my android application.
In my application user can go for different types of subscriptions, like Subs-1 for 30MB of space, Subs-2 for 90MB and so on. Now if, user chooses initially Subs-1 and then upgrades it to Subs-2, as a result now there are two simultaneous subscriptions on user's account.
I want to cancel first subscription, when second is purchased. Is there any method for the same in android code, or do I have to go for server-side implementation of the same here.
Google docs are really confusing, and I didn't find any solution there.
Yes you could use the cancel method, detailed here https://developers.google.com/android-publisher/api-ref/purchases/subscriptions/cancel#request
All you would need is the subscription_id and token which you got when user purchased the subscription

InApp Subscriptions or Google Wallet

I have gone through most of the links here on stackoverflow and i have some doubts regarding InApp Subscriptions and Google Wallet.
What i know:
InApp Subscriptions basically allows a user to be able to subscribe to an app, say for example if it offers one year trial period, then once thats over, Google automatically handles the subscriptions then after.
Google Wallet, its a method that can be used to perform the purchase. What i don't understand is, can i use this method in order to allow users to use the app for one year, and then make them pay for the next years?
Billing continues indefinitely at the interval and price specified for the subscription. At each subscription renewal, Google Play charges the user account automatically, then notifies the user of the charges afterward by email. For monthly and annual subscriptions, billing cycles will always match subscription cycles, based on the purchase date. (Seasonal subscriptions are charged annually, on the first day of the season.)
This is what happens in my app:
1. A user logs in, and i get a date that probably keeps track of the billing cycle
2. If the sessions expired, the user is asked to pay using the inApp Billing serivce
3. Based on TrivailDriveApp Example, where we have the success log printed on subscription, we update the date of payment.
Some questions i have:
As per the quote from android, if the user is automatically subscribed to the service, and if a mail is sent to the user, does that mean that i would never be able to get a notification about the payment extension? How do i sync that with the server then?
Is my approach wrong in handling this kind of scenario? Or do i have to select a different method of handling app extensions?
P.S: There is no way of testing inapp subscriptions also. I wonder if i could do that without using real credit/debit card credentials.
EDIT:
I would also want to keep track of when the purchase or billing was done, if subscriptions are auto-renewed, then should i take up the purchase flow as an InApp Product instead of an InApp Subscription?
Please help.

Playstore subscriptions - testing strategy

Scenario:
I am on the verge of completing my google playstore in-app billing implementation. I am using a monthly or yearly subscription in order to charge my consumers.
Problem: I can't seem to find a way to remove a subscription from active state, since cancellation simply stops the billing from occurring. This doesn't allow QA to thoroughly test the purchase procedure without creating an account for each test, or waiting until the subscription period ends.
Question: Have I missed or am wrong about something? If so, what is it? If not, what should be done to allow QA to do proper testing?
According to what I have understood from your question,
you can not test subscription from the test account. Google play doesn't provide subscription testing using dummy product. you have to test on the real product.
Now question arises how can I test subscription
you can check subscription by purchasing real product and check product status or purchase cancellation using the purchase status api from your server.
you can also get more information from the given link below for the step by step cancellation purchase status:
1) link1
2) link2
you can simply query every day and check your subscription is valid or not and also get it's expiration date.
I also have one other option with out pay for any charges on your real product, you can set trial period in the Google console and before trial period ends up cancel subscription from the Google play store Menu -> MyApp -> Subsciption and cancel product and check above procedure given in the links.
EDIT:
Important: In all cases, you must continue to offer the content that
your subscribers have purchased through their subscriptions, for as
long any users are able to access it. That is, you must not remove any
subscriber’s content while any user still has an active subscription
to it, even if that subscription will terminate at the end of the
current billing cycle. Removing content that a subscriber is entitled
to access will result in penalties. Please see the policies document
for more information.
more information check below links:
1)
http://developer.android.com/google/play/billing/billing_subscriptions.html#cancellation
2) https://support.google.com/googleplay/answer/2476088?hl=en
3)
https://support.google.com/googleplay/android-developer/answer/140504?hl=en
You can not done this with out waiting until the subscription process cycle completes after cancellation of subs product, the only way remaining which is Free trial version it's only the way to provide us to test for the product cancellation in which product cancel immediately after you cancel subscription trial period, it will not continue until even trial periods ends.
more information check below link:
http://developer.android.com/google/play/billing/billing_subscriptions.html#administering
And I think it is better way because in the trial period you should go
with the actual credit card payment process but you doesn't need to
pay anything for it. Google play record the transaction as $0.00 for
the subscription process. And if you cancel the subscription the you
should not pay anything for testing, but yes I am not sure free trial version
is worked before you publish the app but it is only get by efforts only.
Conclusion:
In the current api it is not possible to test subcription product like
normal products and if user has been cancel the subscription product
then you have to wait to purchase the same product until the
subscription cycle has been expired, there is no another way if the
subscription cycle is going on and you can test for the same product
again before subscription cycle ends. And if you still want to test
for the same product then you have to choose another account for
testing it or another way is Free trials, you will not be any charged
until your Free trials period expired or cancel subscription in that
period and for the testing account before publish the app you will be refunded
automatically after 14 days of purchased product according to my
knowledge.
Hope it will solve your problem.
I have a horribly clunky workaround for this problem. Here is what I do every time I want to do a test of in-app subscriptions:
Create a new in-app subscription product in the google play developer console.
Point the android app at the new subscription product you just created.
In your code to check for active subscriptions, add a line to specifically ignore the order number of the previous subscription that you tested.
Export a release build of the app and transfer it directly to your testing device.
After testing, return to step #1 to test the next time.
Don't forget to fix your change from step #2 before deploying the app!
You might want to create many subscriptions in step #1 so you don't have to continually wait hours for them to propagate. Please comment if you know of a better way!
UPDATE: Google now has test subscriptions and is making it easier to use them! https://android-developers.googleblog.com/2018/01/faster-renewals-for-test-subscriptions.html
It seems that nowadays there is better solution:
Open your app page in Google Play Store application
Click "Manage subscriptions"
Click "Cancel subscription"
Go to "Settings", "Apps" in your phone.
Find Google Play Store and clear application data.
You should now be able to re-buy subscription.
Create a mock class that mocks out the Google Play methods that you are using.

Categories

Resources