2024-05-07 14:16:22 发布
网友
我正在向Python Stripe API请求所有争议。我目前检索所有争议的代码如下。你知道吗
import stripe stripe.api_key = "12345" disputes = stripe.Dispute.list(limit=100)
但是,我只想请求包含status的needs_response的争议。在stripeapi中是否有具体的方法来请求这些争议?你知道吗
status
needs_response
import stripe stripe.api_key = get_stripe() from datetime import datetime, timedelta import delorean dt = datetime.utcnow() lte = delorean.Delorean(dt, timezone="UTC").epoch a = datetime.now() + timedelta(days=-2) gte = delorean.Delorean(a, timezone="UTC").epoch chuck = stripe.Dispute.list(created={'gte':int(gte),'lte':int(lte)}) print "NUMBER OF DISPUTES:", len(chuck) ch_lst = [] id_lst = [] name_lst = [] am_lst = [] f_lst = [] for d in chuck.auto_paging_iter(): for d in chuck.auto_paging_iter(): if (d['status'] == 'needs_response' or d['status'] == 'warning_needs_response'): c = stripe.Charge.retrieve(str(d['charge'])) ch_lst.append(str(d['charge'])) id_lst.append(str(d['id'])) am_lst.append(str(c['amount'])) name_lst.append(str(c['source']['name'])) f_lst.append(str(c['source']['fingerprint']))
在这里,最好的办法是在从API中检索disputes的完整列表之后在本地进行过滤。使用auto-pagination,这可以简单到:
disputes
disputes = stripe.Dispute.list(limit=3) for dispute in disputes.auto_paging_iter(): if (dispute.status == 'needs_response'): # Do something with the dispute
作为一个推广,如果它不在arguments list for that resource中,那么您只需要在本地进行进一步的过滤。你知道吗
在这里,最好的办法是在从API中检索
disputes
的完整列表之后在本地进行过滤。使用auto-pagination,这可以简单到:作为一个推广,如果它不在arguments list for that resource中,那么您只需要在本地进行进一步的过滤。你知道吗
相关问题 更多 >
编程相关推荐