【发布时间】: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