我正在构建一个平台,在该平台上我使用Stripe的父“平台”帐户和属于该平台的Connected Stripe帐户的概念。 (例如Lyft模型)按照Stripe的文档,当我在Stripe中创建新客户时,我在主平台帐户下创建了该客户,并在该客户下存储了所有付款方式。当客户从关联帐户购买商品时,请遵循this文档,在该文档中克隆付款方式并创建一个与特定关联帐户关联的PaymentIntent。而且一切正常。但是,当我尝试获取客户交易记录(PaymentIntents列表)时,它返回一个空列表,因为它是针对主要平台帐户运行的:
stripe.PaymentIntent.list(customer='cus_FJDHFGSJHDF')
当我指定一个客户AND关联帐户ID时,它将返回一个空列表,因为该关联帐户中不存在该客户,但是,该关联帐户中存在paymentIntents。
那么,为关联帐户的客户创建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 :(得分:1)
据我所知,您有2种选择:
希望有帮助!
[0] https://stripe.com/docs/connect/cloning-saved-payment-methods#making-a-charge
答案 1 :(得分:0)
这是我决定采用的方法。由于我特别希望提取特定客户在特定关联帐户中产生的费用,因此我阅读了更多有关费用的信息,并注意到您可以基于transfer_group='{ORDER10}'
获得费用列表。所以,这是我的流程:
transfer_group
设置为客户的电话号码,因为它是整个平台上的唯一标识符。现在,当我需要提取特定客户的所有费用时,我将遍历与该客户相关联的每个关联帐户(此关系存储在我的平台上),然后只需使用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