簡體   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