简体   繁体   English

将 Stripe 平台客户克隆到关联账户客户时出现问题 - 没有这样的 payment_intent: 'pi_abc...zyx'

[英]Issues cloning a Stripe platform customer to a Connected Account Customer - No such payment_intent: 'pi_abc...zyx'

I am using the React components for Stripe.js to try and process a payment for a connected account, and collect a fee off of each payment.我正在使用 Stripe.js 的 React 组件来尝试处理已连接帐户的付款,并从每次付款中收取费用。 I am not sure if the flow between my client and server is properly picking up my cloned customer and payment method.我不确定我的客户端和服务器之间的流程是否正确提取了我的克隆客户和付款方式。 When my test customer tries to pay, I get "No such payment_intent: 'pi_abc...zyx'".当我的测试客户尝试付款时,我收到“No such payment_intent: 'pi_abc...zyx'”。 I have ensured I am using the correct private test keys on both client and server.我确保我在客户端和服务器上都使用了正确的私有测试密钥。 My Connected accounts are express accounts.我的关联账户是快速账户。 When I go to my Stripe dashboard to look at the 'Customers' tab under 'Connect', this is what I see:当我 go 到我的 Stripe 仪表板查看“连接”下的“客户”选项卡时,我看到的是:

客户选项卡下的空白条目

It looks like a blank entry is being created each time I make a payment attempt.每次我尝试付款时,似乎都会创建一个空白条目。

Here are the steps I am currently taking to let the platform customer pay a Connected account:以下是我目前正在采取的让平台客户支付 Connected 账户的步骤:

  1. When a customer first signs up on my website, the Stripe-firebase extension I have installed automatically generates a customer ID.当客户第一次在我的网站上注册时,我安装的 Stripe-firebase 扩展会自动生成一个客户 ID。 These are now considered my platform customers这些现在被认为是我的平台客户
  2. I allow a platform customer to create an Express Connected account, this works perfectly fine.我允许平台客户创建一个 Express Connected 帐户,这非常好用。 I now have their Stripe Account Id ex: 'acct_abc...xyz`.我现在有了他们的 Stripe 帐户 ID,例如:'acct_abc...xyz`。
  3. Now here is the flow for when a platform customer tries to make a payment to a Connected Account:下面是平台客户尝试向关联账户付款时的流程:

React/Client Side - loadStripe with only the test key, not with a Stripe Connected account Id const stripePromise = loadStripe('pk_test_abc...'); React/Client Side - loadStripe 仅使用测试密钥,而不使用 Stripe Connected 帐户 Id const stripePromise = loadStripe('pk_test_abc...'); . . I provide this to <Elements stripe={stripePromise}>我将此提供给<Elements stripe={stripePromise}>

React/Client Side - User fills in payment form and presses submit. React/Client Side - 用户填写付款表格并按下提交。 Create a paymentMethodReq from client/platform:从客户端/平台创建 paymentMethodReq:

const paymentMethodReq = await stripe.createPaymentMethod({
                type: 'card',
                card: cardElement,
                billing_details: billingDetails
            });

Node/Server Side - Client then makes a request to my server to try and clone the platform payment method to a Connected account:节点/服务器端- 客户端然后向我的服务器发出请求,尝试将平台支付方式克隆到连接帐户:

const serverPaymentMethod = await stripe.paymentMethods.create({
            customer: data.customerStripeId, // Customer ID of the customer paying (platform customer)
            payment_method: data.paymentMethodId, // Using the payment method Id generated from 'paymentMethodReq' on the client side
        }, {
            stripeAccount: connectedAccountStripeAccountId, // Using the Connected Account
        });

Node/Server Side - Client then makes a request to my server to create/"clone" a new customer from the platform and link it to the Connected account节点/服务器端- 客户端然后向我的服务器发出请求以从平台创建/“克隆”新客户并将其链接到已连接帐户

const customer = await stripe.customers.create({
            payment_method: data.paymentMethodId, //Payment method id generated from 'serverPaymentMethod' above
        }, {
            stripeAccount: connectedAccountStripeAccountId, // Using the same Connected Account
        });

Node/Server Side - Client then makes a request to my server to create a payment intent with the customer id that was linked to the Connected account along with the payment method that was generated from the server节点/服务器端- 然后客户端向我的服务器发出请求,以使用链接到已连接帐户的客户 ID 以及从服务器生成的付款方式创建付款意图

const intent = await stripe.paymentIntents.create({
        amount: data.price * 100,
        currency: 'usd',
        payment_method_types: ['card'],
        payment_method: data.paymentMethodId, // Payment method id generated from 'serverPaymentMethod' above
        customer: data.customerStripeId, // Customer Id generated from 'customer' above
        description: data.desc,
        capture_method: 'manual',
        application_fee_amount: (data.price * 100) * 0.15,

    }

React/Client Side - I try to confirm the card payment which results in the "No such payment_intent: 'pi_abc...zyx'" error反应/客户端- 我尝试确认卡支付,导致“没有这样的支付意图:'pi_abc...zyx'”错误

const confirmedCardPayment = await stripe.confirmCardPayment(paymentIntentResult?.data?.client_secret, {
                payment_method: serverPaymentMethod?.data.id //Payment method id generated from 'serverPaymentMethod' above
            });

I tried replacing stripe.confirmCardPayment on the client with a call to my server that instead confirms the payment intent like so:我尝试将客户端上的stripe.confirmCardPayment替换为调用我的服务器来确认付款意图,如下所示:

const confirmPaymentIntent = await stripe.paymentIntents.confirm(
data.paymentIntentId, // Payment intent id generated from 'intent' above
{ 
payment_method: data.paymentMethodId // Payment method id generated from 'serverPaymentMethod' above
});

and this also results in "No such payment_intent 'pi_3K...9Rx'"这也会导致“No such payment_intent 'pi_3K...9Rx'”

If anyone could help me figure out where I am going wrong in this process, that would be greatly appreciated.如果有人能帮助我找出我在这个过程中哪里出错了,那将不胜感激。 Thank you谢谢

The error indicates that the PaymentIntent belongs to a different account with whose your current call is using a key of.该错误表明 PaymentIntent 属于另一个帐户,您当前的呼叫正在使用该帐户的密钥。 It could be:它可能是:

  1. You created the PaymentIntent on Platform account, then confirm it from your Connected Account您在平台帐户上创建了 PaymentIntent,然后从您的关联帐户确认
  2. You created the PaymentIntent on Connected Account, then confirm it from your Platform Account您在关联账户上创建了 PaymentIntent,然后从您的平台账户确认

While I am seeing both PaymentIntent creation and confirmation calls doesn't use the stripeAccount parameter, I suspect that you missed the code somewhere and the PaymentIntent was actually created in your Connected Account, lead to #2 possibility above.虽然我看到 PaymentIntent 创建和确认调用都不使用 stripeAccount 参数,但我怀疑您在某处错过了代码,而 PaymentIntent 实际上是在您的连接帐户中创建的,导致上面的#2 可能性。

To debug this you can check which account the PaymentIntent belongs to, by searching its ID on Dashboard's search box, or simply write to Stripe Support with the ID and they can check it for you.要对此进行调试,您可以通过在仪表板的搜索框中搜索其 ID 来检查 PaymentIntent 属于哪个帐户,或者只需使用 ID 写信给 Stripe 支持,他们可以为您检查。

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

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