关于 node.js:如何进行付款 Intent 以在 Stripe 中向已连接的帐户收费

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.

我会努力的,看看怎么做


我发现这个 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