#hamidhh
1 messages · Page 1 of 1 (latest)
Do you have a custom csp deployed ?
You probably need to add these directives :
https://stripe.com/docs/security/guide#content-security-policy
How can I do that?
In fact, I just added the stripe link like the below
<script src="https://js.stripe.com/v3/"></script>
Can you try to download this sample project and run it ?
https://stripe.com/docs/payments/quickstart?client=html&platform=web&lang=node
Indeed, my project is like this project
You are facing the issue in your localhost or in a server.
both
Can you share a screenshot
but it looks like you have something in your network that is blocking some CSP
I'm trying to do that, but DC has problem!
Are you using a Campany network ?
No, it's my home intenrnet
Can I send the screenshot in another place for you like whatsapp
Dc has problem
Okay
I have the same errors!
Btw just something came up to my mind!
In my project when I'm pressing pay now button nothing happen!
It seems the payment button take no action
You need to share with us some screenshots.
to be clear, is it causing any actual issue in using the Element or making a payment?
that's normal, it just means you have an adblocker(it blocks those requests to r.stripe.com, which we use to track usage metrics).
I didn't get your meaning exactly, but previously that pay now button functioned it always throw errors for me like something went wrong!
I was using test card 4242 4242 4242 4242 for my tests!
But now it does nothing!
have you checked that "undefined is not valid JSON" error?
looks like something in your own code
No it's because of one my extentions, it exist on other pages and they are working like a charm!
I even tried to use stripe locally like this
<script src="assets/stripe-v3.js"></script>
but it didn't work! I got the same errors
This is another error that I just got
what's the req_xxxx ID in that screenshot, paste it here
I just refreshed and I don't get that error, sorry
Btw I a have and 403 error for this url https://pay.google.com/gp/p/js/pay.js
is that okay or what?
that's part of Google Pay, and it might not be a problem. I'd focus on if the page is actually working or not; there can be random errors in the browser console but it doesn't matter if the page actually works.
I see
So you mean even if we have these errors on the console the payment process must fulfil
if it works it works
I fixed it but there is an error
go on.
Payment can't complete
This is request url
https://api.stripe.com/v1/payment_intents/pi_3NGIs4LDI5581HGc0kU88x86/confirm
it's because you pass return_url: "localhost/result/success", which is not a valid URL
This error is showing under form for seconds!
An unexpected error occurred.
try for example return_url: "http://localhost/result/success", instead
so what would be correct?
if you read the error message it tells you
An explicit scheme (such as https) must be provided.",
I'm checking
Thank you, it fixed
I have another question which is final one
When the payment form wants to render it takes some seconds like 20-30 seconds, during this time pay now button is active and users can press it, is there any way to disabled it till the form get loaded completely
it should not be taking 20 seconds
but yes, you can disable your pay button until this event triggers : https://stripe.com/docs/js/element/events/on_ready
I added this to checkout.js file but it's not working!
document.querySelector("#payment-form")?.on("ready", function (event) {
// Handle ready event
document
.querySelector("#payment-form")
.addEventListener("submit", handleSubmit);
});
document.querySelector("#payment-form") is not what you should put the listener on
you put it on the Elements instance, per the docs I shared
so if you have var elements = stripe.elements(....), it's elements.on('ready', function(){....})
So it should be like this
const paymentElement = elements.create("payment", paymentElementOptions);
paymentElement.mount("#payment-element");
paymentElement.on("ready", function (event) {
// Handle ready event
debugger;
document
.querySelector("#payment-form")
.addEventListener("submit", handleSubmit);
});
I think so yes, try it
Thank you so much