Android-inapp-billing-v3: Question: Is it possible to check if app subscription is in free trial stage?

Created on 11 Aug 2017  路  6Comments  路  Source: anjlab/android-inapp-billing-v3

Currently looking at the PurchaseState class, I don't see an enum for checking if the user is using the full version of the app as a free trial. Is there a way to check if there is an active free trial or do I have to come up with my own solution?

All 6 comments

Well, as I understand, from the APK point of view there is no difference between trial and regular subscriptions. The only difference is how these being billed. But you could look into PurchaseInfo details provided by getSubscriptionTransactionDetails method, maybe be you can find some interesting flag there (see responseData String data).
Let us know if you'll find something, this is indeed interesting question

Finally got around to making a test subsciption and this is what responseData returned:

```{
"orderId": "",
"packageName": "",
"productId": "full_subscription",
"purchaseTime": 1503196647610,
"purchaseState": 0,
"developerPayload": "subs:full_subscription",
"purchaseToken": "",
"autoRenewing": true
}

Looking at the Google Play Developer API, the response for subscription is returned like this: 
```{
  "kind": "androidpublisher#subscriptionPurchase",
  "startTimeMillis": long,
  "expiryTimeMillis": long,
  "autoRenewing": boolean,
  "priceCurrencyCode": string,
  "priceAmountMicros": long,
  "countryCode": string,
  "developerPayload": string,
  "paymentState": integer,
  "cancelReason": integer,
  "userCancellationTimeMillis": long
}

I'm guessing that responseData is directly coming from the In App Billing library. I see that there is a difference between purchaseState from responseData and paymentState from the Google Play Developer API. paymentState can be either 0 for payment pending, 1 for payment received or 2 for free trial. I'm not sure what purchaseState can represent.

Any progress on this yet?

@mochat97 hey :) Do you find any solution for this question? Thanks.

Any way to find paymentState from In App Billing library?

Hi =) It seems like constants for PurchaseState are:
0 -> UNSPECIFIED_STATE
1 -> PURCHASED
2 -> PENDING
image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

goldfish07 picture goldfish07  路  8Comments

pro-guitar picture pro-guitar  路  6Comments

mahirozdin picture mahirozdin  路  3Comments

AdityaAnand1 picture AdityaAnand1  路  6Comments

najam-amfnrh9 picture najam-amfnrh9  路  6Comments