如何仅使用 python 中的条带获取当前日期的发票?
How to get invoice of current date only using stripe in python?
我正在使用 stripe API 获取发票 JSON 并使用 pdf link 下载发票。
现在,每当我索取发票 API returns 时,我都会收到所有发票 JSON。
我的问题是我如何使用任何参数只获得今天的交易发票,或者如果没有参数,这怎么可能通过 python 逻辑实现。
我的代码:
import stripe
stripe.api_key = 'my_secret_key'
invoices = stripe.Invoice.list(limit=100)
print(f'Total Invoices: {len(invoices)}')
print(invoices)
文档建议您可以将创建的参数添加到 Invoice.list 并传递大于/小于时间戳的字典。
https://stripe.com/docs/api/invoices/list?lang=python#list_invoices-created
您可以使用此 API 列出所有 Invoices
,或列出在特定时间创建的特定 Customer
的所有发票,请参阅 https://stripe.com/docs/api/invoices/list#list_invoices-created-gte。请注意 created
参数在 秒 .
中
因此,如果您想列出今天创建的所有 Invoices
(例如,2021 年 3 月 13 日星期六 00:00:00 GMT),那么您可以写一些类似的东西(当然你必须转换成 Python-等价的...)
Map<String, Object> params = new HashMap<>();
Map<String, Object> createdParams = new HashMap<>();
createdParams.put("gte", "1615593600");
params.put("created", createdParams);
InvoiceCollection invoices = Invoice.list(params);
我正在使用 stripe API 获取发票 JSON 并使用 pdf link 下载发票。 现在,每当我索取发票 API returns 时,我都会收到所有发票 JSON。 我的问题是我如何使用任何参数只获得今天的交易发票,或者如果没有参数,这怎么可能通过 python 逻辑实现。
我的代码:
import stripe
stripe.api_key = 'my_secret_key'
invoices = stripe.Invoice.list(limit=100)
print(f'Total Invoices: {len(invoices)}')
print(invoices)
文档建议您可以将创建的参数添加到 Invoice.list 并传递大于/小于时间戳的字典。
https://stripe.com/docs/api/invoices/list?lang=python#list_invoices-created
您可以使用此 API 列出所有 Invoices
,或列出在特定时间创建的特定 Customer
的所有发票,请参阅 https://stripe.com/docs/api/invoices/list#list_invoices-created-gte。请注意 created
参数在 秒 .
因此,如果您想列出今天创建的所有 Invoices
(例如,2021 年 3 月 13 日星期六 00:00:00 GMT),那么您可以写一些类似的东西(当然你必须转换成 Python-等价的...)
Map<String, Object> params = new HashMap<>();
Map<String, Object> createdParams = new HashMap<>();
createdParams.put("gte", "1615593600");
params.put("created", createdParams);
InvoiceCollection invoices = Invoice.list(params);