#nikolakg80
1 messages ยท Page 1 of 1 (latest)
Hi ๐
I can't see that fiddle (502 error) but what did you do, what did you test?
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
Okay so your problem is solved?
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.
Okay that isn't something being returned by Stripe.js so I'm not sure what is going on there
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)```
Okay, what is the code that is throwing this error?
if (!clientSecret) {
return false;
}
let result = await stripe.confirmPayment({
clientSecret,
elements: paymentElements,
redirect: 'if_required'
});
Before that I have paymentElements.submit()
Is that in response to a user triggered action?
It is:
<button type="button" onclick="paymentElements.submit(); submitForm(event)">
And what flow are you following?
and where is the postMessage function being called?
Does your entire submit function look like the code snippet here: https://stripe.com/docs/payments/accept-a-payment-deferred?platform=web&type=payment#submit-the-payment
I didn't call that... It has to do with the time taken between user pressing the button and element.submit(), or stripe.confirmPayment
How long of a gap do you have?
Less than a second I would say
Although I didn't have the await part
It seems like it's working now
Great ๐
Thanks