Skip to content

Commit

Permalink
s/Lightning Kite/Lightning Charge/g
Browse files Browse the repository at this point in the history
  • Loading branch information
shesek committed Dec 29, 2017
1 parent 9f1f594 commit 72a3e33
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
# lightning-strike-client-php
# lightning-charge-client-php

PHP client for the Lightning Strike REST API.
PHP client for the Lightning Charge REST API.

## Install

```bash
$ composer require elementsproject/lightning-strike-client-php
$ composer require elementsproject/lightning-charge-client-php
```

## Use

```php
<?php
// Initialize client
$strike = new LightingStrikeClient('http://localhost:8009', '[TOKEN]');
$charge = new LightingChargeClient('http://localhost:8009', '[TOKEN]');
// alternatively, the token can be provided as part of the URL:
$strike = new LightingStrikeClient('http://api-token:[TOKEN]@localhost:8009');
$charge = new LightingChargeClient('http://api-token:[TOKEN]@localhost:8009');

// Create invoice
$invoice = $strike->invoice([ 'msatoshi' => 50, 'metadata' => [ 'customer' => 'Satoshi', 'products' => [ 'potato', 'chips' ] ] ]);
$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");

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

// Create invoice denominated in USD
$invoice = $strike->invoice([ 'currency' => 'USD', 'amount' => 0.15 ]);
$invoice = $charge->invoice([ 'currency' => 'USD', 'amount' => 0.15 ]);
```

TODO: document missing methods
Expand Down
2 changes: 1 addition & 1 deletion client.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
class LightningStrikeClient {
class LightningChargeClient {
protected $api;

public function __construct($url, $api_token=null) {
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elementsproject/lightning-strike-client-php",
"description": "PHP client for the Lightning Strike REST API",
"name": "elementsproject/lightning-charge-client-php",
"description": "PHP client for the Lightning Charge REST API",
"version": "0.1.2",
"license": "MIT",
"require": {
Expand Down
18 changes: 9 additions & 9 deletions test.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
require_once 'vendor/autoload.php';

class LightningStrikeClientTest extends \PHPUnit\Framework\TestCase {
class LightningChargeClientTest extends \PHPUnit\Framework\TestCase {

public function test_create_invoice(){
$strike = new LightningStrikeClient(getenv('STRIKE_URL'));
$invoice = $strike->invoice([ 'msatoshi' => 50, 'metadata' => [ 'customer' => 'Satoshi', 'products' => [ 'potato', 'chips' ] ] ]);
$charge = new LightningChargeClient(getenv('STRIKE_URL'));
$invoice = $charge->invoice([ 'msatoshi' => 50, 'metadata' => [ 'customer' => 'Satoshi', 'products' => [ 'potato', 'chips' ] ] ]);

$this->assertObjectHasAttribute('id', $invoice);
$this->assertObjectHasAttribute('rhash', $invoice);
Expand All @@ -16,9 +16,9 @@ public function test_create_invoice(){
}

public function test_fetch_invoice(){
$strike = new LightningStrikeClient(getenv('STRIKE_URL'));
$saved = $strike->invoice( [ 'msatoshi' => 50, 'metadata' => 'test_fetch_invoice' ]);
$loaded = $strike->fetch($saved->id);
$charge = new LightningChargeClient(getenv('STRIKE_URL'));
$saved = $charge->invoice( [ 'msatoshi' => 50, 'metadata' => 'test_fetch_invoice' ]);
$loaded = $charge->fetch($saved->id);

$this->assertEquals($saved->id, $loaded->id);
$this->assertEquals($saved->rhash, $loaded->rhash);
Expand All @@ -27,8 +27,8 @@ public function test_fetch_invoice(){
}

public function test_register_webhook(){
$strike = new LightningStrikeClient(getenv('STRIKE_URL'));
$invoice = $strike->invoice([ 'msatoshi' => 50 ]);
$this->assertTrue($strike->registerHook($invoice->id, 'http://example.com/'));
$charge = new LightningChargeClient(getenv('STRIKE_URL'));
$invoice = $charge->invoice([ 'msatoshi' => 50 ]);
$this->assertTrue($charge->registerHook($invoice->id, 'http://example.com/'));
}
}

0 comments on commit 72a3e33

Please sign in to comment.