#mattwoberts - card validation
1 messages ยท Page 1 of 1 (latest)
Hi there! Pasting your other message here:
I've got a pm if that helps -> pm_0Lae2oEHSdXPilfDdBIArv0f
I think that's normal, since Stripe will not do the card validation when creating the Payment Method. It should happen when you attach the Payment Method to a customer.
Can you clarify what is your payment flow and what are you trying to achieve?
Yeah sure - so the scenario is that someone is entering a card for LATER payment.
So they use our web app and enter a card, and using the JS lib we call into stripe (in this flow we're calling createPaymentMethod to create a new payment method)
Stripe confirms, we tell the user that all is OK and they can go and do something else.
Then, behind the scenes we attach that card to a customer, and we may take a payment if we deem that one is needed - this can then fail, but the customer is offline, so we can't inform them
I was sure that the JS lib would validate that the card is valid?
in this flow we're calling createPaymentMethod to create a new payment method
I would recommend to use this instead: https://stripe.com/docs/payments/save-and-reuse?platform=web
This is the recommended flow, and it will automatically attach the payment method to the customer to validate the payment method
Hmm, thing is, we've been using this flow for many years, and it's mostly working. It's just lately we're getting some tickets from customers telling us that the card is accepted but then they still get failed payment messages.... I'm not opposed to changing the flow but has something changed to make this a thing?
I just looked into this some more from our side...
It's just lately we're getting some tickets from customers telling us that the card is accepted but then they still get failed payment messages....
This can always happen, right? Like once you try to make a payment, it's completely up to the bank to accept/decline the payment. So that's something that your integration needs to manage anyways.
but has something changed to make this a thing?
No I don't think so. Another option would be to directly attach the PaymentMethod to the customer to see if it generates an error.
The flow that seems to be causing this is when the customer is "locked" out of our app. In order to continue, they need to enter a card, which we will use to create a new subscription, and then take payment immediately. So perhaps we need to rethink this flow
If you need a PaymentMethod to start a subscription, then the correct flow should be:
- Create the subscription on the backend and retrieve the
latest_invoice.payment_intent.client_secretfrom the subscription - Use the
client_secreton the front-end to collect the payment information and start the subscription
You can learn more about this here: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements
Or even better, use a Checkout Session that does everything for you: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=checkout
Ok thanks for this. So just to confirm - it's normal for a card to be accepted via createPaymentMethod, even if the card number is invalid?
There are some basic checks that are made by createPaymentMethod, like the luhn check (https://www.tokenex.com/blog/ab-what-is-a-luhn-check). However to check if the number is correct Stripe needs to talk to a bank. And this usually happen when the card is attached to a customer (not when calling createPaymentMethod).
Thanks again, appreciate your help here ๐
Happy to help ๐