Learn how to securely accept payments online.
This repository includes examples of 3 types of integration.
Prebuilt Checkout page (docs) | Payment Element (docs) | Custom payment flow (docs) |
---|---|---|
Lower complexity. | Moderate complexity. | Higher complexity. |
Customize logo, images, and colors. | Customize components with Appearance API. | Customize all components with CSS. |
Add payment method types with a single line change. | Add payment methods with a single line change. | Implement each payment method type as a custom integration. |
Built-in support for Apple Pay, and Google Pay. | Built-in support for Apple Pay and Google Pay. | Integrate Apple Pay and Google Pay with extra code. |
Redirect to Stripe hosted page. | Customers stay on your site, but payment completion triggers a redirect. | Customers stay on your site. |
Small refactor to collect recurring payments. | Large refactor to collect recurring payments. | Large refactor to collect recurring payments. |
Input validation and error handling built in. | Input validation built-in but you must implement error handling. | Implement your own input validation and error handling. |
Localized in 25+ languages. | Localized in 25+ languages. | Implement your own localization. |
Automate calculation and collection of sales tax, VAT and GST with one line of code. | Calculate tax using the Tax API | Calculate tax using the Tax API |
Payment Method Type | Prebuilt Checkout page (docs) | Payment Element (docs) | Custom payment flow (docs) |
---|---|---|---|
ACH Credit Transfer | |||
ACH Debit | ✅ | ✅ | ✅ |
Afterpay/Clearpay | ✅ | ✅ | ✅ |
Alipay | ✅ | ✅ | ✅ |
Apple Pay | ✅ | ✅ | ✅ |
Bacs Direct Debit | ✅ | ||
Bancontact | ✅ | ✅ | ✅ |
BECS Direct Debit | ✅ | ✅ | ✅ |
Boleto | ✅ | ✅ | ✅ |
Cards | ✅ | ✅ | ✅ |
EPS | ✅ | ✅ | ✅ |
FPX | ✅ | ✅ | ✅ |
giropay | ✅ | ✅ | ✅ |
Google Pay | ✅ | ✅ | ✅ |
GrabPay | ✅ | ✅ | ✅ |
iDEAL | ✅ | ✅ | ✅ |
Klarna | ✅ | ✅ | ✅ |
Link | ✅ | ✅ | |
Multibanco | ✅ | ✅ | |
OXXO | ✅ | ✅ | ✅ |
Przelewy24 (P24) | ✅ | ✅ | ✅ |
SEPA Direct Debit | ✅ | ✅ | ✅ |
Sofort | ✅ | ✅ | ✅ |
WeChat Pay | ✅ | ✅ | ✅ |
The recommended way to use this Stripe Sample is with the Stripe CLI:
stripe samples create accept-a-payment
You can also clone the repository, but there is a bit more manual setup work to
configure the .env
environment variable file in the server directory.
You'll find more detailed instructions for each integration type in the relevant READMEs:
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.
If you found a bug or want to suggest a new [feature/use case/sample], please file an issue.
If you have questions, comments, or need help with code, we're here to help:
- on Discord
- on Twitter at @StripeDev
- on Stack Overflow at the stripe-payments tag
Sign up to stay updated with developer news.
See TESTING.md.
We provide Dev Container configurations for most of the sample apps for web. For the Visual Studio Code example, by hitting Reopen in Containers
in the Command Pallete and choosing a sample from the options prompted, dedicated Docker containers for the sample will be automatically created.
You can also try these samples even without installing Docker on your machine by using GitHub Codespaces. A sample app codespace can be created by clicking "New with options..." below and choosing a sample app from the Dev container configuration select box. Note that in this case, you would be charged for usage of GitHub Codespaces.
After launching the environment, a couple of setup steps would be needed to launch the web app. For the NodeJS (custom-payment-flow-server-node
) example:
- Export the required environment variables
export STRIPE_PUBLISHABLE_KEY=XXXX
export STRIPE_SECRET_KEY=XXXX
export PRICE=XXXX
- Install the dependencies and run the web server. For NodeJS example,
npm install && npm run start
You can also run some tests for the server app by the following steps. This example is a little hacky as we need to use SSH to run a test command in another container (runner
).
- Run
ssh-keygen
andchmod 600 ~/.ssh/*
- Login to the test runner service with
ssh runner
- Move to the working dir with
cd /work
- Export the required environment variables
export $(cat .devcontainer/.env | xargs)
export STRIPE_PUBLISHABLE_KEY=XXXX
export STRIPE_SECRET_KEY=XXXX
export PRICE=XXXX
- Run tests like
bundle exec rspec spec/custom_payment_flow_server_spec.rb
After launching the environment, a couple of setup steps would be needed to launch the app. For the Create React App (custom-payment-flow-client-react-cra
) example:
- Export the required environment variables
export STRIPE_PUBLISHABLE_KEY=XXXX
export STRIPE_SECRET_KEY=XXXX
export PRICE=XXXX
- Install the dependencies and run the node web server by running
cd ../../server/node && npm install && npm run start
- In another terminal, install the dependencies and run the client app by running
npm install && npm start
- 📝 You might want to set
server.hmr.port
to443
invite.config.js
(related issue)
Made with contrib.rocks.