#Valma
1 messages · Page 1 of 1 (latest)
What's the issue?
So I'm using a php server to make the stripe session request
But I need to send some data from my js file who is fetching the php server to my php file who is creating the session is that possible ?
Sure, should be. There's an example of this in our quickstart: https://stripe.com/docs/checkout/quickstart?lang=php
That doesn't really help, there's no js files and no fetching
was there a specific part you had trouble with? You can adapt things as you need, for example as you mention, instead of using a <form action> you might want to add an event listener for submit instead, and use fetch to call your backend and get back the Session ID, there are many ways to integrate
button.addEventListener("click", (e) => {
checkoutURL = "";
e.preventDefault();
fetch("../server/checkout.php", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"user": "Mike",
"color": "Red",
"age": "26"
})
}).then(res => res.json())
.then(payload => {
stripe.redirectToCheckout({ sessionId: payload.id });
})
})```
That's the script I use
And I want to access the body values in my checkout.php
Alright thanks