#wagamumma_best-practices

1 messages ยท Page 1 of 1 (latest)

rancid locustBOT
#

๐Ÿ‘‹ 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.

feral otter
#

๐Ÿ‘‹ happy to help

#

in that case why not just use the PaymentElements?

forest wadi
feral otter
forest wadi
#

is there any pci compliance issues changing to this method?

#

we like the embedded form because it covers pci compliance

feral otter
#

all of our integrations are PCI compliant

forest wadi
#

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?

feral otter
#

it's fairly simple, you can follow the guide I sent you

rancid locustBOT
forest wadi
#

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?

mint dagger
#

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

rancid locustBOT
forest wadi
mint dagger
#

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.

forest wadi
#

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?

mint dagger
forest wadi
#

but there it calls it server.php

#

sorry it's just a bit confusing compared to the embedded form documentation

mint dagger
#

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-session to 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.

forest wadi
#

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"

mint dagger
#

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.

forest wadi
#

why is that not shown in this doc though? is there an example project I could download as that would be easier

mint dagger
#

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.

forest wadi
#

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

mint dagger
#

let me know if I can help.