nuxt-stripe-module-https
v1.0.0
Published
base nuxt-stripe-module and add https protocol
Downloads
10
Readme
Nuxt Stripe Module
A NuxtJS module to import Stripe client script.
Table of Contents
Requirements
- npm
- NuxtJS
- NodeJS
Install
$ npm install --save nuxt-stripe-module
Getting Started
Add nuxt-stripe-module
to modules
section of nuxt.config.js
.
{
modules: [
// Simple usage
'nuxt-stripe-module',
// With options
['nuxt-stripe-module', {
/* module options */
version: 'v3', // Default
}],
]
}
or even
{
modules: [
'nuxt-stripe-module',
],
stripe: {
version: 'v3',
},
}
Usage
You can use this module to inject in your components a $stripe
object, by setting the publishableKey instead of calling window.Stripe(PUBLISHABLE_KEY)
every time.
{
modules: [
'nuxt-stripe-module',
],
stripe: {
version: 'v3',
publishableKey: 'YOUR_STRIPE_PUBLISHABLE_KEY',
},
}
Then you can use it in your components like:
{
...
mounted() {
const elements = this.$stripe.import().elements();
const card = elements.create('card');
// Add an instance of the card Element into the `card-element` <div>
card.mount('#card-element');
},
...
}
( See Stripe documentation: https://stripe.com/docs/stripe-js/reference)