#lucasnguyen1707

1 messages · Page 1 of 1 (latest)

flint rivetBOT
torpid pier
#

hello! How are you integrating with Stripe - Payment Element, Checkout Session, or...?

minor meadow
#

Here's a popup I wanna prevent to open if the Payment form doesn't match some conditions

#

I'm using Prebuit element of Stripe

#

and using element called Payment Element

torpid pier
#

alright, can you elaborate more on what conditions do you want to check for - can you give some examples?

minor meadow
#

such as case a user needs to check the checkbox of our policy before processing the Payment

#

for now, even user don't check the box, the Apple popup still open

torpid pier
#

hmmmm, I can't think of a way to prevent the payment sheet from displaying if you're using Apple Pay or Google Pay in the Payment Element. You can probably prevent the payment from being made but not prevent the payment sheet itself from displaying first. So the user would try to make payment and it would fail.

You could consider a separate element for Google Pay and Apple Pay where you can control when to display the payment sheet instead

minor meadow
#

So how I do a separate

flint rivetBOT
smoky crater
#

đź‘‹ Taking over here and to clarify, the sheet displays when you push the "Pay" button, correct?

minor meadow
#

Exactly

smoky crater
#

When that happens, can't you catch the timing in the submit event? There you can preventDefaults() if some conditions is not met

minor meadow
#

I Already set The preventDefault(), all other flow work correct, and not process payment flow.

Just one exception that the Apple Pay popup still try to open

smoky crater
#

If you put a breakpoint there and a console.log, how does it behave when you click the button?

minor meadow
#

I set the preventDefault and after that call “return” command to exit my HandlePayment function

#

It works and run the return

#

But after that

#

Apple Pay popup appears

smoky crater
#

I see. I believe that's because Apple/Google is not happy to let anything injected on their sheets. Have heard that in the past

#

Okie then as my colleague said, you probably want to completely separate and hide the PaymentElement before your checkbox is checked