Track your subscriptions better with the Google Play Developer API

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

Posted by Neto Marin, Developer Advocate

Back in 2012, we introduced free trials support for Android app subscriptions. A
free trial runs for a period of time that you set and then automatically
converts to a full subscription based on the subscription’s billing interval and
price. Google Play supports free trials for all subscription types. Check out Free
trials in our documentation for more details.

This feature is an important tool for user conversion because the user can try
your app or game before committing to paying. To help you track the
subscription status better, we are adding a third “paymentState” value to the Purchases.subscriptions
API (on Google
Play Developer API) to represent that the user is in a free trial. Possible
values are:

  • 0 – Payment pending
  • 1 – Payment received
  • 2 – Free trial

Since there is a new possible value, it is necessary to check how your back end
is handling the paymentState parameter. If you are doing something like this,
you potentially could have a problem:

// WARNING: Don't do this!
if (paymentState == 1) {
    // User is in normal state
} else {
    // Handle user in grace period   # this would now be a bug
}

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

As a best practice, and to avoid issues on future updates, we recommend checking
specifically for each possible case, like this:

if (paymentState == 0) {
    // Subscriber with payment pending
} else if (paymentState == 1) {
    // Subscriber in good standing (paid)
} else if (paymentState == 2) {
    // Subscriber in free trial
}

You can check the Purchases.subscriptions
documentation for more details. And if you’re not offering free trials in your
app or game, don’t miss the chance to increase user conversions by letting them
have a taste of your app – check out our documentation on Free
trials.


Android Developers Blog

Your ads will be inserted here by

Easy Ads.

Please go to the plugin admin page to set up your ad code.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy This Password *

* Type Or Paste Password Here *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>