#linas-invoice-revision
1 messages · Page 1 of 1 (latest)
thanks I'll get the docs fixed, but mostly it's just a normal create with those parameters
Great to hear! Let us know if you have any other questions
One more question about JS part :
// Create and mount the Address Element in billing mode
const addressElement = elements.create("address", {
mode: "billing",
defaultValues: {
name: 'Your Full Name...',
address: {
// line1: 'Address...',
city: 'City...',
state: 'CA',
postal_code: '',
country: 'US',
},
},
fields: {
phone: 'always',
},
validation: {
phone: {
required: 'always',
},
},
});
I was reading in documentation, that it is possible to hide adress1 or any unwanted field.
But i cannot find again
Gotcha, looking in to this
For the address element, it actually looks like we only currently support hiding the phone number field https://stripe.com/docs/js/elements_object/create_address_element#address_element_create-options-fields
Are you using this with the Payment Element? It looks like that element has the ability to hide these fields, I am wondering if hiding them on that element will actually hide them on the Address Element if it is on the same page. https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-fields-billingDetails-address-line1
Might be worth testing to see if that works though obviously that is a bit of a roundabout way of doing it. I will add feedback to allow this through the address element itself
I used like this:
const paymentElement = elements.create("payment", paymentElementOptions);
paymentElement.mount("#payment-element");
// Create and mount the Address Element in billing mode
const addressElement = elements.create("address", {
mode: "billing",
defaultValues: {
name: 'Your Full Name...',
/* address: {
line1: 'Address...',
city: 'City...',
state: 'CA',
postal_code: '',
country: 'US',
},*/
},
fields: {
phone: 'always',
},
validation: {
phone: {
required: 'always',
},
},
});
addressElement.mount("#address-element");
If i comment out this part:
address: {
line1: 'Address...',
city: 'City...',
state: 'CA',
postal_code: '',
country: 'US',
},
it hides me some fields, but somehow it also hides me a phone number.
Interesting, so they will show when you provide default values but are otherwise hidden?
Ah, do you want to hide these fields because you already have the user's address?
I assumed your use case was hiding them to present your own custom address form. If you have the details already, you may want to just pass them in to the billingDetails hash when confirming the payment
i want to hide just a few and others show.
i have jsut tried different approach:
const paymentElementOptions = {
layout: "tabs",
billingDetails: {
phone: "never",
email: "never",
}
};
const paymentElement = elements.create("payment", paymentElementOptions);
to use Only payments. But phone field is not shown.
Actually, i changed "never" to "auto"
Ah, that may be because the specific payment method you are working with doesn't require a phone number.
As you noted, we currently have never and auto as options now but we don't have always at the moment.
To have something always show, we actually recommend setting it to never and displaying your own input field for it.
Then i'm forced to use "addressElement" instead of paymentElement.
But then it is displaying too many fields. and i'm not able to hide.. 😄
For now, I don't think we have a Stripe.js Element that will always collect the phone number like that. You may have to code your own custom phone number field here.
@teal prawn did you have more questions?