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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pricing-widget

v0.0.1

Published

browser widget to accept payments by credit card

Readme

pricing-widget

Accept online payments by credit card.

This module provides only the browser interface code necessary for accepting online payments.

We use this widget code at browserling which you should definitely check out if you need to do some cross-browser testing!

example

The default style looks like this, but you can get fancy.

var pricing = require('pricing-widget');
var plans = pricing(function (payment) {
    console.log('purchased ' + payment.name);
    payment.accept();
});
plans.appendTo(document.body);

plans.add('free', {
    price: 0,
    per: 'month',
    image: 'images/free.png',
    description: 'Great for students, casual cross-browser testing,'
        + ' and product evaluation',
    features: [ '5-minute sessions' ],
    more: [
        'Use browserling for 5 minutes at a time as much as you like.',
        'Sometimes you\'ll need to wait in a queue if the site is busy.'
    ]
});

plans.add('developer', {
    price: 20,
    per: 'month',
    image: 'images/developer.png',
    description: 'Perfect for designers, front-end developers, and freelancers'
        + ' who need to check their work against all the browsers.',
    features: [ 'unlimited sessions', 'ssh tunnels' ],
    more: [
        'Use browserling for as long as you need, as much as you like.',
        'SSH tunnels to access localhost and intranet services'
    ]
});

plans.add('team', {
    price: {
        equation: '20 + 10 * (n - 1)',
        formula: function (n) { return 20 + 10 * (n - 1) },
        min: 2,
        max: 10,
        init: 2
    },
    per: 'month',
    image: 'images/team.png',
    description: 'Perfect for whole teams of designers and developers!',
    features: [ 'unlimited sessions', 'ssh tunnels' ],
    more: [
        'Use browserling for as long as you need, as much as you like.',
        'SSH tunnels to access localhost and intranet services',
        'Share a plan among your whole team!'
    ]
});

methods

var plans = pricing(opts={}, cb)

Create a new pricing widget.

You can optionally set the opts.path root to use for push-state routing.

cb is an optional shortcut to listen on 'payment' events.

plans.appendTo(target)

Append the plans.element dom node to the dom element or query selector string target.

plans.add(name, plan)

Add a plan object with a string name.

plan should have a:

  • plan.description - text to briefly describe the plan
  • plan.image - the image to show for the plan
  • plan.price - the amount to pay

plan.price can get fancy, as in the example above that uses a formula function starting at init and constrained between min and max with equation as a formula description.

plan can optionally have:

  • plan.per - payment interval, if applicable
  • plan.features - short list to show below the plan name
  • plan.more - long-form string to describe the plan when clicked on

plans.note(page, msg)

There are several places in the UI where you can add some notes to the html;

'currency', 'purchase', 'busy', and 'success' are all valid page locations.

plans.setCurrency(name)

Set a currency name different from the default name 'USD'.

plans.setSymbol(symbol)

Set a currency symbol different from the default symbol '$'.

payment.accept()

Accept a 'payment' object from a payment event, showing the user the success page.

payment.reject(err)

Reject a 'payment' object from a payment event, showing the error page with the err message.

events

plans.on('payment', function (payment) {})

When somebody clicks the purchase button, this payment event fires.

At this point you should make the api calls out to your payment processor and then call either payment.accept() or payment.reject(errMessage) to show the user what the result of the transaction is.

The parameters to payment are designed to fit well with the stripe create_charge api endpoint. The keys in payment are:

  • name
  • number
  • amount
  • cvc
  • exp_month
  • exp_year

attributes

plans.element

This is the raw dom node that pricing-widget appends all its html content to if you don't want to use .appendTo().

install

With npm do:

$ npm install pricing-widget

Then use browserify to require('pricing-widget').

license

MIT