Processing payments using Stripe
Stripe is one of the best financial services out there; it's straightforward to use and offers excellent documentation to understand how to integrate their APIs.
Before continuing with this section, make sure to open an account at https://stripe.com.
Once we have an account, we can log in and go to https://dashboard.stripe.com/apikeys, where we'll retrieve the following information: the publishable key and secret key. We will need to store them inside of two environment variables, following this naming convention:
NEXT_PUBLIC_STRIPE_SHARABLE_KEY= STRIPE_SECRET_KEY=
Please double-check that you're not exposing the STRIPE_SECRET_KEY
variable and that the .env.local
file is not added to the Git history by including it in the .gitignore
file.
Now let's install the Stripe JavaScript SDK inside of our project:
yarn add @stripe/stripe-js stripe
Once the two packages are installed, we can create a new file under lib...