#piLLy

1 messages · Page 1 of 1 (latest)

native flickerBOT
odd quarry
#

Hi! Let me help you with this.

#

What would you validate in the Payment Element if you've selected Google Pay?

ionic copper
#

I'm trying to validate billing information and the payment element validity at the same time, then if they're both valid, continue on to create the intent and order on the server.

#

So for Google pay, nothing, but I just need a way to check if there are any errors on the payment element.

odd quarry
#

But why you don't want to open the PR if Google Pay was selected?

#

Do you just want to check if the form is valid?

ionic copper
#

I have my own billing fields that I want to validate at the same time as the payment element.

#

I was going to pass these in to the confirmPayment method

#

So when the user submits, I validate their billing information, validate the payment element has no errors, and then send the data to the server, create the intent and call confirmPayment using the billing information from the form

#

If there's a billing validation issue, the PR will still open

#

Is there a way to get the selected payment method from the payment element? Then I can check if there's actually anything to validate on the element

odd quarry
#

Can you validate your form before calling .submit()?

ionic copper
#

Sure, but then I'm validating the form before the payment element which just seems pretty bad UX

#

I'd like to show the form errors and the element errors at the same time

odd quarry
ionic copper
#

That's a different change event to the one you linked before, and it's for a different element I think?

odd quarry
#

It's the same

ionic copper
#

But it's for a card element?

#

There's no event.error

odd quarry
#

But you're using Payment Element right?

ionic copper
#

Yes

#

What did you mean when you said validate in real time? Like check the event.value if it's googlepay and not call .submit() ?

#

Sorry I got misunderstood because you linked two different change events which appear to have slightly different results

odd quarry
#

I meant you listen to events when the form input changes and check if the form is valid or not.

ionic copper
#

I can see the event.complete property now

odd quarry
#

Sorry for confusion.

ionic copper
#

Is there anyway to pull that at will instead of listening to the change event

#

paymentElement.complete or something

odd quarry
odd quarry
ionic copper
#

added via stripe

odd quarry
#

Definitely, this will simplify the situation.

#

Please, let me know if you have any other questions.