如果试图通过 a connected account收取客户记录(其具有关联的信用卡),我得到一个错误声明,“没有这样的客户:cus_xxxx“ - 即使向同一客户收取费用,当不是使用”已连接“帐户(通过平台帐户进行收费)时,也能正常工作。Stripe连接:针对“已连接”(独立)帐户对现有客户进行充电
例如,请考虑下面的Ruby代码,假设我们有一个ID acct_ABC123
一个“连接”(独立)帐户:
# Use the (secret) API key for the "platform" or base account.
Stripe.api_key = 'sk_[...]'
customer = Stripe::Customer.create(email: '[email protected]')
# 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 }