Add Stripe Keys to Config

Link to chapter - https://serverless-stack.com/chapters/add-stripe-keys-to-config.html

A comment regarding this chapter if people are having problems.

Make sure you include the “” around your Stripe key. A friend of mine said he had issues getting this part working, and it was because he didn’t have the quotes (“key”)

1 Like

Yup! Thanks for sharing!

why include strip in html and not use the object provided in react-stripe ?

There are two separate things to load here. The Stripe Elements and Strip.js. For Stripe.js you can either do it directly through the HTML. Or you can use:

import {loadStripe} from '@stripe/stripe-js';

const stripePromise = loadStripe('pk_test_ABCDEFGHI');

The HTML way is just simpler.

1 Like

I went through using the library and I have a class for that working if you need it.
the thing is from security perspective, I don’t think it’s safe to load data from browser, imagine an attacker altering this js link that you use and provide their own library that steals client info. I know this can’t happen because of https but still isn’t a very smart thing to do. or that’s what I think

Hmmm there must be a misunderstanding here because both those ways load data from your browser. In one case it uses an external script. While in the import case it builds the script when you build your app.