seanc / nuxt-stripejs

💳 NuxtJS module for Stripe.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nuxt-stripejs

NuxtJS module for Stripe.js

Main features

  • Load Stripe.js only when required
  • Reuse the same instance across all components
  • TypeScript support

Setup

  1. Add nuxt-stripejs dependency to your project:
npm install nuxt-stripejs
  1. Add nuxt-stripejs module and configuration to nuxt.config.js:
export default {
  // ...other config options  
  modules: ["nuxt-stripejs"];
  stripe: {
    publishableKey: 'pk_test_XXXXXXXXXXXXXXX',
  }
}
  1. (Optional) TypeScript support. Add nuxt-stripejs to the types section of tsconfig.json:
{
  "compilerOptions": {
    "types": [
      "nuxt-stripejs"
    ]
  }
}

Options

publishableKey

  • Type: String

Your Stripe's publishable key.

Usage

It can be used inside components like:

{
  async mounted() {
    const stripe = await this.$stripe()
    const elements = stripe.elements()

    const card = elements.create('card')
    card.mount('card-element');
  }
}

Stripe: JavaScript SDK documentation & reference

License

See the LICENSE file for license rights and limitations (MIT).

About

💳 NuxtJS module for Stripe.js

License:MIT License


Languages

Language:TypeScript 100.0%