我正在尝试向已创建的客户收费,但出现错误 “ 无法向没有有效卡的客户收费”
该卡也已经添加
这是我用来向客户收费的node.js代码
const response = await stripe.charges.create({
'amount': amount,
'currency': currency,
'description': title,
'customer': customer,
}, { idempotencyKey: onDemandId });
// What I am sending
{
"amount": "40",
"currency": "usd",
"description": "120 دقيقة",
"customer": "cus_I33Z2JrUSj1bBm"
}
// What I am getting
{
"error": {
"code": "missing",
"doc_url": "https://stripe.com/docs/error-codes/missing",
"message": "Cannot charge a customer that has no active card",
"param": "card",
"type": "card_error"
}
}
知道为什么我会收到此错误吗?
答案 0 :(得分:2)
您应该检查客户是否有default_source
,并在需要时使用set it使用one of their saved cards。
更好的是,您应该查看creating payment using a saved card with Payment Intents,然后答案是您需要明确提供payment_method
。