使用板条充电时“无此类客户”

2024-05-16 03:24:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我在用stripeapi进行测试,但我无法让这个基本的“市场”场景正常工作。这个场景是买家从卖家那里购买,而应用程序需要付费。在

我的设置:

# Seller has already connected their account to the application 
# through "Stripe Connect Standalone". Below will attempt to charge a customer.

import stripe

# application's sk from stripe
stripe.api_key = "sk...."

# Build customer
customer = stripe.Customer.create(
    email = customer.email,
    card = token_from_stripe_checkout
)

# Now do a charge
charge = stripe.Charge.create(
    amount = 2000,
    currency = "usd",
    customer = customer.id,
    application_fee = 500,
    stripe_account = seller.stripe_user_id # which is something like: acct_xxxxxxxxx
)

这将导致错误:

^{pr2}$

我做错什么了?在


Tags: tofromidapplication市场emailcreate场景
1条回答
网友
1楼 · 发布于 2024-05-16 03:24:53

代码中主要发生两件事:

  1. 你创造了一个客户。在
  2. 然后你向那个顾客收费。在

问题是你在自己的账户中创建客户,但你在关联账户的范围内创建费用。当您传递stripe_account时,实际上是告诉Stripe在另一个已连接帐户下运行API调用。您的已连接帐户无法访问基本帐户的客户。在

简单的修复方法是将stripe_account传递给createcustomerapi调用。在

相关问题 更多 >