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

squareup

v1.0.0

Published

Making square up API integration easy by bringing everything at one place

Downloads

20

Readme

The Square Up library provides an easy and convinent access to Square UP API from server-side applications.

Please keep in mind that this package can be used only in the server-side Node applications that uses Square Up access token. This package should not be used for front-end applications.

Installation:

Install the package with:

npm install squareup --save

Square Up Introduction:

Square up provides up with a list of API that can be used to connect to square up, register customers, store their credit cards details, paying to the merchant and handling refunds from them.

This library allows us methods to use the Square Up APIs for :

  • Initialise Square Up module with its access token.
  • Add new customer.
  • Adding new card for the customer.
  • Deleting the card from customer's cards list.
  • Charging the customer.
  • Making refunds.
Usage:

The package needs to be configured with your access token which is available in your Square up Dashboard. It can be either sandbox or actual access token. Require it with the token's value:

var SquareUp = require('squareup');
var squareUp = new SquareUp('your token here ..');     //Initialize square up by passing token here
 
var customerObj = {
		"given_name": '',           //required
		"family_name": '',          //required
		"email_address": '',        //required
		"address": {                //object us required, can be emply object
	     	"address_line_1": "",   //can be empty string
			"address_line_2": "",   //can be empty string
			"locality": "",         //can be empty string
			"postal_code": "",      //can be empty string
			"country": ""           //can be empty string
		},
		"phone_number": "",           //can be empty string
		"reference_id": ""            //any random string, min 32 characters
};
squareUp.createCustomer(
  customerObj,
  function(err, customer) {
    err; // null if no error occurred 
    customer; // the created customer object 
  }
);
For adding cutomer cards:
var cardObj = {
	"card_nonce": string,      //Generated by client-side square up library used for adding customer card details
	"billing_address": {    
	    "address_line_1": Joi.string(),      //Can be emppty string
	    "address_line_2": Joi.string(),     //Can be emppty string
	    "locality": Joi.string(),           //Can be emppty string
	    "administrative_district_level_1": Joi.string(), //Can be emppty string
    	"postal_code": Joi.string(),        //Required and should be the same as entered in client-side square up library to generate nonce
    	"country": Joi.string()             //Required
	},
	"cardholder_name": Joi.string().required()      //Required
};

squareUp.createCustomerCard(
  customerId,
  cardObj,
  function(err, card) {
    err; // null if no error occurred 
    card; // the created card object 
  }
);

Other methods used are :

  1. createCustomer(customer_details_obj, function(err, customerInfo)): For adding new customer
  2. createCustomerCard(customerId, card_details_obj, function(err, cardDetails)): For adding new card to the customer
  3. deleteCustomerCard(customerId, cardId, function(err, result)): For deleting card from the customer's cards list
  4. charge(charge_details_obj, function(err, result)):
var charge_details_obj = {
			"shipping_address": {
				"address_line_1": string,
				"address_line_2": string),
				"administrative_district_level_1": string,
				"locality": string,
				"postal_code": string,
				"country": string
			},
			"billing_address": {
				"address_line_1": string,
				"address_line_2": string,
				"administrative_district_level_1": string,
				"locality": string,
				"postal_code": string,
				"country": string
			},
			"amount_money": ({
				"amount": number,    //required
				"currency": string      //required
			}),
			"customer_card_id": string,         //required
			"customer_id": string,          //required
			"note": string,
			"delay_capture": false     //required
		};

either of the billing_address or shipping_address must be provided for making transaction with chargeback protection.

The above method provides an idempotency_key which is unique for every transaction and can be used to uniquely identify the transaction.

  1. refund(transactionId, details_obj, function(err, result)) : For making a refund for customer's card.

More Information

Square Up Rest API Documentation Square Up Connection