简体   繁体   English

为条带连接帐户 node.js 创建客户

[英]create customer for stripe connected account node.js

I have this:我有这个:

 const paymentMethod = await stripe.paymentMethods.create({
    type: 'card',
    card: {
      number: '4242424242424242',
      exp_month: 1,
      exp_year: 2024,
      cvc: '123',
    },
  });

  console.log(paymentMethod.id)
  const customer = await stripe.customers.create({
    payment_method: paymentMethod.id,
  });

what this does is creates a payment method and links it to the customer in which i create on the spot.这样做是创建一种付款方式并将其链接到我当场创建的客户。 However, I need to create the customer for a stripeAccount , instead of my own.但是,我需要为stripeAccount创建客户,而不是我自己的。 I am also programmatically creating stripe accounts for my merchants, so now I want to link the customer i create to the specific merchant.我还在以编程方式为我的商家创建条带帐户,所以现在我想将我创建的客户链接到特定的商家。

here's what I found you can do for paymentIntents , that I thought you may be able to do for stripe accounts, but it doesn't seem so:这是我发现您可以为paymentIntents做的事情,我认为您可能可以为条带帐户做这些,但似乎并非如此:

const paymentIntent = await stripe.paymentIntents.create({
    amount: 2000,
    currency: 'usd',
    customer: customerid
  }, {
    stripeAccount: 'myaccount_id',
});

so how can i use stripeAccount within creation of customer?那么我如何在创建客户时使用stripeAccount

You can use stripeAccount for any API request, it works the same way on all of them.您可以对任何 API 请求使用stripeAccount ,它对所有请求的工作方式都相同。 There's an example directly in Stripe's documentation: https://stripe.com/docs/connect/authentication#stripe-account-header Stripe 的文档中直接有一个示例: https://stripe.com/docs/connect/authentication#stripe-account-header

const customer = await stripe.customers.create(
  {email: 'person@example.edu'},
  {stripeAccount: '{{CONNECTED_STRIPE_ACCOUNT_ID}}'}
);

As an aside, note also your integration seems a little wrong — you should never be calling stripe.paymentMethods.create with raw card details like that unless you want large PCI compliance headache( https://stripe.com/docs/security/guide#validating-pci-compliance under "API Direct").顺便说一句,还请注意您的集成似乎有点错误 - 除非您想要大的 PCI 合规性头痛,否则您永远不应该使用这样的原始卡详细信息调用stripe.paymentMethods.createhttps://stripe.com/docs/security/guide #validating-pci-compliance在“API Direct”下)。 You should use Stripe's frontends like Elements/Checkout.你应该使用 Stripe 的前端,比如 Elements/Checkout。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM