Skip to content

How to build a card form to take a payment using Stripe Elements and React

License

Notifications You must be signed in to change notification settings

auchenberg-stripe/react-elements-card-payment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Card Payment using React

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

Preview of recipe

Features

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.

How to run locally

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

Running the API server

  1. Go to /server
  2. Pick the language you are most comfortable in and follow the instructions in the directory on how to run.

Running the React client

  1. Go to /client
  2. Run yarn
  3. Run yarn start and your default browser should now open with the front-end being served from http://localhost:3000/.

Using the sample app

When running both servers, you are now ready to use the app running in http://localhost:3000.

  1. Enter your name and card details
  2. Hit "Pay"
  3. 🎉

FAQ

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!

Author(s)

@auchenberg-stripe

About

How to build a card form to take a payment using Stripe Elements and React

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published