[英]Stripe - Retrieve Customer PaymentIntent history
我正在构建一个平台,我正在使用 Stripe 的父“平台”帐户和属于该平台的 Connected Stripe 帐户的概念。 (例如 Lyft 模型) 按照 Stripe 的文档,当我在 Stripe 中创建一个新客户时,我会在主平台帐户下创建它,并将所有付款方式存储在该客户下。 当客户从 Connected 帐户购买东西时,我会按照 此文档进行操作,在其中克隆付款方式并创建附加到特定 Connected 帐户的 PaymentIntent。 这一切都有效。 但是,当我尝试获取客户交易的历史记录(PaymentIntents 列表)时,它返回一个空列表,因为它针对主平台帐户运行它:
stripe.PaymentIntent.list(customer='cus_FJDHFGSJHDF')
当我指定一个客户和关联账户 ID 时,它返回一个空列表,因为该客户在该关联账户中不存在,但是,paymentIntents 存在于该关联账户中。
那么,为 Connected 帐户的客户创建 PaymentIntent 然后获取该客户 PER Connected Stripe 帐户的付款历史记录的正确方法是什么?
以下是我克隆 PaymentMethod 并创建 PaymentIntent 的方法:
payment_method = stripe.PaymentMethod.create(
customer=customer,
payment_method=customer.invoice_settings.default_payment_method,
stripe_account=stripe_connect_id,
)
intent = stripe.PaymentIntent.create(
payment_method=payment_method,
amount=amount,
currency='usd',
confirm=True,
application_fee_amount=fee_in_cents if fee_in_cents >= 1 else None,
stripe_account=stripe_connect_id,
)
据我所知,您有两个选择:
希望有帮助!
[0] https://stripe.com/docs/connect/cloning-saved-payment-methods#making-a-charge
这是我决定采取的方法。 由于我对提取特定客户在特定 Connected 帐户中的费用特别感兴趣,因此我阅读了有关费用的更多信息,并注意到您可以根据transfer_group='{ORDER10}'
获得费用清单。 所以,这是我的流程:
transfer_group
设置为客户的电话号码,因为它是整个平台的唯一标识符。 现在,当我需要提取特定客户的所有费用时,我会遍历与客户关联的每个 Connected 帐户(此关系存储在我的平台上),并使用transfer_group
和stripe_account_id
简单地提取所有费用:
def get_all_charges(user, stripe_account_id):
return stripe.Charge.list(transfer_group=user.phone_number, stripe_account=stripe_account_id, limit=100).data
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.