elementsproject / lightning-charge-client-php
PHP client for the Lightning Charge REST API
Installs: 287
Dependents: 0
Suggesters: 0
Security: 0
Stars: 24
Watchers: 11
Forks: 8
Open Issues: 0
Requires
- tcdent/php-restclient: ^0.1
Requires (Dev)
- clue/phar-composer: ^1.0
- phpunit/phpunit: ^6.4
This package is not auto-updated.
Last update: 2025-03-24 09:48:48 UTC
README
PHP client for the Lightning Charge REST API.
Install
$ composer require elementsproject/lightning-charge-client-php
Use
<?php require_once 'vendor/autoload.php'; // Initialize client $charge = new LightningChargeClient('http://localhost:8009', '[TOKEN]'); // Create invoice $invoice = $charge->invoice([ 'msatoshi' => 50, 'metadata' => [ 'customer' => 'Satoshi', 'products' => [ 'potato', 'chips' ] ] ]); tell_user("to pay, send $invoice->msatoshi milli-satoshis with rhash $invoice->rhash, or copy the BOLT11 payment request: $invoice->payreq"); // Create invoice denominated in USD $invoice = $charge->invoice([ 'currency' => 'USD', 'amount' => 0.15 ]); // Fetch invoice by id $invoice = $charge->fetch('m51vlVWuIKGumTLbJ1RPb'); // Fetch all invoices $invoice = $charge->fetchAll(); // Register web hook $charge->registerHook('m51vlVWuIKGumTLbJ1RPb', 'http://my-server.com/my-callback-url');
TODO: document wait
Test
$ CHARGE_URL=http://api-token:[TOKEN]@localhost:8009 phpunit test
License
MIT