#maxwell-paymentelement-email
1 messages ยท Page 1 of 1 (latest)
Hello ๐
PaymentElement collects email automatically for the PaymentMethods that need it.
If you want to mandate email collection for each payment, you can just add in your own textfield and pass the email as part of confirmParams.payment_method_data.billing_details when you make the confirmPayment call
https://stripe.com/docs/js/payment_intents/confirm_payment#confirm_payment_intent-options-confirmParams-payment_method_data-billing_details
Thanks for your reply. If I use my own text field how would I add data validation so the the email field is consistent with the rest of the form?
maxwell-paymentelement-email
@neat fractal if you do your own field you would do your own validation
Trying to accurately mimic Stripe's validation styling that is in the rest of the form doesn't seem like a realistic approach. What alternatives are there? Collecting an email address along with a shipping address and payment details should be an extremely common use case, it feels like there should be a supported way to do this?
Sure but there isn't right now
It's something we want to offer in the future, just hasn't been built yet
So what are my options? Meticuously recreating stripes validation styling for an email text input is not realistic. Is there really not not a way I can force stripe to add an email field? The only solution I can think of is using the prebuilt checkout, but it doesn't fit my usecase.
I'm sorry I don't understand what you call "recreating stripes validation styling". It's an email field, you control it, you can style it the same way you style the rest of PaymentElement
For example, if you enter a card number with the incorrect number of digits, red text and a little red icon will appear telling you what is wrong. I would need to recreate that for the email field to validate it is in the correct format, eg contains an @ symbol etc.
Gotcha, then yes you have to do that yourself
Like I said before, that's not a realistic approach, what other options do I have?
That is the only option, that's what everyone else does
I don't believe that is true, that kind of approach is considered really bad practice for software development. Do you have any colleagues who might have some ideas?
There is no other solution. You already talked to a colleague of mine. I also just asked the lead on my team who said the exact same thing. You have to build this yourself
This video seems to show a custom checkout with an email field. Do you know how this is achieved? https://www.youtube.com/watch?v=hzWo7J5t_Wc&t=483s
which part? It's a 9 minutes video
right at the beginning (about 10 seconds in) they show a checkout form using custom elements which has an email field.
ah cool, you had linked to almost the end of the video
but yeah this is basically their own email field really
sorry
look at 1:02
I think it's the LinkAuthenticationElement
https://stripe.com/docs/js/element/link_authentication_element but it's specific to Link
and it's unlikely to be what you want ๐ฆ
Ah, ok yeah I just saw that it is using Link. Can link just be used to collect an email address or does the user have to sign up for Link? I'm thinking using Link is a better option than having to code my own email element.
It's specific to Link and not really relevant in PaymentElement because we're embedding this for you for Link but only for customers who want to use Link
So really I would still say my answer is exactly the same as earlier. I know you don't want this answer but sadly this is the way today
Ok, thanks for your help. Given it is all open source I'm going to see if I can find the styling and validation code so I can just copy it.
I did push for your feature request internally. My team has asked for it a lot because you're definitely not the only person who wants this