Home » Android » What is the response of the cancelled subscription product from the google developer api android

What is the response of the cancelled subscription product from the google developer api android

Posted by: admin May 14, 2020 Leave a comment

Questions:

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.

How to&Answers:

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.