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

bayonet-node

v1.1.0

Published

A Javascript SDK for integrating with the Bayonet API

Downloads

22

Readme

Bayonet Build Status

Bayonet enables companies to feed and consult a global database about online consumers’ reputation, based on historic payments. Start making smarter business decisions today.

Introduction

Bayonet’s API is organized around REST and exposes endpoints for HTTP requests. It is designed to have predictable, resource-oriented URLs and uses standard HTTP response codes to indicate the outcome of operations. Request and response payloads are formatted as JSON.

About the service

Bayonet provides an Ecosystem of Trust and Protection where companies can collaborate with each other to combat online fraud. We provide a secure platform to share and consult data to understand when a consumer is related to fraudulent activity or has a fraud-free record. Different technologies that run algorithms to link parameters seen in different transactions, fed by companies connected to the ecosystem are employed in order to build consumer profiles. By consulting Bayonet’s API, a response with data provided by companies themselves is available in real-time for your risk assesment process to analyze it and take better decisions.

Bayonet's API details

To know more about Bayonet's API and its domain and technical details, please refer to the Bayonet API documentation.

Getting started

To use this SDK, please make sure:

  • You have NodeJS installed on your system.

  • You have an API KEY (sandbox and/or live) provided by Bayonet's team.

  • Install the 'bayonet-node' module on your system

    npm install bayonet-node
  • Add dependency 'bayonet-node' in your package.json file.

  • Require 'bayonet-node' in your file

    var bayonet = require('bayonet-node');
  • Create config options, with parameters (api_key).

    bayonet.configure({
      'api_key': 'your_api_key'
    });
  • You can use environment vars too.

    export BAYONET_API_KEY=your_api_key

Usage

Once you have Bayonet's SDK configured, you can call the three APIs with the following syntax:

  • Consulting API

    bayonet.api.consulting({
        "channel": "mpos",
        "email": "[email protected]",
        "consumer_name": "Example name",
        "cardholder_name": "Example name",
        "payment_method": "card",
        "card_number": 4111111111111111,
        "transaction_amount": 999,
        "currency_code": "MXN",
        "transaction_time": 1476012879,
        "coupon": false,
        "payment_gateway": "stripe",
        "shipping_address" : {
            "address_line_1" : "example line 1",
            "address_line_2" : "example line 2",
            "city" : "Mexico City",
            "state" : "Mexico DF",
            "country" : "MEX",
            "zip_code" : "64000"
        },
        ...
    });
  • Feedback API

    bayonet.api.feedback({
        "transaction_status": "success",
        "transaction_id": "uhffytd65rds56yt",
        ...
    });
  • Feedback-historical API

    bayonet.api.feedback_historical({
        "channel": "mpos",
        "type": "transaction",
        "email": "[email protected]",
        "consumer_name": "Example name",
        "payment_method": "card",
        "card_number": 4111111111111111,
        "transaction_amount": 999,
        "currency_code": "MXN",
        "transaction_time": 1423823404,
        "transaction_status": "bank_decline",
        "transaction_id": "uhffytd65rds56yt",
        "coupon": false,
        "payment_gateway": "stripe",
        "device_fingerprint": "AF567GHGJJJ87JH",
        "bank_auth_code": "5353888",
        "telephone": "0000000000",
        "expedited_shipping": false,
        "bank_decline_reason": "stolen_card",
        "shipping_address": {
            "address_line_1": "example line 1",
            "address_line_2": "example line 2",
            "city": "Mexico City",
            "state": "Mexico DF",
            "country": "MEX",
            "zip_code": "64000"
        }
        ...
    });

Success and error handling

Bayonet's SDK supports Promises for success and error handling

bayonet.api.consulting({
    ...
})
.then(function (parsedBody) {
    console.log('Success', parsedBody);
})
.catch(function (error) {
    console.log('Error', error);
});

For a full list of error codes and their messages, please refer to the Bayonet API documentation.

Demo

You can run a demo application with this command:

cd demo && node index.js

Testing

You can run the test suite with the following command:

grunt