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

magpie-js-sdk

v1.0.6

Published

SDK library for Magpie

Readme

Description

A NodeJS based wrapper that connects to Magpie REST APIs.

Usage

Magpie

To use the sdk, we need to require the Magpie SDK class and create an instance of it.

const Magpie = require('magpie-js-sdk');

const isSandbox = false;
const magpie = new Magpie('pk_mypublickey', 'sk_mysecretkey', isSandbox, 'v1.1');

// the `magpie` object contains (3) properties
// - magpie.token
// - magpie.charge
// - magpie.customer

// each property contains method that is a mapping to Magpie's REST endpoint.

Token

  • Create token using magpie.token.create
magpie.token.create('John Doe', '4242424242424242', '02', '2022', '123')
	.then(response => {
		// response contains object in this shape, { statusCode, body }
		// create token success returns `201` status code
		if (response.statusCode !== 201) {
			// handle error in response here
		}

		// handle success scenario
	})
  • Get token info using magpie.token.get
magpie.token.get('tok_123asdfa034jasdf')
	.then(response => {
		// response contains object in this shape, { statusCode, body }
		if (response.statusCode !== 200) {
			// handle error in response here
		}
		// handle success scenario here
	})

Customer

  • Create customer: magpie.customer.create
const email = '[email protected]';
const description = 'Developer';
magpie.customer.create(email, description)
	.then(response => {
		if (response.statusCode !== 200) {
			// handle error scenario here
		}
		// handle success scenario here
	});
  • Get customer: magpie.customer.get
magpie.customer.get('cus_1adlkfjas03asdf')
	.then(response => {
		if (response.statusCode !== 200) {
			// handle error scenario here
		}
		// handle success scenario here
	});
  • Add/update customer payment source: magpie.customer.update
magpie.customer.update('cus_1adlkfjas03asdf', 'tok_asdfas39234asdf')
	.then(response => {
		if (response.statusCode !== 200) {
			// handle error scenario here
		}
		// handle success scenario here
	});
  • Delete customer payment source: magpie.customer.deleteSource
magpie.customer.deleteSource('cus_1adlkfjas03asdf', 'card_asdfas3asdfas3')
	.then(response => {
		if (response.statusCode !== 200) {
			// handle error scenario here
		}
		// handle success scenario here
	});
  • Delete customer: magpie.customer.delete
magpie.customer.delete('cus_1adlkfjas03asdf')
	.then(response => {
		if (response.statusCode !== 200) {
			// handle error scenario here
		}
		// handle success scenario here
	});

Charge

  • Create charge: magpie.charge.create
const amount = 5000;
const currency = "PHP";
const source = 'tok_asldfjalsdfja98a7sfa';
const description = "Test create charge";
const statementDescriptor = "Test statement";
const capture = true;
magpie.charge.create(
    amount,
    currency,
    source,
    description,
    statementDescriptor,
    capture
  )
	.then(response => {
		// create charge success returns `201` status code
		if (response.statusCode !== 201) {
			// handle error scenario here
		}
		// handle success scenario here
	});
  • Get charge: magpie.charge.get
magpie.charge.get('ch_awdkfjalsdjf30234a')
	.then(response => {
		if (response.statusCode !== 200) {
			// handle error scenario here
		}
		// handle success scenario here
	});
  • Capture charge: magpie.charge.capture
magpie.charge.capture('ch_awdkfjalsdjf30234a', 5000)
	.then(response => {
		if (response.statusCode !== 200) {
			// handle error scenario here
		}
		// handle success scenario here
	});
  • Void charge: magpie.charge.void
magpie.charge.void('ch_awdkfjalsdjf30234a')
	.then(response => {
		if (response.statusCode !== 200) {
			// handle error scenario here
		}
		// handle success scenario here
	});
  • Refund charge: magpie.charge.refund
magpie.charge.refund('ch_awdkfjalsdjf30234a', 5000)
	.then(response => {
		if (response.statusCode !== 200) {
			// handle error scenario here
		}
		// handle success scenario here
	});

If you have suggestions or comments, kindly email me [email protected]