Nodejs library for integrating with the Bitpay.com API
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).