【发布时间】:2017-05-20 01:58:40
【问题描述】:
如果尝试通过connected account 向客户记录(具有关联的信用卡) 收取费用,我会收到错误消息,声称“没有这样的客户:cus_xxxx”——即使当不使用“连接”帐户(通过平台帐户收费时)时,向同一客户收费将正常工作。
例如,考虑以下 Ruby 代码,假设我们有一个 ID 为 acct_ABC123 的“已连接”(独立)帐户:
# Use the (secret) API key for the "platform" or base account.
Stripe.api_key = 'sk_[...]'
customer = Stripe::Customer.create(email: 'customer@example.com')
# Associate a credit-card with the customer.
token = # Generate a token (e.g., using Stripe Checkout).
customer.sources.create(source: token)
# Attempt to charge the card via the connected account...
Stripe::Charge.create({ amount: 150, currency: 'usd', customer: customer.id,
application_fee: 25 }, stripe_account: 'acct_ABC123')
最后一行导致Stripe::InvalidRequestError 异常,上面提到了“没有这样的客户”错误。但是,如果我们只是尝试在“平台”帐户上运行它(没有stripe_account 参数并且没有application_fee),那么同样的费用将被罚款......
Stripe::Charge.create({ amount: 150, currency: 'usd', customer: customer.id }
【问题讨论】:
标签: ruby stripe-payments stripe-connect