#Valma

1 messages · Page 1 of 1 (latest)

pliant spadeBOT
leaden fog
#

What's the issue?

royal mortar
#

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 ?

leaden fog
pliant spadeBOT
royal mortar
#

That doesn't really help, there's no js files and no fetching

tulip merlin
#

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

royal mortar
#
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

royal mortar
#

Alright thanks