具有多个目标帐户 ID 的 Stripe Connect

Stripe Connect with Multiple Destination Account Ids

我们可以使用 NodeJS 中的 Stripe 连接创建付款并收取 application_fee 作为 follows:

// Get the credit card details submitted by the form
var token = request.body.stripeToken;

// Create the charge on Stripe's servers - this will charge the user's card
stripe.charges.create(
  {
    amount: 1000, // amount in cents
    currency: "eur",
    source: token,
    description: "Example charge",
    application_fee: 123 // amount in cents
  },
  {stripe_account: CONNECTED_STRIPE_ACCOUNT_ID},
  function(err, charge) {
    // check for `err`
    // do something with `charge`
  }
);

可以使用Stripe原生获取源checkout handler

但是,如果我有一个市场并且我想结帐多个具有不同作者的项目,我将如何进行?

问题是我需要从一个来源创建多个费用。但是随后系统会认为存在错误,因为总金额(在检索 stripeToken 源时使用)与(单个项目的)单个金额不匹配。

单笔费用不能分摊到多个账户。

1) 您需要将令牌保存给平台帐户中的客户。 2) 使用 "Shared Customers"

为每个要创建费用的帐户创建一个新令牌
// Create a Token from the existing customer on the platform's account
stripe.tokens.create(
  { customer: CUSTOMER_ID, card: CARD_ID },
  { stripe_account: CONNECTED_STRIPE_ACCOUNT_ID }, // id of the connected account
  function(err, token) {
    // callback
  }

3) 使用新令牌使用问题中的代码创建费用

如果有人仍然遇到这个问题,看起来 Stripe 现在有一个 transfer_group 属性 可以放在 PaymentIntent 上。这个 transfer_group 是你想出的一些字符串,可以将它附加到多个传输中。

在此处阅读更多相关信息:https://stripe.com/docs/connect/charges-transfers

您可以看到,在示例中,同一个 PaymentIntent 发生了多次传输。

转群看看:

// Set your secret key. Remember to switch to your live secret key in 

production.
// See your keys here: https://dashboard.stripe.com/apikeys
const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

// Create a PaymentIntent:
const paymentIntent = await stripe.paymentIntents.create({
  amount: 10000,
  currency: 'usd',
  payment_method_types: ['card'],
  transfer_group: '{ORDER10}',
});

// Create a Transfer to the connected account (later):
const transfer = await stripe.transfers.create({
  amount: 7000,
  currency: 'usd',
  destination: '{{CONNECTED_STRIPE_ACCOUNT_ID}}',
  transfer_group: '{ORDER10}',
});

// Create a second Transfer to another connected account (later):
const secondTransfer = await stripe.transfers.create({
  amount: 2000,
  currency: 'usd',
  destination: '{{OTHER_CONNECTED_STRIPE_ACCOUNT_ID}}',
  transfer_group: '{ORDER10}',
});

参考:https://stripe.com/docs/connect/charges-transfers