【问题标题】:Issues cloning a Stripe platform customer to a Connected Account Customer - No such payment_intent: 'pi_abc...zyx'将 Stripe 平台客户克隆到关联账户客户时出现问题 - 没有这样的 payment_intent: 'pi_abc...zyx'
【发布时间】:2022-01-10 19:21:17
【问题描述】:

我正在使用 Stripe.js 的 React 组件来尝试处理已连接帐户的付款,并从每次付款中收取费用。我不确定我的客户端和服务器之间的流程是否正确提取了我的克隆客户和付款方式。当我的测试客户尝试付款时,我收到“No such payment_intent: 'pi_abc...zyx'”。我确保我在客户端和服务器上都使用了正确的私有测试密钥。我的关联账户是快速账户。当我转到我的 Stripe 仪表板查看“连接”下的“客户”选项卡时,我看到的是:

每次我尝试付款时都会创建一个空白条目。

以下是我目前正在采取的让平台客户支付关联帐户的步骤:

  1. 当客户首次在我的网站上注册时,我安装的 Stripe-firebase 扩展程序会自动生成一个客户 ID。这些现在被视为我的平台客户
  2. 我允许平台客户创建一个 Express Connected 帐户,这非常好用。我现在有了他们的 Stripe 帐户 ID,例如:'acct_abc...xyz`。
  3. 下面是平台客户尝试向关联账户付款时的流程:

React/Client Side - 仅使用测试密钥加载Stripe,而不使用 Stripe Connected 帐户 ID const stripePromise = loadStripe('pk_test_abc...');。我将此提供给<Elements stripe={stripePromise}>

React/客户端 - 用户填写付款表格并按下提交。从客户端/平台创建 paymentMethodReq:

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

节点/服务器端 - 客户端然后向我的服务器发出请求,尝试将平台支付方式克隆到已连接的帐户:

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

节点/服务器端 - 客户端然后向我的服务器发出请求以从平台创建/“克隆”新客户并将其链接到已连接的帐户

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

节点/服务器端 - 客户端然后向我的服务器发出请求,以使用与连接帐户相关联的客户 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 - 我尝试确认卡付款,结果出现“No such payment_intent: 'pi_abc...zyx'”错误

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

我尝试将客户端上的 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
});

这也会导致“No such payment_intent 'pi_3K...9Rx'”

如果有人能帮助我找出我在这个过程中哪里出了问题,那将不胜感激。谢谢

【问题讨论】:

    标签: node.js reactjs firebase stripe-payments


    【解决方案1】:

    该错误表明 PaymentIntent 属于另一个帐户,您当前的呼叫正在使用该帐户的密钥。可能是:

    1. 您在平台帐户上创建了 PaymentIntent,然后确认它 来自您的关联帐户
    2. 您在 Connected Account 上创建了 PaymentIntent,然后确认它 来自您的平台帐户

    虽然我看到 PaymentIntent 创建和确认调用均未使用 stripeAccount 参数,但我怀疑您在某处遗漏了代码,而 PaymentIntent 实际上是在您的关联帐户中创建的,导致上述第 2 种可能性。

    要调试此问题,您可以通过在仪表板的搜索框中搜索其 ID 来检查 PaymentIntent 属于哪个帐户,或者只需使用 ID 写信给 Stripe 支持,他们可以为您检查。

    【讨论】:

    • 所以我在确认付款意图时在服务器端添加了stripeAccount: connectedStripeAccountId 选项以及付款方式(这两种情况都发生在连接的帐户上,因为我传入了“stripeAccount”选项? ) 并且它似乎在客户端“工作”。但是,在 Stripe 仪表板中,Connected 帐户的客户下没有显示任何内容,只是另一个空白行,如上所示。当我检查日志时,我看到了200 OK,因此意图似乎实际上得到了确认,并且理所当然地需要捕获作为状态。不知道我在这里还缺少什么
    猜你喜欢
    • 2021-08-01
    • 2021-06-09
    • 2016-11-30
    • 2021-02-23
    • 1970-01-01
    • 1970-01-01
    • 2018-07-26
    • 2020-06-20
    • 2021-01-06
    相关资源
    最近更新 更多