可以从Stripe API获取计划的订阅者数量吗? [英] Is it possible to get a count of subscribers for a plan from the Stripe API?

查看:58
本文介绍了可以从Stripe API获取计划的订阅者数量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Stripe.net库针对Stripe API进行调用.

I am using the Stripe.net library to make calls against the Stripe API.

我希望获得各种计划的订阅者总数,但是我不确定当前的API和/或Stripe.NET库是否可以实现.

I would like to get a total count of subscribers for various Plans but I am not sure if this is possible with the current API and/or the Stripe.NET Library at all.

任何人都可以提供关于是否可行的任何见解吗?

Can anyone provide any insight as to whether or not this is possible?

推荐答案

对此没有直接要求,但很容易完成.

There's no direct call for this, but it's easy enough to accomplish.

列出所有客户" API调用( StripeCustomerService

The "List all customers" API call (StripeCustomerService's List() method in Stripe.Net) returns the full JSON object for each customer, including their subscription and plan information. You can easily iterate through that and build your list of subscriber counts.

请注意,如果您有很多用户,则必须分块检索客户列表.API调用的上限为100条记录(默认值为10),并且接受偏移量.为了便于遍历列表,Stripe JSON响应中的 count 属性是客户记录的 total 个总数.

Note that if you have a lot of users, you'll have to retrieve the customer list in chunks. The API call is capped at 100 records (with a default of 10) and accepts an offset. For easy traversal of the list, the count property in Stripe's JSON response is the total number of customer records.

因此,对于基本概述,您的策略将是:

So for a basic outline, your strategy would be:

  1. 通过 List()
  2. 请求100条记录
  3. 计算所需的其他请求数
  4. 处理最初的100条记录
  5. 通过 List()请求100条记录,偏移100 *迭代
  6. 处理当前的100条记录
  7. 重复4&5,直到记录用完
  1. Request 100 records via List()
  2. Calculate the number of additional requests required
  3. Process the initial 100 records
  4. Request 100 records via List(), offset by 100 * iteration
  5. Process the current 100 records
  6. Repeat 4 & 5 until records are exhausted

这篇关于可以从Stripe API获取计划的订阅者数量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆