npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@chantouchsek/nuxt-stripe

v0.0.6

Published

NuxtJS module for Stripe.js

Downloads

32

Readme

Table of contents

Features

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

Setup

  1. Add @chantouchsek/nuxt-stripe dependency to your project:
npm install @chantouchsek/nuxt-stripe
  1. Add @chantouchsek/nuxt-stripe module and configuration to nuxt.config.js:
export default {
    modules: [
        // simple usage
        '@chantouchsek/nuxt-stripe',
        // with options
        ["@chantouchsek/nuxt-stripe", {
            publishableKey: 'YOUR_STRIPE_PUBLISHABLE_KEY',
            version: '2020-08-27',
            i18n: true,
        }]
    ],
    // .....option
    stripe: {
        publishableKey: 'YOUR_STRIPE_PUBLISHABLE_KEY',
        version: '2020-08-27',
        i18n: true,
    },
    // runtime config
    publicRuntimeConfig: {
        stripe: {
            publishableKey: 'YOUR_STRIPE_PUBLISHABLE_KEY',
            version: '2020-08-27',
            i18n: true,
        }
    }
}
  1. (Optional) TypeScript support. Add @chantouchsek/nuxt-stripe to the types section of tsconfig.json:
{
  "compilerOptions": {
    "types": [
      "@nuxt/types",
      "@chantouchsek/nuxt-stripe"
    ]
  }
}
  1. (Optional), If you need to support change stripe locale base i18n locale changed, just create a file in plugins/i18n.{js,ts}
import { Context, Inject } from '@nuxt/types/app'
import { getStripeInstance } from '@chantouchsek/nuxt-stripe'
import { CheckoutLocale, StripeElementLocale } from '@stripe/stripe-js'

export default function (ctx: Context, inject: Inject) {
    const {app} = ctx
    app.i18n.onLanguageSwitched = async (_, locale) => {
        const stripeLocale = locale as StripeElementLocale | CheckoutLocale
        const stripeInstance = await getStripeInstance(ctx, stripeLocale)
        inject('stripe', stripeInstance)
        ctx.app.stripe = stripeInstance
    }
}

And call it in nuxt.config.{js,ts}

export default {
    plugins: [
        '~/plugins/i18n',
    ]
}

Options

publishableKey

  • Type: String

Your Stripe's publishable key.

version

  • Type: String

Your Stripe's version.

i18n

  • Type: Boolean
  • Default: false

Enable i18n-module integration.

Usage

It can be used inside components like:


<template>
    <div>
        <div ref="stripeElements"/>
    </div>
</template>
export default {
    async mounted() {
        const stripe = await this.$stripe()
        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).