【问题标题】:Stripe API in python gives incorrect number of transactionspython中的Stripe API给出了不正确的交易数量
【发布时间】:2021-04-11 19:35:31
【问题描述】:

这是我在 Stripe API 中检索交易数量的代码

import stripe
customers = stripe.Customer.list()
print(len(customers))

上面的代码总是在输出中打印10。我正在使用 Stripe 网站给我的测试公钥和私钥。我的代码的哪一部分不正确?

【问题讨论】:

    标签: python api transactions payment


    【解决方案1】:

    根据 Stripe API 文档,请求客户列表的默认限制是 10 个。这可能是您最终只获得 10 个客户而不是整个列表的原因。

    与许多此类 API 一样,文档包含一个启用分页的参数 starting_afterending_before。您可以阅读有关 Stripe 的 API here 的更多信息 - 我建议您增强您的 API 文档阅读能力,因为我个人发现它们在处理此类项目时非常有用。

    【讨论】:

    • 添加这一行解决了问题'customers = stripe.Customer.list(limit=100000)'
    猜你喜欢
    • 2020-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-17
    • 1970-01-01
    • 2014-08-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多