为关联账户创建条纹费用 - 没有这样的客户
Create Stripe Charge for Connected Account - No Such Customer
我已成功设置客户付款方式,并且能够使用以下代码检索它们:
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 仪表板中找到客户。我也在那里看到客户的付款方式。
我做错了什么?
问题是客户存在于您的平台帐户中,而不是您尝试创建付款意向的连接帐户中。
在您的第一个代码片段中,您没有指定 stripeAccount
,因此 API 请求是在您的平台帐户上发出的。客户在那里,这就是为什么它按预期工作的原因。
在您的第二个代码片段中,您确实指定了 stripeAccount
,这意味着 API 请求是在指定的连接帐户上发出的,而不是您的平台帐户。你可以 read more about making API calls on connected accounts in Stripe's documentation.
要解决这种情况,您需要在您的平台帐户上创建支付意向作为 destination charge,或者在连接的帐户上创建客户对象以便在那里使用。
我已成功设置客户付款方式,并且能够使用以下代码检索它们:
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 仪表板中找到客户。我也在那里看到客户的付款方式。
我做错了什么?
问题是客户存在于您的平台帐户中,而不是您尝试创建付款意向的连接帐户中。
在您的第一个代码片段中,您没有指定 stripeAccount
,因此 API 请求是在您的平台帐户上发出的。客户在那里,这就是为什么它按预期工作的原因。
在您的第二个代码片段中,您确实指定了 stripeAccount
,这意味着 API 请求是在指定的连接帐户上发出的,而不是您的平台帐户。你可以 read more about making API calls on connected accounts in Stripe's documentation.
要解决这种情况,您需要在您的平台帐户上创建支付意向作为 destination charge,或者在连接的帐户上创建客户对象以便在那里使用。