【发布时间】:2020-03-07 15:36:22
【问题描述】:
我想创建一个 Stripe PaymentIntent,直接向关联的账户收费
这是我写的
stripe.paymentIntents.create(
{
amount: 2000,
currency: 'gbp',
payment_method: 'pm_xxxx',
}, {
stripe_account: 'acct_1F2xxxxxxxxxx'
},
function(err, paymentIntent) {
// asynchronously called
// do something here
}
);
我做错了什么??
以下代码(没有连接的帐户)可以正常工作
stripe.paymentIntents.create(
{
amount: 2000,
currency: 'gbp',
payment_method: 'pm_xxxx',
},
function(err, paymentIntent) {
// asynchronously called
// do something here
}
);
我怀疑这是罪魁祸首,因为控制台错误说明了 PaymentMethod....
编辑:代码是正确的,我发现问题出在 Stripe 上,因为它们需要某种进一步的身份验证。来自 Stripe 文档
如果您选择直接收费,则需要确保 连接的帐户已启用您打算使用的付款方式 采用。直接收费需要在连接时创建 PaymentMethods 帐户....
如果您从服务器创建 PaymentMethods,您 可以使用 Stripe-Account 标头进行身份验证 我们支持的任何库。
我会努力的,看看怎么做
【问题讨论】:
-
这段代码是正确的。如果您收到错误,可能是您无权访问您在
stripe_account中传递的帐户。在不知道这里的确切错误的情况下提供帮助有点棘手。另外,您可能想直接与 Stripe 的支持团队交谈,因为这是您连续第三个关于 PaymentIntents 的问题。 -
这是错误@koopajah
Error: No such payment_method: pm_1FdmPxxxxxxxxx; OAuth key or Stripe-Account header was used but API request was provided with a platform-owned payment method ID. Please ensure that the provided payment method matches the specified account. -
你没有表明你做错了什么。
-
代码正确。问题出在 Stripe 上——我做了一个 edit2 评论
-
问题是在平台上创建了PaymentMethod,然后您尝试在连接的帐户上使用它。那永远行不通。您需要查看此文档:stripe.com/docs/payments/payment-methods/…