This sample shows how to build a card form to take a payment using the Payment Intents API, Stripe Elements and React.
See a hosted version of the demo in test mode or fork on codesandbox.io
This sample consists of a client
in React and a server
piece available in 5 common languages.
The client is implemented using create-react-app
to provide the boilerplate for React. Stripe Elements is integrated using react-stripe-elements
, which is the official React library provided by Stripe.
The server includes 5 server implementations in Node, Ruby, Python, Java, and PHP in the /server directory. We included several RESTful server implementations, each with the same endpoints and logic.
To run this sample locally you need to start both a local dev server for the front-end
and another server for the back-end
.
You will need a Stripe account with its own set of API keys.
If you want to run the recipe locally, copy the .env.example file to your own .env file in this directory:
cp .env.example .env
- Go to
/server
- Pick the language you are most comfortable in and follow the instructions in the directory on how to run.
- Go to
/client
- Run
yarn
- Run
yarn start
and your default browser should now open with the front-end being served fromhttp://localhost:3000/
.
When running both servers, you are now ready to use the app running in http://localhost:3000.
- Enter your name and card details
- Hit "Pay"
- 🎉
Q: Why did you pick these frameworks?
A: We chose the most minimal framework to convey the key Stripe calls and concepts you need to understand. These demos are meant as an educational tool that helps you roadmap how to integrate Stripe within your own system independent of the framework.
Q: Can you show me how to build X?
A: We are always looking for new recipe ideas, please email [email protected] with your suggestion!