android - 如何区分用户是否在谷歌播放订阅试用期?

标签 android api google-play google-play-services

我正在实现一项检查用户的 google play 订阅状态​​的服务器端服务。我使用 Android Pubisher API ( https://developers.google.com/android-publisher/api-ref/purchases/subscriptions/get ) 检查订阅状态。虽然,我不明白如何区分用户是否处于试用期或他是否已经付款(我需要它进行分析,以归因于收入)?

如何做到这一点?

最佳答案

当您从您的服务器验证订阅购买时,您将获得这样的订阅资源:

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

paymentState 值有 3 种订阅状态:

  • 0 - 待付款
  • 1 - 已收到付款
  • 2 - 免费试用

您可以随时调用 Google Play API 来检查此状态。 API 文档:https://developers.google.com/android-publisher/api-ref/purchases/subscriptions#resource

关于android - 如何区分用户是否在谷歌播放订阅试用期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41122253/

相关文章:

java - CountDownTimer cancel() 不会取消计时器并继续工作

java - 我有错误 "Call requires API level 11 (current min is 8)"。这是我在我的项目(ECLIPSE)中可以找到的

java - 不断向AsyncTask传入数据?

node.js - 我们可以说 “If an API is following 6 constraints of REST then it’ 是一个 RESTful API”吗?

php - 进行具有不同参数的多个curl请求的最佳实践是什么?

android - 如何在android应用程序的抽屉导航菜单中放置缩进

android - 如何使用深度链接而不是 google play 商店网站打开我的应用程序?

url - 为什么我的内部测试轨道选择加入 URL 不起作用?

android - 需要创建一个在互联网可用时上传数据的后台服务

android - 如何在 Android 中像 Facebook 一样制作操作栏