gpt4 book ai didi

ruby-on-rails - 没有这样的客户: cus_************ (Stripe::InvalidRequestError) 当客户存在时

转载 作者:行者123 更新时间:2023-12-04 13:48:32 24 4
gpt4 key购买 nike

我正在一个名为 foodsy 的电子商务市场上工作。我正在使用 stripe connect为目的。连接帐户是使用 stripe-connect-omniauth 创建的. Foodsy 有几个客户。一个 Sku 的订单是在 rails Controller 中创建的

 Stripe.api_key = "sk_test_************"
Stripe::Order.create(
{:currency => 'usd',
:items => [
{
:type => 'sku',
:parent => "sku_************"
}
] },
{ :stripe_account => "acct_************" }
)
它创建了一个 ID 为 or_************ 的订单.
存在于foodsy平台上的顾客购买它,
order=Stripe::Order.retrieve("or_************",stripe_account: "acct_************")
order.pay(customer: "cus_************")
但此代码返回错误 No such customer: cus_************ (Stripe::InvalidRequestError).客户存在,我可以在仪表板上看到他,并且源属性设置在 strip 上。那么为什么会出错呢?

最佳答案

问题在于客户存在于平台的帐户中,而不是您尝试创建费用的连接帐户中。

您需要share the customer从平台账户到关联账户:

# Create a token from the customer on the platform account
token = Stripe::Token.create(
{:customer => "cus_7QLGXg0dkUYWmK"},
{:stripe_account => "acct_17BTxDCioT3wKMvR"}
)

# Retrieve the order on the connected account and pay it using the token
order = Stripe::Order.retrieve("or_17BUNHCioT3wKMvREWdDBagG",
stripe_account: "acct_17BTxDCioT3wKMvR"
)
order.pay(source: token.id)

关于ruby-on-rails - 没有这样的客户: cus_************ (Stripe::InvalidRequestError) 当客户存在时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33946397/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com