繁体   English   中英

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

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

我有这个:

 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,
  });

这样做是创建一种付款方式并将其链接到我当场创建的客户。 但是,我需要为stripeAccount创建客户,而不是我自己的。 我还在以编程方式为我的商家创建条带帐户,所以现在我想将我创建的客户链接到特定的商家。

这是我发现您可以为paymentIntents做的事情,我认为您可能可以为条带帐户做这些,但似乎并非如此:

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

那么我如何在创建客户时使用stripeAccount

您可以对任何 API 请求使用stripeAccount ,它对所有请求的工作方式都相同。 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}}'}
);

顺便说一句,还请注意您的集成似乎有点错误 - 除非您想要大的 PCI 合规性头痛,否则您永远不应该使用这样的原始卡详细信息调用stripe.paymentMethods.createhttps://stripe.com/docs/security/guide #validating-pci-compliance在“API Direct”下)。 你应该使用 Stripe 的前端,比如 Elements/Checkout。

暂无
暂无

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

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