I am trying to charge already created customer but getting error " Cannot charge a customer that has no active card "
The card is already added too
Here is the node.js code I am using to charge the customer
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"
}
}
Any idea why I am getting this error?
You should check if the Customer has a default_source
, and set it using one of their saved cards if needed.
Even better, you should look at creating payment using a saved card with Payment Intents , and then the answer would be that you need to provide the payment_method
explicitly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.