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

forgingblock.js

v0.1.4

Published

The Official ForgingBlock Library for Node.js

Downloads

9

Readme

ForgingBlock

ForgingBlock is a peer-to-peer cryptocurrency payment system that facilitates developers in providing infrastructure similar to what is offered within the credit card payment industry. ForgingBlock offers APIs, libraries, and Ecommerce plugins to assist merchants and developers - who are familiar with the credit payment process – in adopting cryptocurrency, L2 networks & stable coins as a payment method with a minimal learning curve and easy adaptability.

The official Node.js library for the ForgingBlock API.

npm Links : https://www.npmjs.com/package/forgingblock.js

Table of contents

Node.js versions

Node.js v0.10.48 and above are supported.

Documentation

For more details visit ForgingBlock API Docs.

To start using this library register an account on ForgingBlock. You will find your Trade and Token keys from Settings.

Next initialize a Client for interacting with the API. The required parameters to initialize a client are Trade and Token, however, you can also pass in baseUrl, apiVersion and timeout.

const forgingblock = require('forgingblock.js');
const Client = forgingblock.Client;
const Sale = forgingblock.resources.Sale;
const Balance = forgingblock.resources.Balance;

Client.init({
  trade: <trade>, 
  token: <token>
});

The API resource class provides the following static methods: list, all, create, retrieve, updateById, deleteById. Additionally, the API resource class also provides the following instance methods: save, delete, insert, update.

Each API method returns an ApiResource which represents the JSON response from the API. When the response data is parsed into objects, the appropriate ApiResource subclass will automatically be used.

Parameters can be also be set post-initialization:

var clientObj = Client.init(Trade, Token);
clientObj.setRequestTimeout(3000);

Installation

Install with npm:

npm install forgingblock.js --save

Usage

var forgingblock = require('forgingblock.js');
var Client = forgingblock.Client;

Client.init({
  trade: <trade>, 
  token: <token>
});

Checkouts

Checkouts API docs

Load checkout resource class

var forgingblock = require('forgingblock.js');
var Checkout = forgingblock.resources.Checkout;

Retrieve

checkout_type is of type string, and can accept either "product" or "donation"

Checkout.retrieve(<checkout_id>, <checkout_type [ product | donation ]>, function (error, response) {
  console.log(error);
  console.log(response);
});

Create

checkout_type is of type string, and can accept either "product" or "donation"

var checkoutData = {
  amount: 550,
  currency: 'usd',
  description: 'Description for the product',
  email: '[email protected]',
  count: 2,
  name: 'IPhone'
};

IPN (Instant Payment Notification) As a developer, you want to get notification on events when a payment is completed or rejected. That's where IPN (Instant Payment Notification) come in handy. IPN helps in receiving the success/error messages with payment status from the ForgingBlock server to your server.

Provide ipn parameter with url (starting https:// or http://) in order to receive IPN after invoice is expired.

Checkout.create(checkoutData, <checkout_type [ product | donation ]>, <ipn [ url ]>, function (error, response) {
  console.log(error);
  console.log(response);
});

Update

var newParams = {
  description: 'thebesttool',
  name: 'product1',
  count: 12,
  item: '829f8bd302d0f2b24e8fe9b6d23ad494' // item or fund id is required
};

Checkout.update(newParams, function (error, response) {
  console.log(error);
  console.log(response);
});

Get all checkouts

Checkout.all({}, function (error, list) {
  console.log(error);
  console.log(list);
});

Sales

Sales API docs

Load Sale resource class

var forgingblock = require('forgingblock.js');
var Sale = forgingblock.resources.Sale;

Retrieve

Sale.retrieve(<invoiceId>, function (error, response) {
  console.log(error);
  console.log(response);
});

Get all sales

Sale.all({}, function (error, response) {
  console.log(error);
  console.log(response);
});

// OR you can pass the status parameter to get only the paid invoices

Sale.all({ status: 'paid' }, function (error, response) {
  console.log(error);
  console.log(response);
});

Balances

Load event resource class

var forgingblock = require('forgingblock.js');
var Balance = forgingblock.resources.Balance;

Get balances

Display balances, multi wallet only (default)

Balance.all({}, function (error, list) {
  console.log(error);
  console.log(list);
});

License

MIT