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

vue-stripe-async

v0.0.3

Published

Vue.js 2 Stripe checkout component using async communication instead of form

Downloads

9

Readme

Vue Stripe

This package provides a convenient wrapper around stripe's checkout component for vue.js 2

Installation

Compile the code using browserify + vueify or webpack + vue-loader

npm install vue-stripe

Require the script:

import VueStripe from 'vue-stripe'

Regsiter the component:

Vue.use(VueStripe)

If you want to listen to events require the event bus:

import bus from 'vue-stripe/bus'

Usage

Embed the compnenet in your form as a direct HTML child.

If your are selling a single product this will do:

<form action="/process-payment" method="POST">
 <stripe-checkout
 stripe-key="my-stripe-key"
 product="product"></stripe-checkout>
</form>

The product object should match at least the bare minimum required by Stripe. E.g:

{
  name:'Moby Dick',
  description:'I love whales',
  amount:100000 // 100$ in cents
}

Additional props:

  • options Additional options to be merged into the main configuration object (e.g zipCode:true)
  • button Button text. Default: 'Purchase'

When selling multiple products you can either pass them all to the client (Option A) or, if you are dealing with an espescially large number of products, get the relevant product via ajax (Option B. Requires vue-resource>=0.9.0).

Both options require a product-id prop, which references the current product id on your instance. This would normally be a value from a select box or a router param.

Option A:

<form action="/process-payment" method="POST">
 <select v-model="productId">
  <option value="1">Product A</option>
  <option value="2">Product B</option>
  <option value="3">Product C</option>
</select>
<stripe-checkout
stripe-key="my-stripe-key"
:products="products"
:product-id="productId"></stripe-checkout>
</form>
{
      data: {
        products:[
          {
          id:1,
          name:'Product A',
          description:'Product A Description',
          amount:100000
        },
        {
          id:2,
          name:'Product B',
          description:'Product B Description',
          amount:50000
        },
        {
           id:3,
           name:'Product C',
           description:'Product C Description',
           amount:60000
        }
      ]
  }
}

Option B:

<form action="/process-payment" method="POST">
 <select v-model="productId">
  <option value="1">Product A</option>
  <option value="2">Product B</option>
  <option value="3">Product C</option>
</select>
<stripe-checkout
stripe-key="my-stripe-key"
products-url="/products"
:productId="productId"></stripe-checkout>
</form>

Server side Example (Laravel)

Route::get('products', function() {
  $productId = request('productId');

  return Product::find($productId);
});

Once the checkout form was submitted the main form will be automatically submitted. The request will include the stripeEmail and stripeToken parameters, which will enable you to process the payment and redirect back.

Events

use the bus variable to listen for events. E.g

bus.$on('vue-stripe.error', function(e) {
  console.log(e)
});
  • vue-stripe.not-found Fires off when the selected product was not found
  • vue-stripe.error Fires off when an invalid response was returned from the server using the products-url prop