代码之家  ›  专栏  ›  技术社区  ›  Mohsin

如何在应用程序产品购买中消费订阅类型

  •  3
  • Mohsin  · 技术社区  · 9 年前

    我已经在我的应用程序中实现了订阅类型的应用程序内产品,比如1个月或2个月的套餐,一旦用户订阅了该产品,我就会让服务器知道并相应地处理他/她,并且它运行得非常好。

    根据谷歌在订阅期结束时的数据:

    谷歌汽车削减了信用额度,并续订了套餐。

    我的问题: 我如何才能知道下个月是否已经付款的用户?

    2 回复  |  直到 9 年前
        1
  •  7
  •   lxknvlk    8 年前

    回答问题:你不能使用订阅。你只能吃些小吃。

    引用自文档:

    Important: Unlike in-app products, subscriptions cannot be consumed. 资料来源: https://developer.android.com/google/play/billing/api.html

    这一页引出了这两条: https://developer.android.com/google/play/billing/billing_subscriptions.html https://developer.android.com/google/play/billing/billing_integrate.html#Subs

    还要注意,在提供订阅时,最好允许用户恢复订阅。例如,如果一个用户登录了你的应用程序,购买了一个订阅,然后用另一个用户名登录,那么该订阅也应该在那里可用,因为它附加到用户的googleplay帐户。

    要做到这一点,您应该查询购买的订阅,如 马尔默 明确规定。

        2
  •  1
  •   marmor    8 年前

    您可以从GooglePlay获得活动购买的列表,然后相应地更新您的服务器(例如每天)。

    IInAppBillingService service = ...;
    Bundle items = service.getPurchases(API_VERSION, PACKAGE_NAME, "subs", null);
    int response = getResponseCodeFromBundle(items);
    if (response != RESULT_OK) {
      // handle error
    }
    ArrayList<String> productIDs = items.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
    // update server with active product ids