#Naveed-VueJS
1 messages ยท Page 1 of 1 (latest)
perhaps this has some hints https://stripe.com/docs/js/element/mount
It mentions:
"If the container DOM element has a label, the Element is automatically focused when its label is clicked"
Perhaps I can listen for the focus event
Or perhaps I need to rethink my entire approach. Perhaps I need to use stripe elements on a per-field basis? Maybe not using PaymentElement?
Is there something like that?
i need to collect this information btw. so not just country
hmmm much better!
Still seeing the same screen recording ๐
We do collect billing detail, but in an "automatic" way. See here: https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-fields-billingDetails
never or auto. Payment Element will detect by itself and collect if it think it should
So if you want to force collecting some info, then yes you might need an additional form, then pass as defaultValue when you create the PaymentElement https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-defaultValues
so what does auto do, based on what does it make the decision to collect
it might be at odds with business requirements right
It's a detection engine, all I can say is it may look at customer location/ip and all the obligation/regulation we need to follow as a Payment processor
For example if the customer is in some countries, we know those countries regulation requires additional address etc
The idea is we take care of that, you don't need to
okay interesting so the default is 'auto' am i right?
yes
so if thats the case then the form that gets loaded is dynamic
which means that if i were to add billing fields on my own
potentially id come across a situation where there are duplicate fields for billing address
unless i specify never that is...
if you collect on your own, then:
- You pass the collected info in
defaultValueswhen creating Element - You set the corresponding fields as
never
Dont understand this part
- You pass the collected info in defaultValues when creating Element
the element being created is to collect customer info, at that point in time i have no collected info
so u mean i can initialise with null?
Oh this is prefilling
initialise billing fields with null or something?
Sorry disregard step 2. Step 1 is enough for prefilling
hm i dont get it why do i need to prefill
Because you already have your form right? I see
my form is basically a combination of Stripe + my own button + my own address fields
of course ideally all the form inputs are from Stripe
i havent added the address fields yet
so ignore that for now
itll be annoying becaus i need to match the UI of stripe for the form
But you have plan to add your own address fields, correct?
yep
Let's forget about prefilling. Collect address via your own address fields, disabling Stripe's Payment Element with never, then pass the information you collected in confirmation call
This part
If you disable the collection of a certain field with the fields option, you must pass that same data to stripe.confirmPayment or the payment will be rejected.
๐ okay I will try this out