Easy way to create a checkout payment with Stripe API. Note: There are many ways to use the Stripe API. I recommed taking a look at the documentation for more advanced use of it.
- React:
dotenv
&react-stripe-checkout
- Ruby:
dotenv
&stripe
As we are dealing with an external API, it remain important to hide you API keys in a .env
file and add this file to your gitignore. Just a friendly reminder if you don't want to have to pay huge fees for putting an API key out to the public.
Make sure that your Stripe account is in Test Mode(comes in test mode by default), while also using the test keys.
Reminder!! Never use a real Credit Card/Debit Card number. The test number for the card is 4242 4242 4242 4242.
- Install ‘react-stripe-checkout’ & ‘dotenv’ packages;
- Create
.env
file; - Add
<StripeCheckout />
Component; - Create
onToken
function to handle transaction; - Create
fetch
tocharges
controller in the back end withtoken
andprice
; - Check Stripe account for activity
- Install ‘dotenv’ & ‘stripe’ gems;
- Create
.env
file; - Create
charges
controller to handle Stripe API charges; - Create custom
route
for thecharges
controller;