1.0.3 • Published 6 years ago
nuxt-stripe-2 v1.0.3
Nuxt Stripe Module
A NuxtJS module to import Stripe client script.
Table of Contents
Requirements
- npm
- NuxtJS
- NodeJS
Install
$ npm install --save nuxt-stripe-2Getting Started
Add nuxt-stripe-2 to modules section of nuxt.config.js.
{
modules: [
// Simple usage
'nuxt-stripe-2',
// With options
['nuxt-stripe-2', {
/* module options */
version: 'v3', // Default
}],
]
}or even
{
modules: [
'nuxt-stripe-2',
],
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-2',
],
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)