#PeterW-Source

1 messages · Page 1 of 1 (latest)

zenith moth
#

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

lyric saffron
#

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.

zenith moth
#

It will say the card is active, but the moment you want to make charge on it it will fail.

lyric saffron
#

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.

zenith moth
#

Are you using SetuptIntent?

lyric saffron
#

No, just the Sources and Subscriptions APIs. Does SetupIntent not have this issue?

zenith moth
#

OK, so you call the https://api.stripe.com/v1/payment_methods/:id/attach \ API to attach the source to your customer?

lyric saffron
#

@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

reef salmon
#

👋 Taking over from Jack

#

Dashboard doesn't use payment method API

#

It uses setup intent which has card validation

lyric saffron
#

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"
  }
}
reef salmon
#

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

lyric saffron
#

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

reef salmon
#

validate param is not documented as it's not recommended

#

are you using dotnet library?

lyric saffron
#

No I just googled… I'm using NodeJS

#

(and testing with the stripe CLI because that's fast and easy)

reef salmon
#

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);
lyric saffron
#

Amazing, thanks! Will give that a try.

#

Do you know if something similar works with the Sources API?

reef salmon
#

Nope! This only works for payment method attach API