#dovahkiin-paynow-modal

1 messages ยท Page 1 of 1 (latest)

blazing flowerBOT
ashen stump
#

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?

thorny rock
#

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

ashen stump
#

Gotcha.
Are you running this code locally or do you have a site live that I can visit?

thorny rock
#

I'm running it locally

ashen stump
#

can you try printing the client_secret before stripe.confirmPayNowPayment(...) is called and share what that looks like?

thorny rock
#

yes I can even provide it to you i just set it staticaly

ashen stump
#

sure

#

Also can you look into your network tab to see if there are any failed network requests there?

thorny rock
#

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

ashen stump
#

can you try adding a console log in the response block to see if you see the same error?

thorny rock
#

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

ashen stump
#

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

thorny rock
#

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

ashen stump
#

Quick question: how are you serving the HTML?
Are you running a server or just opening up the HTML file?

thorny rock
#

I tried both ways but on localhost, if you want I can try to host it quickly

ashen stump
#

Sure, let's give it a try

thorny rock
#

yes I can see the popup on your page !

ashen stump
#

Gotcha. So its mostly something in your code or browser.
Can you try using a different browser?

thorny rock
#

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 ?

ashen stump
#

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
        }
      });
})```
thorny rock
#

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

ashen stump
thorny rock
#

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

manic warren
#

@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

thorny rock
#

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 ^^

manic warren
#

okay so what's the problem?

#

Sorry the server is extremely busy right now with 14 other people all asking many questions