2017 © Pedro Peláez
 

library lightning-charge-client-php7

PHP7 client for the Lightning Charge REST API

image

analogic/lightning-charge-client-php7

PHP7 client for the Lightning Charge REST API

  • Tuesday, March 27, 2018
  • by analogic
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

lightning-charge-client-php

PHP client for the Lightning Charge REST API., (*1)

Install

$ composer require elementsproject/lightning-charge-client-php

Use

<?php
require_once 'vendor/autoload.php';

// Initialize client
$charge = new \LightningCharge\Client('http://localhost:8009', '[TOKEN]');

// Create invoice
$request = new \LightningCharge\InvoiceRequest();
$request->setMilliSatoshi(50);
$request->setMetadata(['customer' => [ 'customer' => 'Satoshi', 'products' => [ 'potato', 'chips']]]);
$invoice = $charge->invoice($request);

tell_user("to pay, send ".$invoice->getMilliSatoshi()." milli-satoshis with rhash ".$invoice->getRhash().", or copy the BOLT11 payment request: ".$invoice->getPayreq());


// Create invoice denominated in USD
$request = new \LightningCharge\InvoiceRequest();
$request->setCurrency('USD');
$request->setAmount(0.15);
$invoice = $charge->invoice($request);

// Fetch invoice by id
$invoice = $charge->fetch('m51vlVWuIKGumTLbJ1RPb');

// Fetch all invoices
$invoices = $charge->fetchAll();

// Register web hook
$charge->registerHook('m51vlVWuIKGumTLbJ1RPb', 'http://my-server.com/my-callback-url');

TODO: document wait, (*2)

Test

$ composer install
$ mkdir /tmp/data
$ docker run -u `id -u` -v /tmp/data:/data -p 9112:9112 \
             -e API_TOKEN=mySecretToken \
             shesek/lightning-charge
$ CHARGE_URL=http://api-token:mySecretToken@localhost:9112 vendor/bin/phpunit test

License

MIT, (*3)

The Versions

27/03 2018

dev-master

9999999-dev

PHP7 client for the Lightning Charge REST API

  Sources   Download

MIT

The Requires

 

The Development Requires

27/03 2018

0.1.4

0.1.4.0

PHP7 client for the Lightning Charge REST API

  Sources   Download

MIT

The Requires

 

The Development Requires

29/12 2017

0.1.3

0.1.3.0

PHP client for the Lightning Charge REST API

  Sources   Download

MIT

The Requires

 

The Development Requires

09/12 2017

0.1.2

0.1.2.0

PHP client for the Lightning Strike REST API

  Sources   Download

MIT

The Requires

 

The Development Requires