Skip to content

Commit

Permalink
feat: get Stripe keys from environment file (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitjans authored Jun 25, 2023
1 parent 7c0d6d0 commit 2ee7b10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,20 @@ export default defineNuxtConfig({
modules: [
'nuxt3-stripe'
],
stripe: {
apiKey: 'sk_test_123',
publishableKey: 'pk_test_123',
}
})
```

## Configuration

You can configure the module by providing the necessary Stripe keys and an optional API version in your `nuxt.config.js` file:
Stripe keys can be added to the `.env` file...

```env
STRIPE_PUBLISHABLE_KEY="pk_live_..."
STRIPE_API_KEY="sk_live_..."
```

...or to the Nuxt configuration file:


```ts
export default defineNuxtConfig({
Expand All @@ -109,6 +113,8 @@ export default defineNuxtConfig({
})
```

> We highly recommend you put your **production** keys in your `.env` file to avoid committing them
## Development

Initial step: Clone this repository
Expand Down
4 changes: 2 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export default defineNuxtModule<ModuleOptions>({
}
},
defaults: {
publishableKey: null,
apiKey: null,
publishableKey: process.env.STRIPE_PUBLISHABLE_KEY as string,
apiKey: process.env.STRIPE_API_KEY as string,
apiVersion: '2022-11-15'
},
setup (options, nuxt) {
Expand Down

0 comments on commit 2ee7b10

Please sign in to comment.