Skip to content

Commit

Permalink
docs: update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
giraud florent committed Jun 19, 2023
1 parent 72bfbd7 commit 1e5c0aa
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 32 deletions.
105 changes: 75 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,103 @@
<!--
Get your module up and running quickly.
Find and replace all on all files (CMD+SHIFT+F):
- Name: My Module
- Package name: my-module
- Description: My new Nuxt module
-->

# My Module
# Nuxt module for stripe

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![License][license-src]][license-href]
[![Nuxt][nuxt-src]][nuxt-href]

My new Nuxt module for doing amazing things.
Nuxt module for application using stripe.

- [&nbsp;Release Notes](/CHANGELOG.md)
<!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/my-module?file=playground%2Fapp.vue) -->
- [🏀 Online playground](https://stackblitz.com/github/fuentesloic/nuxt3-stripe?file=playground%2Fapp.vue)
<!-- - [📖 &nbsp;Documentation](https://example.com) -->

## Features

<!-- Highlight some of the features your module provide here -->
-&nbsp;Foo
- 🚠 &nbsp;Bar
- 🌲 &nbsp;Baz
At any time look at the playground for code examples.

As Stripe can only be used in a node env we had to use both `stripe` (ssr / server) and `@stripe/stripe-js` (frontend).

Use stripe inside the server folder.

``` server/api/hello-stripe.ts
import { useServerStripe } from '#stripe/server'

export default defineEventHandler(async (event) => {
const stripe = await useServerStripe(event)

console.log(stripe)

return {
hello: "stripe"
}
});
```

Use stripe inside pages or plugins

``` app.vue
<template>
<h1>Nuxt Stripe module playground!</h1>
<div>
{{ stripe }}
</div>
</template>
<script setup lang="ts">
import { useClientStripe } from '#imports';
const stripe = useClientStripe() // useClientStripe is doing exactly the same as the code below. We have added a composable for convenience
const stripePlugin = useNuxtApp().$stripe
</script>
```


## Quick Setup

1. Add `my-module` dependency to your project
1. Add `@nuxtjs/stripe` dependency to your project

```bash
# Using pnpm
pnpm add -D my-module
pnpm add -D @nuxtjs/stripe

# Using yarn
yarn add --dev my-module
yarn add --dev @nuxtjs/stripe

# Using npm
npm install --save-dev my-module
npm install --save-dev @nuxtjs/stripe
```

2. Add `my-module` to the `modules` section of `nuxt.config.ts`
2. Add `@nuxtjs/stripe` to the `modules` section of `nuxt.config.ts`

```js
export default defineNuxtConfig({
modules: [
'my-module'
]
'@nuxtjs/stripe'
],
stripe: { // both keys are required. Check typescript
publishableKey: 'pk_test_123',
apiKey: 'sk_test_123'
}
})
```

That's it! You can now use My Module in your Nuxt app ✨
## Configuration

``` nuxt.config.js
export default defineNuxtConfig({
modules: [
'@nuxtjs/stripe'
],
stripe: {
publishableKey: 'pk_test_123', // required
apiKey: 'sk_test_123' // required,
locale: string,
apiVersion: string, // default 2022-11-15
}
})
```

## Development

Expand Down Expand Up @@ -81,14 +126,14 @@ npm run release
```

<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/my-module/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-version-href]: https://npmjs.com/package/my-module
[npm-version-src]: https://img.shields.io/npm/v/@nuxtjs/stripe/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-version-href]: https://npmjs.com/package/@nuxtjs/stripe

[npm-downloads-src]: https://img.shields.io/npm/dm/my-module.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-downloads-href]: https://npmjs.com/package/my-module
[npm-downloads-src]: https://img.shields.io/npm/dm/@nuxtjs/stripe.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-downloads-href]: https://npmjs.com/package/@nuxtjs/stripe

[license-src]: https://img.shields.io/npm/l/my-module.svg?style=flat&colorA=18181B&colorB=28CF8D
[license-href]: https://npmjs.com/package/my-module
[license-src]: https://img.shields.io/npm/l/@nuxtjs/stripe.svg?style=flat&colorA=18181B&colorB=28CF8D
[license-href]: https://npmjs.com/package/@nuxtjs/stripe

[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
[nuxt-href]: https://nuxt.com
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@nuxtjs/stripe",
"version": "1.0.0",
"description": "My new Nuxt module",
"repository": "unlok/stripe",
"description": "Nuxt module for stripe",
"repository": "https://github.com/fuentesloic/nuxt3-stripe",
"license": "MIT",
"type": "module",
"exports": {
Expand Down

0 comments on commit 1e5c0aa

Please sign in to comment.