🔐 Environment Variables

Add the Stripe SDK to Environment Variables

Commands

Create a .env file and install the dotenv and stripe packages.

touch .env
npm i dotenv stripe

Prompt Template

Configure Stripe environemt variables in [SOME WEB FRAMEWORK] using the code below as a reference. 
Use the environment variables to initialize the Stripe SDK.

Code

file_type_config .env
STRIPE_PUBLISHABLE_KEY=pk_test_
STRIPE_SECRET_KEY=sk_test_
STRIPE_WEBHOOK_SECRET=whsec_
file_type_typescript src/index.ts
import { serve } from '@hono/node-server'
import { Hono } from 'hono'
import Stripe from 'stripe';
import 'dotenv/config'

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);


const app = new Hono()

const port = 3000
console.log(`Server is running on port ${port}`)

serve({
  fetch: app.fetch,
  port
})

Questions? Let's chat

Open Discord