8

I can't seem to find any relevant information in the Purchase object returned by Google. I know there is a "getFreeTrialPeriod()" method for SkuDetails, but that only returns the duration of the free trial, and not if the user used the free trial or not.

Any ideas? Thanks!

Michael Eilers Smith
  • 8,466
  • 20
  • 71
  • 106

1 Answers1

4

This is only possible if you use backend to process subscriptions. Then from your server you can make a request that will return you JSON with purchase information, where you can find paymentState field.

Possible values:

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

You can use it if you want to determine if the trial is active now. To determine if a trial was active in the past, your server should receive Real-time developer notifications and store information about purchased subscriptions.

For example, when you receive SUBSCRIPTION_PURCHASED notification, you can make the same request as above, to retrieve information about purchase. In the JSON you'll get there will be priceAmountMicros field. It should be 0 for trial. So you can store that on your server and check for it later.

Victor Cold
  • 603
  • 5
  • 15
  • Only if you don't have a backend you can also check the free trial period programmatically starting from the day of the original purchase with `Purchase.getPurchaseTime` and making the calculation by yourself. Obviously to avoid possible mistakes it's best to keep track also of any purchase updates. – LM_IT Oct 07 '21 at 15:35