How to make a payment Intent to charge a connected account in Stripe
我想创建一个 Stripe PaymentIntent,直接向关联的账户收费
这是我写的
1
2 3 4 5 6 7 8 9 10 11 12 13 |
stripe.paymentIntents.create(
{ amount: 2000, currency: ‘gbp’, payment_method: ‘pm_xxxx’, }, { stripe_account: ‘acct_1F2xxxxxxxxxx’ }, function(err, paymentIntent) { // asynchronously called // do something here } ); |
我做错了什么??
以下代码(没有连接的帐户)可以正常工作
1
2 3 4 5 6 7 8 9 10 11 |
stripe.paymentIntents.create(
{ amount: 2000, currency: ‘gbp’, payment_method: ‘pm_xxxx’, }, function(err, paymentIntent) { // asynchronously called // do something here } ); |
我怀疑这是罪魁祸首,因为控制台错误说明了 PaymentMethod….
编辑:代码是正确的,我发现问题出在 Stripe 上,因为它们需要某种进一步的身份验证。来自 Stripe 文档
If you opt for direct charges, you will need to make sure that the
connected account is onboarded on the payment method you intend to
use. Direct charges require creating PaymentMethods on connected
accounts….If you’re creating PaymentMethods from the server, you
can make use of authentication using the Stripe-Account header with
any of our supported libraries.
我会努力的,看看怎么做
- 这段代码是正确的。如果您收到错误,可能是您无权访问您在 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/…
- 你是对的@koopajah。然后,我决定按照您的指南在服务器中克隆我的付款意图。克隆的付款方式工作正常,我可以代表我连接的帐户创建付款意图。现在的问题是当我需要在客户端中确认/验证时。我正在使用颤振和 stripe_payment 插件,但无法进行身份验证
- 不幸的是,我不知道插件是如何工作的。但是在客户端,当您初始化 Stripe.js 时,您也需要像这样显式设置连接的帐户 ID:stripe.com/docs/payments/payment-methods/…
我发现这个 https://medium.com/flutter-community/build-a-marketplace-in-your-flutter-app-and-accept-payments-using-stripe-and-firebase-72f3f7228625 描述如何为已连接的帐户收费。
基本上你需要在服务器中克隆你的支付方式,然后创建你的支付意图
用于克隆支付方式的 Stripe 文档:https://stripe.com/docs/connect/cloning-saved-payment-methods
- 您是如何克隆付款方式的?链接已损坏
- 链接更新。看一看
来源:https://www.codenong.com/58809995/