#mayadelasriveras - testing PHP quickstart
1 messages · Page 1 of 1 (latest)
Hi there 👋 which payment front are you talking about? What are you hoping to do?
Alright, and where are you running into a blockage?
when I download all the code and run it on my test localhost
It only shows me the payment button, it does not show me the entire screen to enter the card data.
What happens when you click the button?
nothing I can not enter data because the form does not appear all only the payment button
Does your code deviate at all from the tutorial you posted?
it is not the same just change the names to spanish
Can you post all the relevant code here?
i create stripe.php, index, stripe.js and stripe.cscs
Please don't post code that has your API keys in them. Can you redact them and copy/paste again?
my code is the same as the one on the page https://stripe.com/docs/payments/quickstart
What are the exact file names you're using?
create.php es stripe.php, pago. html es index.html, checkout.js es stripe.js y checkout.css es stripe.css
this is my name of file
i need snow what is the problems in this tutorial
If your code is identical to the code we give you in those docs, then the file names will need to be identical as well. Otherwise there's no way for the code to know where to look for the resources it needs.
Excuse me, the js gives me a syntax error when I do my test on my local host, I tried them, it works
Okay, and what is the syntax error?
this is when i run it on my localhost and inspect it
this is the screen you should see
Can you add some logging to your code to see how for it gets / where exactly its failing?
I don't know how to do it because I can't enter the card data
I insist this is the code of the tutorial example or the one predesigned by you
probando con los mismos nombres
I understand, but I need to more about where exactly its failing. Looking at the screenshot you shared, it appears stripe.js is failing during initialization. Did you provide your publishable key?
Where is that 500 error coming from? You'll need to inspect the running code a little more closely I'm afraid, in order fr me to help you through this.
Can you explain what you did to run the code?
just put my api key and try it from my localhost
Did you run the code with a local PHP webserver?
As we show in step 5: php -S 127.0.0.1:4242 --docroot=public
It's not expected that you open the php files directly with the browser
not with my appserve
and as I try it then in the previous version I did the same and it opens perfectly
this was my old test until i change the upload form for card data
What do you mean previous version?
the payment front before this
Hey, I need it to open up and let me load the cards and allow me to continue with the integration. Can you help me to make the front end work?
That's what i'm trying to do, but the code is designed to be run with the PHP web server, then the client side makes requests to the backend
mayadelasriveras - testing PHP quickstart
OK, can you share the network request that failed?
It looks like the client got a 404 error back from trying to call /create.php
ok but how can I correct that 404 error I can't believe this is the same code the same files and it gives me an error
// Fetches a payment intent and captures the client secret
async function initialize() {
const { clientSecret } = await fetch("/create.php", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ items }),
}).then((r) => r.json());
the error is here
there
OK, great! And it looks like that fails due to a 404 on the /create.php call
If you try to curl that url, what do you get?
in your browser dev tools you can right click the failing network request and choose ot copy as curl, which you can paste in your command line
or import into postman or similar HTTP testing tool
how do i do it please
It seems like that endpoint might not be running
I'm trying to explain that
If that URL is public, can you share it here?
It is public, but the error is stripe since it is its payment integration model.
how do you
You're going to need to debug some more of this yourself, to be honest. We can certainly help guide you, but you need to be able to perform test requests and share logs from your PHP server to help investigate on your side.
My guess is that the webserver is not properly running the code to host the create.php endpoint, for some reason
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</body></html>
ok thank for you help
For example, when you put the PHP files on your server, did you ensure the stripe-php library was installed with composer like the guide you linked to suggested?
And you should double check how these files are being served, you need to ensure that the create.php endpoint is accessible/reachable for requests
Failed to load resource: the server responded with a status of 500 ()
last question and this error
OK thats good! that means your server tried to do something and crashed! Crashes mean errors and we can fix errors. I would suggest seeing if you can access logs for the server, or add some logging, or simplify the endpoint and gradually add things back to get the Payment Intent creation.
Best guesses would be:
- stripe library not installed
- composer not set up to load the vendor init file correctly
- incompatible PHP versions if the server is using an old PHP version