GithubHelp home page GithubHelp logo

isabella232 / nodejs-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bitpay/nodejs-client

0.0 0.0 0.0 159 KB

Nodejs library for integrating with the Bitpay.com API (old client library)

JavaScript 100.00%

nodejs-client's Introduction

bitpayNodejs

Nodejs library for integrating with the Bitpay.com API

This client library is provided to demonstrate how to interact with the BitPay.com JSON API. You can use this client library as is on your server, you can customize it, or you can use it as a guide for developing a client library in another language. The sample client library is written in JavaScript and is designed to run using nodejs. Nodejs can be downloaded form http://nodejs.org. The examples have been tested on version 0.8.9, but should work on later versions as well. There are 3 utilities: createInvoice, getInvoice, invoiceListener. These files are executable and invoke the node runtime using typical Unix shebang notation. They can also be started by passing them as the first argument to the β€œnode” runtime. The files themselves are JavaScript source code.

To use the utilities, modify the config.js file and copy and paste an API key from your merchant account into the apiKey setting. This will associate your API calls with your merchant account. Also, there is a sample SSL key and certificate file that is used by the invoiceListener to setup the HTTPS server that listens for incoming invoice notifications. While these example credentials will work fine, you may want to create your own unique SSL key and certificate.

To create an invoice, run the createInvoice utility and pass in an invoice description on stdin. A sample invoice description is provided in the file sampleInvoice.json. To create an invoice using this sample, run the following command:

$ ./createInvoice < sampleInvoice.json

The newly created invoice will be output on a single line in JSON format.

To get an invoice, run the getInvoice utility and pass the invoice id as the sole argument as follows:

$ ./getInvoice 5_TU2V-M0glicVcZuQkkkq9aiA7qP0MjxRkhdc1MRSY=

Just as before, the invoice will be output on a single line in JSON format.

To receive notifications of invoice status updates, use the invoiceListener utility. It takes a single parameter on the command line to specify the port number (or it can be specified in config.js) and listens for incoming notifications from BitPay.com. If you create an invoice with a notificationURL to your server and port, notifications of status changes on that invoice will be delivered to this utility. When a notification is received, the utility will print the JSON encoded invoice on stdout (one line per notification).

nodejs-client's People

Contributors

ionux avatar martindale avatar gasteve avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.