The simplest possible payment implementation - for static websites.
Implementation of Stripe's Direct Charge payment using all 3 available methods. Any one would suffice, however all are included to demonstrate. These include:
Secure, back-end communication to stripe performed in a Firebase Function, implemented using a http trigger.
Example front-end code uses Firebase Hosting, but can be hosted anywhere.
Further reading:
See file public/index.html for all html and js code.
See file functions/index.js for the code.
The dependencies are listed in functions/package.json.
To test this integration:
firebase login
.firebase use --add
and select your project.cd functions; npm i; cd -
firebase functions:config:set stripe.token=<YOUR STRIPE SECRET KEY>
STRIPE_PUBLIC_KEY
variable in public/index.html
firebase deploy --only functions
FIREBASE_FUNCTION
variable in public/index.html
firebase deploy --only hosting
firebase open hosting:site