【问题标题】:Create Stripe Charge for Connected Account - No Such Customer为关联账户创建条带费用 - 无此类客户
【发布时间】:2021-03-18 19:16:16
【问题描述】:

我已成功设置客户付款方式,并且能够使用以下代码检索它们:

return stripe.paymentMethods
       .list({ customer: customerId, type: 'card' })
       .then((cards) => {
            if (cards) {
               return { cards: cards.data, error: null };
            }
            return {
               error: 'Error creating client intent',
               cards: null,
             };
        })
        .catch((e) => {
           console.log(e);
           return { cards: null, error: 'Error fetching user cards' };
        });

我现在正在尝试创建一个直接的PaymentIntent,它将付款路由到一个Stripe Connect 关联帐户。

为此,我正在运行以下代码:

if (cards && cards.cards && cards.cards.length > 0) {
   const card = cards.cards[0];

   const paymentIntent = await stripe.paymentIntents.create(
    {
        amount: amount,
        customer: card.customer,
        receipt_email: userEmail,
        currency,
        metadata: {
            amount,
            paymentMode: chargeType,
            orderId,
        },
        description:
            'My First Test Charge (created for API docs)',
        application_fee_amount: 0,
    },
    {
        stripeAccount: vendorStripeAccount,
    }
);
const confirmedPaymentIntent = await stripe.paymentIntents.confirm(
    paymentIntent.id,
    { payment_method: card.id }
);

这给了我“没有这样的客户”错误,即使客户 ID 已定义并且我可以在我的 Stripe 仪表板中找到该客户。我还在那里看到了客户的付款方式。

我做错了什么?

【问题讨论】:

    标签: javascript node.js stripe-payments


    【解决方案1】:

    问题是客户存在于您的平台帐户中,而不是您尝试在其上创建付款意图的关联帐户。

    在您的第一个代码 sn-p 中,您没有指定 stripeAccount,因此 API 请求是在您的平台帐户上发出的。客户在那里,这就是为什么它可以按预期工作。

    在您的第二个代码 sn-p 中,您确实指定了 stripeAccount,这意味着 API 请求是在指定的连接帐户上发出的,而不是您的平台帐户。你可以read more about making API calls on connected accounts in Stripe's documentation

    要解决这种情况,您需要在您的平台帐户上将支付意图创建为destination charge,或者在连接的帐户上创建客户对象,以便在那里使用它。

    【讨论】:

    • 感谢贾斯汀的解释 - 我的目标是将客户及其付款方式存储在我的帐户中,当客户尝试向其中一个连接的帐户付款时,检索他们的付款信息并用它来处理费用——这样我就不会在每一个 conn 上存储客户的付款方式。他们与之互动的帐户,但在我的帐户上只有一次。
    • 啊,那你可能会对cloning Payment Methods感兴趣。
    猜你喜欢
    • 2021-09-11
    • 1970-01-01
    • 2018-06-22
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 2020-06-20
    • 2021-02-23
    • 1970-01-01
    相关资源
    最近更新 更多