1.0.0 • Published 5 years ago

nuxt-stripe-module-https v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Nuxt Stripe Module

npm (scoped with tag) npm js-standard-style

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)

License

MIT License