#theruv

1 messages · Page 1 of 1 (latest)

icy tapirBOT
uneven ermine
#

👋 happy to help

#

would you mind elaborating on what you're trying to achieve exactly?

drifting vector
#

I'm initializing elements in the background, and when a user submits a form with their email, I reveal the payment elements. However I want to prefill the email that was just submitted so it doesn't need to be typed twice.

uneven ermine
#

there's no email input in Payment Elements

#

what are you refering to exactly?

drifting vector
#

Apologies, I'm using the linkAuthentication element to capture email

#

I can usually do this via elements.getElement("payment").update({
layout: "tabs",
defaultValues: {
billingDetails: {
email: document.getElementById("email").value,
},
},
paymentMethodOrder: ["card", "apple_pay", "google_pay"],
});

However, it is not consistently reliable. Sometimes, it doesn't work, leaving the linkAuth email field empty

uneven ermine
#

let me take a look if there's a way to this differently

drifting vector
#

Thank you

uneven ermine
drifting vector
#

One note: I only get access to my email after I initialize elements

uneven ermine
#

what's your constraints there?

drifting vector
#

Customer submits email -> they say payment form.

I'm trying to ensure paymentElement (hidden) is initialized before they submit (reveal pre-rendered payment form)

uneven ermine
#

that's not recommended though

#

only add the PaymentElement when necessary

drifting vector
#

I'm using defferedPaymentIntent method so it shouldn't have any negative impact. I usually only render the form when it's highly likely user will want to checkout. Is there a way to add email programatically?

uneven ermine
#

I'm using defferedPaymentIntent method so it shouldn't have any negative impact
regardless

#

we recommend creating and mounting the elements when needed

#

rather than pre-initializing them

drifting vector
#

Wouldn't this add a slight delay for the user? How would you solve for this?

uneven ermine
#

not really