This sample shows how to build a card form to take a payment using the Payment Intents API, Dots Elements and React.
This sample consists of a client
in React and a server
piece.
The client is implemented using create-react-app
to provide the boilerplate for React. Dots Elements is integrated using react-dots-js
, which is the official React library provided by Dots.
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 Dots account with its own set of API keys.
Follow the steps below to run locally.
Installing and cloning manually
git clone
Copy the .env.example file into a file named .env in the folder of the server you want to use. For example:
cp .env.example server/node/.env
You will need a Dots account in order to run the demo. Once you set up your account, go to the Dots developer dashboard to find your API keys.
DOTS_CLIENT_ID=<replace-with-your-client-id>
DOTS_CLIENT_SECRET=<replace-with-your-client-secret>
STATIC_DIR
tells the server where to the client files are located and does not need to be modified unless you move the server files.
- Run
npm run server
- Run
npm run client
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 card details
- Hit "Pay"
- 🎉