#mrjoozy - react client and server
1 messages · Page 1 of 1 (latest)
hey there, this is a fairly common set up when running react applications with a server/backend component
that server typically runs listening on another port and needs to be proxied for front end access
is your server running?
i think so?
ok and what do you get if you access that on port 5000 instead of 3000?
since that's where you have it listening
that endpoint is defined for POST, not GET
can you take off the create-checkout-session and try just localhost:3000/
That should get you the static front end, the session create post endpoint in for the backend call made by the client
u mean in the web url of chrome right like my pic above
ok looks like progress!
that seems like teh right front end, then the client code makes the post request to get the checkout session
yup when i click the button this is the code that handles the checkout button
this is the result of clicking the button
Our example uses port 4242 for the back end. Did you grab this example from here: https://stripe.com/docs/checkout/quickstart ?
And then you changed the port in the server.js file?
yup
OK did you also change the port in the proxy line in package.json?
just did that
ah wait ok mybad i used https instead of http for localhost. it works now
thanks m8 much appreciated
NP!
actually i have one more question, after a successful stripe payment, is there a way to keep a customers email and send them a e receipt of some sorts? also can it be a custom email where i send them instructions on how to use the product they have bought
You dashboard settings allow you to set up automatic receipt emails if preferred, otherwise you can inspect the customer email after the checkout session completes (eg, using webhooks) and create/send your own custom receipt.
is there a way to get their emails programmatically? like if i want to store their email to also keep logs of who bought what
Yep you can get that from the customer that you can retrieve following receiving a checkout.session.completed event:
https://stripe.com/docs/payments/checkout/fulfill-orders#handle-the-event
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.