11

I have implemented monthly Subscription in my application to activate user on our web server. I have successfully implemented subscription code in my project. I want to deactivate user if user cancel subscription from the google play store My App profile. I have implemented get product subscription detail if user cancel subscription product according to the document-1 and document-2.

What is the problem?

I can not test subscription product purchase according to the documentation. So, I will give the signed build to the client and they will check using the credit card and real product purchase. But how can I test what is the response that client will get while subscription was cancelled by the user?

for the cancelling product: I put the service to get access token daily and check validUntilTimestampMsec is greater than zero then check autoRenewing flag is false or not if both are true then deactivate the user. but don't know this logic is right or wrong.

if (validUntilDateInMilli > 0) {
    if ((System.currentTimeMillis() > validUntilDateInMilli)
                        && (!autoRenewingFlag)) {
        // call web service to deactivate user

        new AsyncTaskDeActivateBusinessOwner().execute();
    } 
}

I only got this response from the official document of developer api is shown below:

{
  "kind": "androidpublisher#subscriptionPurchase",
  "initiationTimestampMsec": {long},
  "validUntilTimestampMsec": {long},
  "autoRenewing": {boolean}
}

According to what I have searched on Google and StackOverFlow, but no documentation I found what is the response for the below condition:

what is the response 

1) if the user currently has the subscription and 
2) if user has cancelled subscription(in 15 days) or if subscription cycle is completed.

Please anyone who have tested the subscription end-to-end purchase and cancelled subscription validUntilDate from the google developer api.

Any help will greatly appreciated. Thank you in advance.

Maulik
  • 3,316
  • 20
  • 31
  • 1
    Just a guess - check Purchase API that may be useful http://developer.android.com/google/play/billing/gp-purchase-status-api.html – MKJParekh Oct 04 '13 at 08:35
  • @MKJParekh Captain, thanks for the reply. I have go through this link and got the other links which are posted on my question. – Maulik Oct 04 '13 at 09:07

1 Answers1

4

Google Play API get gives you similar Purchases result regardless of the subscription cancellation status. So, currently, you cannot find out whether the user has canceled the subscription or not.

You have to check whether the subscription is valid or not after the expiration date.

Query for subscription status only at expiration — Once your server has retrieved the expiration date of subscription tokens, it should not query the Google Play servers for the subscription status again until the subscription is reaching or has passed the expiration date.

http://developer.android.com/google/play/billing/gp-purchase-status-api.html

Compare the validUntilTimestampMsec (in the Purchases result) with the current time to see if the subscription has ended.

Juuso Ohtonen
  • 8,826
  • 9
  • 65
  • 98
  • Thank you for your answer, I have to stop querying for purchase status after I receive subscription date until exp date (+1 for this). but what is the response before or after the expiration date so that I could manage the flow of app for the cancellation of subscription. – Maulik Oct 14 '13 at 06:11
  • as you told me "check whether subs is valid or not after the expiration date" but how can I check this? if using the same querying to developer api then what will be the response if subscription is valid or invalid? I could not found any document according to the response like if subs is valid then you get this response or what for invalid. – Maulik Oct 14 '13 at 06:23
  • If the user has canceled the subscription, the `validUntilTimestampMsec` in Purchases result should be a time in the past if you check it after the expiration date. – Juuso Ohtonen Oct 14 '13 at 09:17
  • that is already added in my question, and what is the response if the subs is valid before expiration date and subs is cancelled before expiration date. – Maulik Oct 14 '13 at 10:18
  • After expiration, check `validUntilTimestampMsec` - if it's in the future, the subscription is valid; if it's in the past, the subscription is not valid anymore. – Juuso Ohtonen Oct 14 '13 at 10:22
  • are you sure about this and have tested on real subs products? I mean the response for the cancelled subscription should be any thing after expiration date either it is null or as you given in the previous comments. can you have official document that show me the response for both the cases because I could not test in the real product right now using credit card? – Maulik Oct 14 '13 at 10:34
  • Sorry, I don't have a reference to an official document. I had tested this with a real product, and checked the `validUntilTimestampMsec` value. – Juuso Ohtonen Oct 15 '13 at 03:28