Bitnet Checkout Core is a client library for interacting with the Bitnet Websocket Gateway. This library enables you to create a fully customized checkout experience.
Installation
npm install bitnet-checkout-core --save
Usage
var BitnetCheckoutCore = ; // Pass in the environment, TEST or LIVEvar co = 'TEST'; // Set the invoice ID, as retrieved from the *Bitnet RESTful API (see below for a link)co; // See below for a full list of Lifecycle Hooksco; // This will initiate the connection of the websocketco; // ... // This will disconnect the websocketco;
* You can find the Bitnet RESTful API here (referenced in the comment above).
Lifecycle Hooks
You can hook into several points throughout the lifecycle of an invoices state. You've already seen one
in the 'usage' example above, onInvoiceFullyPaid
. Here is a full list of the available lifecycle hooks:
onInvoiceFullyPaid(callback)
onInvoiceOverpaid(callback)
onInvoiceUnderpaid(callback)
onInvoiceUnpaid(callback)
onInvoiceExpiredUnderpaid(callback)
onInvoiceExpiredUnpaid(callback)
onInvoiceError(callback)
Building
$ npm i -g webpack$ npm build
Testing
$ npm test