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

transact-payments

v1.4.0

Published

Node module to do payments using transact.io

Downloads

21

Readme

transact-payments

This is a library for use with transact.io

See an example on package transact-payments-demo with a live demo

Working with this package

Add transact-payments package to your package.json file

Usage

Require transact-payments library

let transactIo = require('transact-payments');

Instantiate a new instance of the TransactIoMsg class

let transactToken = new transactIo.TransactIoMsg(); // get new instance

Required: Set the secret that is in the Developer Settings / Keys of the transact publisher menu

transactToken.setSecret('Signing Secret'); // secret key

Required: Set the Account ID of who recieves the funds

transactToken.setRecipient('5206507264147456'); // Account ID to pay

Required: set the URL of what is being purchased.

// Note that the host name MUST match the real name for cross site 
// messaging to work. 
transactToken.setURL($_REQUEST['url']);

Required: Set the price in pences of the sale

transactToken.setPrice(2);

Required: Set an item or product code. This can be something unique to the article or content you are selling. The buyer will see this as part of the name of the charge

transactToken.setItem('ItemCode1'); // item code

Optional: Set a Unique ID associated with this sale.

transactToken.setUid('UniqueSaleID');

Optional: Set meta data you want to save with this sale.

// Set your own meta data
// Note you must keep this short to avoid going over the 1024 byte limt
// of the token URL
transactToken.setMeta({
	'your' : 'data',
	'anything' : 'you want'
});

Get token for normal purchase

Get a token that will be passed to transact.js after all paramateres are set. There are two ways to generate a token.

Using callback

function getTokenCb(error,token) {
	if (error) {
		console.log("Failed to create the token with error:",error);
	} else {
		console.log("Token created successfully:",token);
	}
}

transactToken.getToken(getTokenCb);

Using promise

let promise = transactToken.getToken();

promise.then(function(token) {
	console.log("Token created successfully:",token);
).catch(function(error) {
	console.log("Failed to create the token with error:",error);
});

Verifying a token

To verify a token the signing secret needs to match the one used when creating the token. There are two ways to verify a token.

Using callback

let transactIo = require('transact-payments');
let token = 'token generated previously';
let secret = 'Signing Secret';

function tokenVerification(error,verifiedToken) {
	if (error) {
		console.log("Failed to verify the token with error:",error);
	} else {
		console.log("Token verified successfully:",verifiedToken);
	}
}

transactIo.TransactIoMsg.verify(token,secret,tokenVerification);

Using promise

let transactIo = require('transact-payments');
let token = 'token generated previously';
let secret = 'Signing Secret';

let promise = transactIo.TransactIoMsg.verify(token,secret);
promise.then(function(verifiedToken) {
	console.log("Token verified successfully:",verifiedToken);
}).catch(function(error) {
	console.log("Failed to verify the token with error:",error);
});