#PeterW-Source
1 messages · Page 1 of 1 (latest)
Hi there, Stripe will perform card validation when attaching card to a customer.
And that's why you encountered this error if there's insufficient funds in this card
Interesting, thanks Jack. But technically the card is still "valid" right - as in, I can own a perfectly valid bank card and yet have no money in it. And tomorrow, I can put money in the bank and buy a coffee with it.
It will say the card is active, but the moment you want to make charge on it it will fail.
Yes… that is what I would hope would be the behavior but that isn't what I'm seeing. Instead I cannot attach the card.
The use case is setting up a Subscription which will not invoice until 2-3 weeks later. I would expect to be able to attach the card and set up the subsciption, and only if the account is empty at the time of invoicing should there be an error arising.
Are you using SetuptIntent?
No, just the Sources and Subscriptions APIs. Does SetupIntent not have this issue?
OK, so you call the https://api.stripe.com/v1/payment_methods/:id/attach \ API to attach the source to your customer?
@zenith moth I just tried this in the Stripe Dashboard and it failed - using this test card - 4000000000009995. I assume the Dashboard uses the payment methods api
👋 Taking over from Jack
Dashboard doesn't use payment method API
It uses setup intent which has card validation
Thanks @reef salmon
Yeah so just tested this with the Payment Method API; same issue
I did
stripe payment_methods create --type=card -d "card[number]"=4000000000009995 -d "card[exp_month]"=6 -d "card[exp_year]"=2023 -d "card[cvc]"=314
then
stripe payment_methods attach pm_1L90MwKBXzfl9USoGw4PFO9s --customer=cus_LqhbIc7ZC4T9e9
and it returns
{
"error": {
"code": "card_declined",
"decline_code": "insufficient_funds",
"doc_url": "https://stripe.com/docs/error-codes/card-declined",
"message": "Your card has insufficient funds.",
"param": "",
"type": "card_error"
}
}
Yes, card validation can occur when attaching to the customer. You can pass validate:false when attaching to the customer, but we generally don't recommend it
Oh wow, is that documented somewhere?
Hmm, I've just tried stripe payment_methods attach pm_1L90MwKBXzfl9USoGw4PFO9s --validate=false --customer=cus_LqhbIc7ZC4T9e9 but it came back with unknown flag: --validate
I'm wondering if I'd need to use the REST api directly? It looks like this has come up in the past and Stripe didn't add it to developer-facing code: https://github.com/stripe/stripe-dotnet/issues/213
validate param is not documented as it's not recommended
are you using dotnet library?
No I just googled… I'm using NodeJS
(and testing with the stripe CLI because that's fast and easy)
most likely CLI doesn't expose the hidden param
let me check how to do it in NodeJS
this should work in Node:
const options = {
customer: 'cus_xxx',
validate: false,
};
const attached = await stripe.paymentMethods.attach('pm_xxx', options);
Amazing, thanks! Will give that a try.
Do you know if something similar works with the Sources API?
Nope! This only works for payment method attach API