#nikolakg80

1 messages ยท Page 1 of 1 (latest)

vivid sorrelBOT
fiery thorn
#

Hi ๐Ÿ‘‹

I can't see that fiddle (502 error) but what did you do, what did you test?

wispy beacon
#

I tried to call this:
<button type="button" onclick="elements.submit(); submitForm(event)">
In general, elements variable inside onclick handler represents the collection of form elements, so this code didn't work...

<html>
<head>
<title>Test for elements variable inside onclick handler for submit button</title>
</head>
<body>

<form action="test">
<input type="text" name="temp" value="Test value">
<input type="submit" onclick="console.log(elements); event.preventDefault()">
</form>

<h1>Test for elements variable inside onclick handler for submit button</h1>

</body>
</html>```
#

I solved it by using another variable for stripe elements... Might be useful for someone else

fiery thorn
#

Okay so your problem is solved?

wispy beacon
#

Not entirely. It is moved to another place

#

I'm having issue with deferred payments

#

And Google Pay

#

So, when I click on the submit button, I create the Payment Intent in the background

#

And I get this:
Uncaught DOMException: Failed to execute 'postMessage' on 'Window': Delegation is not allowed without transient user activation.

fiery thorn
#

Okay that isn't something being returned by Stripe.js so I'm not sure what is going on there

wispy beacon
#

It actually is:

    at l (https://js.stripe.com/v3/:1:122840)
    at t.value (https://js.stripe.com/v3/:1:39017)
    at t.value (https://js.stripe.com/v3/:1:38452)
    at e.show (https://js.stripe.com/v3/:1:485262)
    at t.<anonymous> (https://js.stripe.com/v3/:1:511739)
    at t.show (https://js.stripe.com/v3/:1:65863)
    at https://js.stripe.com/v3/:1:198420
    at https://js.stripe.com/v3/:1:60912
    at Array.forEach (<anonymous>)
    at t._emit (https://js.stripe.com/v3/:1:60655)```
fiery thorn
#

Okay, what is the code that is throwing this error?

wispy beacon
#

    if (!clientSecret) {
        return false;
    }

    let result = await stripe.confirmPayment({ 
        clientSecret,
        elements: paymentElements,
        redirect: 'if_required'
    });
#

Before that I have paymentElements.submit()

fiery thorn
#

Is that in response to a user triggered action?

wispy beacon
#

It is:
<button type="button" onclick="paymentElements.submit(); submitForm(event)">

fiery thorn
#

And what flow are you following?

wispy beacon
fiery thorn
#

and where is the postMessage function being called?

wispy beacon
#

I didn't call that... It has to do with the time taken between user pressing the button and element.submit(), or stripe.confirmPayment

fiery thorn
#

How long of a gap do you have?

wispy beacon
#

Less than a second I would say

#

Although I didn't have the await part

#

It seems like it's working now

fiery thorn
#

Great ๐ŸŽ‰

wispy beacon
#

Thanks