#wagamumma_best-practices
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1332296839411662869
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
you can use the custom checkout instead of the embedded one https://docs.stripe.com/checkout/custom/quickstart
is there any pci compliance issues changing to this method?
we like the embedded form because it covers pci compliance
all of our integrations are PCI compliant
ok thank you, how easy is it to switch do i totally replace the checkout.js code with this? is there an example project i could download?
it's fairly simple, you can follow the guide I sent you
Set the SDK to use the custom_checkout_beta=v1 beta version header.
could you explain where this goes please? it doesnt seem to say where you would set this?
hi! I'm taking over this thread.
could you explain where this goes please? it doesnt seem to say where you would set this?
there's a code sample just below that shows exactly this
Hi thanks I see the code, it just doesn't say where it needs to go like all the other code snippets, I assume in the checkout.php file?
that completely depends on how you set things up on your end.
this code is to initialize Stripe, to allow you to create a Checkout Session just after.
ok but on that point, the next step says:
fetch('/create-checkout-session', {method: 'POST'})
but nowhere does it explain what /create-checkout-session is, is that mean to be the php page on our server again, or is it totally different?
we do explain it here: https://docs.stripe.com/checkout/custom/quickstart?server-lang=php#create-checkout-session
Add an endpoint on your server that creates a Checkout Session and returns its client secret to your front end.
but there it calls it server.php
sorry it's just a bit confusing compared to the embedded form documentation
but there it calls it server.php
yep, if you want to follow the documentation exactly:
- on your server, have a file called server.php that contains an endpoint to
/create-checkout-sessionto initialize Stripe and create a Checkout Session - on your frontend, make a fetch to that endpoint to retrieve the Checkout client secret
but if you don't want to use an endpoint, you could also directly create the Checkout Session when the page loads. that's up to you.
ok and does the server.php still need to echo json like with the embedded version? Because it doesn't show it is in the docs
but if i remove that line its saying "Uncaught (in promise) SyntaxError: JSON.parse: unexpected end of data at line 1 column 2 of the JSON data"
but if i leave it in its saying "Uncaught ReferenceError: clientSecret is not defined"
the /create-checkout-session needs to return the client secret as JSON yes. this way when you call fetch from the frontend, your can retrieve the secret.
why is that not shown in this doc though? is there an example project I could download as that would be easier
it is mentioned in the doc:
Add an endpoint on your server that creates a Checkout Session and returns its client secret to your front end.
but it's true we don't show the code for this. I can raise that as feedback to the team working on the documentation.
ok thanks, I will keep trying but it's just not working at all at the moment and I've copied every bit of the code from the docs, will try in a fresh environment and see if it helps
let me know if I can help.