lightning-charge-client-js
JavaScript client for the Lightning Charge REST API.
Install
$ npm install lightning-charge-client
Use
// Initialize the clientconst charge = 'http://localhost:9112' '[API-TOKEN]' // new is optionalconst charge = 'http://localhost:9112' '[API-TOKEN]' // Create invoiceconst inv = await charge console // Create invoice denominated in USDconst inv = await charge // Fetch invoiceconst invoice = await charge // Fetch all invoicesconst invoices = await charge // Long poll payment updates for a specific invoicedo const paid = await charge if paid console else if paid === false console else if paid === null console while paid === null // Stream all incoming paymentsconst stream = chargestream
See Lightning Charge's documentation for more information and a full list of invoice fields.
Test
$ CHARGE_URL=http://api-token:ACCESS-TOKEN@localhost:8009 npm test
License
MIT