#dovahkiin-paynow-modal
1 messages ยท Page 1 of 1 (latest)
Hello ๐
That link isn't working for me, huh.
Lets chat here ๐
Can you bring me up to speed on what exactly you're having trouble with?
Sure let me copy the original message
Hey guys, I have some issues when trying to use paynow with stripe.
When I try to reproduce the example from the doc, a popup is supposed to open with a QR code to scan unfortuantely, it doesn't work on my side and I don't have any error the promise just resolve without doing anything (so it's not in success oviously).
Here the piece of code we use:
`<script src="https://js.stripe.com/v3/"></script>
<form id='payment-form'>
<input type="submit" value='OK'>
</form>
<script>
const client_secret = ''
var stripe = Stripe('');
var form = document.getElementById('payment-form');
form.addEventListener('submit', function(event) {
event.preventDefault();
// Set the clientSecret here you got in Step 2
stripe.confirmPayNowPayment(
client_secret,
).then((res) => {
if(res.paymentIntent.status === 'succeeded') {
// The user scanned the QR code
} else {
// The user closed the modal, cancelling payment
}
});
});
</script>`
This part unfortuantely, it doesn't work on my side and I don't have any error the promise just resolve without doing anything seemed unclear so what i meant is the popup does not even open
Gotcha.
Are you running this code locally or do you have a site live that I can visit?
I'm running it locally
can you try printing the client_secret before stripe.confirmPayNowPayment(...) is called and share what that looks like?
yes I can even provide it to you i just set it staticaly
sure
Also can you look into your network tab to see if there are any failed network requests there?
Here is an example client secret: pi_3LuGcrA3o3xjwbgW0ky9XONi_secret_Z2VkE9p79c0PPH6tztULvu6sQ
And no there is no error in networking except for the call to confirm the payment intent that will obviously not work because no popup has opened so no payment method has been attached
I do see an error on the confirmation though
https://dashboard.stripe.com/test/logs/req_hh9YLDqjG897bx
can you try adding a console log in the response block to see if you see the same error?
Yes indeed that's what I said in my previous message the confirmation is in error because there is no payment method attached, and there is no payment method attached because the popup that was supposed to attach one never opened ?
Indeed we have the same error in console if we log when resolving the promise
Interesting, I'm trying to reproduce on my end to see if I can trigger the same behavior.
Okay I see the QR modal right away with the code that you've shared thus far
Do you have any other code running besides what you've shared above?
dovahkiin-paynow-modal
no I wanted to make it as simple as possible so I just made this html and ran it ๐
Wait le me try to run it on my phone with mobile data to be sure it's not linked to a networking issue in my company's site
Quick question: how are you serving the HTML?
Are you running a server or just opening up the HTML file?
I tried both ways but on localhost, if you want I can try to host it quickly
Sure, let's give it a try
Also, can you try visiting this page and see if you're able to see a popup?
https://pale-chiseled-society.glitch.me/
yes I can see the popup on your page !
Gotcha. So its mostly something in your code or browser.
Can you try using a different browser?
well we tried a different browser on a different computer haha so I guess the issue is in the code. Would you mind sharing the code you used for the page you shared with me ?
I copied most your code ๐
hang on
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://js.stripe.com/v3/"></script>
<script defer src="script.js"> </script>
</head>
<body>
<form id="submit-form">
<input type="submit" value="Confirm Paynow">
</form>
</body>
</html>
script.js
const stripe = Stripe('pk_test_xxx')
const form = document.getElementById('submit-form');
form.addEventListener('submit', (e) =>{
e.preventDefault()
const pi = 'pi_xxx'
stripe.confirmPayNowPayment(
pi,
).then((res) => {
if(res.paymentIntent.status === 'succeeded') {
// The user scanned the QR code
} else {
// The user closed the modal, cancelling payment
}
});
})```
Well it didnt work for me but I guess that was to be expected since the code is similar. Would you mind if I share my public key with you and you test with it ? To check if maybe this is related to the strip account configuration or something like that
can you create a sample on https://replit.com/
It would be easier to take a look there
just sent you in private message
If it doesn't work for you too with my credentials at least we'll be sure the issue is linked to the account used
@thorny rock I'm taking over. Would be great to get actionable information here in public, that's why doing a quick repo is best here
yea I can forward it to you the reason I did not post it here is because it contains the public key and client secret we use ^^