DataGreed
DataGreed

Reputation: 13889

How to distinguish if the user is on subscription trial period or not in google play?

I am implementing a server-side service that checks user's google play subscriptions status. I use the Android Pubisher API (https://developers.google.com/android-publisher/api-ref/purchases/subscriptions/get) to check the subscription status. Though, I cannot understand how to distinguish if the user is on trial period or if he has already paid (i need it for analytics, to attribute revenue)?

How can this be done?

Upvotes: 6

Views: 2379

Answers (1)

Bruno Paulino
Bruno Paulino

Reputation: 5770

When you validate the subscription purchase from your server, you are going to get the subscription resource like that:

{
  "kind": "androidpublisher#subscriptionPurchase",
  "startTimeMillis": long,
  "expiryTimeMillis": long,
  "autoRenewing": boolean,
  "priceCurrencyCode": string,
  "priceAmountMicros": long,
  "countryCode": string,
  "developerPayload": string,
  "paymentState": integer,
  "cancelReason": integer,
  "userCancellationTimeMillis": long
}

The paymentState value has 3 states for subscriptions:

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

You can always call the Google Play API to check this state. API Docs: https://developers.google.com/android-publisher/api-ref/purchases/subscriptions#resource

Upvotes: 3

Related Questions