#k1ng
1 messages · Page 1 of 1 (latest)
Hello there
I believe you are asking about prefilling the email in Payment Element, correct?
Gotcha then yeah you can set defaultValues when you create/render Payment Element: https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-defaultValues-billingDetails-email
i added it but its still not showing up
const defaultValues = {
billingDetails : {
email: userdata.email,
}
}
const options = {
clientSecret,
appearance,
defaultValues,
};
Can you provide a screenshot of what you see?
Okay that's because Payment Element doesn't require Email for Card payments. So that Email form is either your own Email form or you are potentially using Address Element as well?
<LinkAuthenticationElement
id="link-authentication-element"
onChange={(e) => setEmail(e.target.value)}
/>
this thing
is it necessary?
Ah
It isn't necessary, but it is recommended as it is an easy way for your customers to checkout
It is a quick way for customers to store and re-use PaymentMethods across Stripe merchants.
But if you are prefilling email as you are doing above then that should be enough...
Have you logged out userdata.email to make sure that is initialized correctly?
I'd recommend trying to hardcode an email to start with
const appearance = {
theme: 'stripe',
};
const defaultValues = {
billingDetails : {
email: "lol@gmail.com",
}
}
const options = {
clientSecret,
appearance,
defaultValues,
};
still not prefilled
Are you passing appearance to the function where you initialize the Element?
From the docs:
const CheckoutPage = ({clientSecret}) => ( <Elements stripe={stripe} options={{clientSecret, appearance}}> <CheckoutForm /> </Elements> );
<Elements options={options} stripe={stripePromise}>
<CheckoutForm />
</Elements>
looks more like this
Where did you get that specific code? Did you modify it from the docs you got from Bismarck?
followed this exactly
Did you follow this specific step?
https://stripe.com/docs/payments/quickstart#style
You have to pass the appearance object to the options object. That options object then gets passed when you initialize Elements
Give me a few minutes to test the defaultValues on my end
Okay, circling back to default values. Where are you expecting to see those populate?
just the email
@neon dome i want email to be prefilled
i think it has something to do with link authentication element, because that handles the email
but options aren't passed into it
Can you send me a screenshot of what you're seeing and where you're expecting it to show up?
Is there a line you're including somewhere to force the Payment Element to show an email field?
<LinkAuthenticationElement
id="link-authentication-element"
onChange={(e) => setEmail(e.target.value)}
/>
its this thing
if i remove it the email element disappears
@neon dome
got it, thanks. Still digging
Okay, this is going to take more time than I can provide in a live chat environment. Can you create an email support thread and mention two-shoes in the text body somewhere? This will allow me to pick it up and respond via email.
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
Okay, I'll grab it and try to follow up as soon as I can
Can you DM me your email?
Or rather, the email of the account you signed into to send it?