Socket
Book a DemoInstallSign in
Socket

nuxt-stripejs

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuxt-stripejs

NuxtJS module for Stripe.js

2.1.0
latest
Source
npmnpm
Version published
Weekly downloads
428
25.88%
Maintainers
1
Weekly downloads
 
Created
Source

nuxt-stripejs

NuxtJS module for Stripe.js with multi-account support

Table of contents

Main features

  • Support multiple Stripe accounts
  • Load Stripe.js only when required (once $stripe() is called)
  • Reuse the same instance across all components
  • Retry mechanism to bypass temporary network issues
  • Public runtime config
  • TypeScript support

Setup

  • Add nuxt-stripejs dependency to your project:
npm install nuxt-stripejs
  • Add nuxt-stripejs module and configuration to nuxt.config.js:
export default {
  // append the module
  modules: ["nuxt-stripejs"];
  
  // public runtime config
  publicRuntimeConfig: {
    stripe: {
      i18n: true,
      accounts: [
        {
          id: 'account-a',
          pubKey: 'pk_test_123',
        },
        {
          id: 'account-b',
          pubKey: 'pk_test_12345',
        },
      ],
    },
  }
}
  • (Optional) TypeScript support. Add nuxt-stripejs to the types section of tsconfig.json:
{
  "compilerOptions": {
    "types": ["nuxt-stripejs"]
  }
}

Options

accounts

  • Type: NuxtStripeJsConfig
interface NuxtStripeJsAccount {
    id: string
    pubKey: string
}

interface NuxtStripeJsConfig {
    i18n: boolean;
    accounts: NuxtStripeJsAccount[]
}

Stripe accounts (see an example in setup)

i18n

  • Type: Boolean
  • Default: false

Enable i18n-module integration.

Usage

It can be used inside components like:

<template>
  <div>
    <div ref="stripeElements" />
  </div>
</template>
{
  async mounted() {
    const stripe = await this.$stripe()
    const elements = stripe.elements()

    const card = elements.create('card')
    card.mount(this.$refs.stripeElements)
  }
}

Multiple stripe accounts support:

{
  async mounted() {
    const stripe = await this.$stripe(conditionX ? 'account-a' : 'account-b')
    const elements = stripe.elements()

    const card = elements.create('card')
    card.mount(this.$refs.stripeElements)
  }
}

Stripe: JavaScript SDK documentation & reference

License

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

FAQs

Package last updated on 03 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.