#Heena
1 messages · Page 1 of 1 (latest)
i created payment form using stripe payment element
const paymentElement = elements.create('payment', {
fields: {
billingDetails: {
name : 'auto',
email : 'auto',
address: {
postalCode: 'auto'
}
}
}});
Hi, what's the question?
Please write in this thread, and not in the main channel, thanks!
Let me check
You need to add an Address Element: https://stripe.com/docs/elements/address-element
how ca i add with payment element ?
i added https://js.stripe.com/v3/
I did form using https://stripe.com/docs/js/element/payment_element
payment element also provide "postalCode" fields but in my form not display
You have elements.create('payment', ...)
You also need to add elements.create("address", ...): https://stripe.com/docs/elements/address-element/collect-addresses?platform=web&client=html#web-collect-address
Okay, 'auto' is default for billingDetails fields, could you set all the other ones to never please? https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-fields-billingDetails-address
payment element are different and address element are different
The issue is that the address element is in mode: "shipping"
But payment element specifies billingDetails
You need to set mode: "billing"
i tried ti billing
const addressElement = elements.create("address", {
mode: "billing",
});
is that ok ?
Yep, that will put the Element in billing mode
not working
But I'm not sure that will work as you need
We only collect the required billing details for the payment method type/customer location
my question is payment element provide postalcode
I guess in India postal code is not deemed necessary for payment conversion
So we don't collect it, you'd need to collect it separately
i did this site for UK
but payment element provide postalcode then why it not worked?
Yep, UK is one country where we do collect a postal code. As I said, it's determined on a per country basis
If you need the postal code I'd recommend collecting it via your own UI and passing on confirmation: https://stripe.com/docs/js/payment_intents/confirm_payment#confirm_payment_intent-options-confirmParams-payment_method_data-billing_details
ok
We try to collect a few details as possible required for the payment to succeed, in order to increase conversion: https://stripe.com/docs/disputes/prevention/verification#avs-check:~:text=Support for both,the United Kingdom.
const paymentElement = elements.create('payment', {
fields: {
billingDetails: {
name : 'auto',
email : 'auto',
address: {
postalCode: 'auto'
}
}
},
defaultValues: {
billingDetails: {
address: {
country: 'GB',
postalCode: '90005'
}
}
}
});
I did like this
and removed address element
I did it 🙂
Yeah, but if you switch country to India the postal code field will disappear
yes
As I said, the other address fields are determined by the billing country. In your original question you had India selected. So it was expected
yes right
i not know about it
can you please let me know that how can i display country and postal code fields in same line
I need same design like that screenshot
You can't
What's the question?
i need to display country and postal code in same line like above screenshot
The form is just responsive. I suspect that because your form is in narrow modal it collapses the fields onto separate lines. Make it wider and they'll be on the same line
no no
i need country and postal code in same line
see here
Not possible I'm afraid
ok
then why it display in above portal ?
in customer management page you can see in "Add payment method"
As I explained, because of the wider viewport. Shrink your browser and the fields will collapse onto their own rows