-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,883 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...g_pcp_btcpay/helpers/vendor/btcpayserver/btcpayserver-greenfield-php/examples/api_key.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use BTCPayServer\Client\ApiKey; | ||
|
||
// Fill in with your BTCPay Server data. | ||
$apiKey = ''; | ||
$host = ''; // e.g. https://your.btcpay-server.tld | ||
$userEmail = ''; | ||
$userId = ''; | ||
|
||
// Get information about store on BTCPay Server. | ||
try { | ||
$client = new ApiKey($host, $apiKey); | ||
var_dump($client->getCurrent()); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} | ||
/* | ||
print("\nCreate a new api key (needs server modify permission of used api).\n"); | ||
try { | ||
$client = new Apikey($host, $apiKey); | ||
var_dump($client->createApiKey('api generated', ['btcpay.store.canmodifystoresettings'])); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} | ||
*/ | ||
print("\nCreate a new api key for different user. Needs unrestricted access\n"); | ||
|
||
try { | ||
$client = new Apikey($host, $apiKey); | ||
$uKey = $client->createApiKeyForUser($userEmail, 'api generated to be deleted', ['btcpay.store.canmodifystoresettings']); | ||
var_dump($uKey); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} | ||
|
||
|
||
print("\nRevoke api key for different user.\n"); | ||
|
||
try { | ||
$client = new Apikey($host, $apiKey); | ||
$uKey = $client->revokeApiKeyForUser($userEmail, $uKey->getData()['apiKey']); | ||
var_dump($uKey); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} |
95 changes: 95 additions & 0 deletions
95
...tcpay/helpers/vendor/btcpayserver/btcpayserver-greenfield-php/examples/create_invoice.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
// Include autoload file. | ||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
// Import Invoice client class. | ||
use BTCPayServer\Client\Invoice; | ||
use BTCPayServer\Client\InvoiceCheckoutOptions; | ||
use BTCPayServer\Util\PreciseNumber; | ||
|
||
// Fill in with your BTCPay Server data. | ||
$apiKey = ''; | ||
$host = ''; | ||
$storeId = ''; | ||
$amount = 5.15 + mt_rand(0, 20); | ||
$currency = 'USD'; | ||
$orderId = 'Test39939' . mt_rand(0, 1000); | ||
$buyerEmail = 'john@example.com'; | ||
|
||
// Create a basic invoice. | ||
try { | ||
$client = new Invoice($host, $apiKey); | ||
var_dump( | ||
$client->createInvoice( | ||
$storeId, | ||
$currency, | ||
PreciseNumber::parseString($amount), | ||
$orderId, | ||
$buyerEmail | ||
) | ||
); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} | ||
|
||
// Create a more complex invoice with redirect url and metadata. | ||
try { | ||
$client = new Invoice($host, $apiKey); | ||
|
||
// Setup custom metadata. This will be visible in the invoice and can include | ||
// arbitrary data. Example below will show up on the invoice details page on | ||
// BTCPay Server. | ||
$metaData = [ | ||
'buyerName' => 'John Doe', | ||
'buyerAddress1' => '43 South Beech Rd.', | ||
'buyerAddress2' => 'Door 3', | ||
'buyerCity' => 'Mount Prospect', | ||
'buyerState' => 'IL', | ||
'buyerZip' => '60056', | ||
'buyerCountry' => 'USA', | ||
'buyerPhone' => '001555664123456', | ||
'posData' => 'Data shown on the invoice details go here. Can be JSON encoded string', | ||
'itemDesc' => 'Can be a description of the purchased item.', | ||
'itemCode' => 'Can be SKU or item number', | ||
'physical' => false, // indicates if physical product | ||
'taxIncluded' => 2.15, // tax amount (included in the total amount). | ||
]; | ||
|
||
// Setup custom checkout options, defaults get picked from store config. | ||
$checkoutOptions = new InvoiceCheckoutOptions(); | ||
$checkoutOptions | ||
->setSpeedPolicy($checkoutOptions::SPEED_HIGH) | ||
->setPaymentMethods(['BTC']) | ||
->setRedirectURL('https://shop.yourdomain.tld?order=38338'); | ||
|
||
var_dump( | ||
$client->createInvoice( | ||
$storeId, | ||
$currency, | ||
PreciseNumber::parseString($amount), | ||
$orderId, | ||
$buyerEmail, | ||
$metaData, | ||
$checkoutOptions | ||
) | ||
); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} | ||
|
||
// Create a top-up (0 initial amount) invoice. | ||
try { | ||
$client = new Invoice($host, $apiKey); | ||
var_dump( | ||
$client->createInvoice( | ||
$storeId, | ||
$currency, | ||
null, | ||
$orderId, | ||
$buyerEmail | ||
) | ||
); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} |
24 changes: 24 additions & 0 deletions
24
...p_btcpay/helpers/vendor/btcpayserver/btcpayserver-greenfield-php/examples/get_invoice.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
// Include autoload file. | ||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
// Import Invoice client class. | ||
use BTCPayServer\Client\Invoice; | ||
|
||
// Fill in with your BTCPay Server data. | ||
$apiKey = ''; | ||
$host = ''; // e.g. https://your.btcpay-server.tld | ||
$storeId = ''; | ||
$invoiceId = ''; | ||
|
||
// Get information about a specific invoice. | ||
try { | ||
echo 'Get invoice data:' . PHP_EOL; | ||
$client = new Invoice($host, $apiKey); | ||
var_dump($client->getInvoice($storeId, $invoiceId)); | ||
echo 'Get invoice payment methods:' . PHP_EOL; | ||
var_dump($client->getPaymentMethods($storeId, $invoiceId)); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} |
30 changes: 30 additions & 0 deletions
30
...lg_pcp_btcpay/helpers/vendor/btcpayserver/btcpayserver-greenfield-php/examples/health.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use BTCPayServer\Client\Health; | ||
|
||
class HealthClass | ||
{ | ||
public $apiKey; | ||
public $host; | ||
|
||
public function __construct() | ||
{ | ||
$this->apiKey = ''; | ||
$this->host = ''; | ||
} | ||
|
||
public function getHealthStatus() | ||
{ | ||
try { | ||
$client = new Health($this->host, $this->apiKey); | ||
var_dump($client->getHealthStatus()); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} | ||
} | ||
} | ||
|
||
$health = new HealthClass(); | ||
$health->getHealthStatus(); |
150 changes: 150 additions & 0 deletions
150
...pers/vendor/btcpayserver/btcpayserver-greenfield-php/examples/lightning_internal_node.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?php | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use BTCPayServer\Client\LightningInternalNode; | ||
|
||
class LightningInternalNodes | ||
{ | ||
public $apiKey; | ||
public $host; | ||
public $cryptoCode; | ||
|
||
public function __construct() | ||
{ | ||
$this->apiKey = ''; | ||
$this->host = ''; | ||
$this->cryptoCode = 'BTC'; | ||
} | ||
|
||
public function getNodeInformation() | ||
{ | ||
try { | ||
$client = new LightningInternalNode($this->host, $this->apiKey); | ||
var_dump($client->getNodeInformation( | ||
$this->cryptoCode | ||
)); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} | ||
} | ||
|
||
public function connectToLightningNode() | ||
{ | ||
$nodeURI = null; | ||
|
||
try { | ||
$client = new LightningInternalNode($this->host, $this->apiKey); | ||
var_dump($client->connectToLightningNode( | ||
$this->cryptoCode, | ||
$nodeURI | ||
)); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} | ||
} | ||
|
||
public function getChannels() | ||
{ | ||
try { | ||
$client = new LightningInternalNode($this->host, $this->apiKey); | ||
var_dump($client->getChannels( | ||
$this->cryptoCode | ||
)); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} | ||
} | ||
|
||
public function openChannel() | ||
{ | ||
$nodeURI = ''; | ||
$channelAmount = '100'; | ||
$feeRate = '1'; | ||
|
||
try { | ||
$client = new LightningInternalNode($this->host, $this->apiKey); | ||
var_dump($client->openChannel( | ||
$this->cryptoCode, | ||
$nodeURI, | ||
$channelAmount, | ||
$feeRate | ||
)); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} | ||
} | ||
|
||
public function getDepositAddress() | ||
{ | ||
try { | ||
$client = new LightningInternalNode($this->host, $this->apiKey); | ||
var_dump($client->getDepositAddress( | ||
$this->cryptoCode | ||
)); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} | ||
} | ||
|
||
public function getInvoice() | ||
{ | ||
$id = ''; | ||
|
||
try { | ||
$client = new LightningInternalNode($this->host, $this->apiKey); | ||
var_dump($client->getInvoice( | ||
$this->cryptoCode, | ||
$id | ||
)); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} | ||
} | ||
|
||
public function payLightningInvoice() | ||
{ | ||
$BOLT11 = ''; | ||
|
||
try { | ||
$client = new LightningInternalNode($this->host, $this->apiKey); | ||
var_dump($client->payLightningInvoice( | ||
$this->cryptoCode, | ||
$BOLT11 | ||
)); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} | ||
} | ||
|
||
public function createLightningInvoice() | ||
{ | ||
$amount = '1000000'; | ||
$description = 'test'; | ||
$expiry = 600; | ||
$privateRouteHints = false; | ||
|
||
try { | ||
$client = new LightningInternalNode($this->host, $this->apiKey); | ||
var_dump($client->createLightningInvoice( | ||
$this->cryptoCode, | ||
$amount, | ||
$expiry, | ||
$description, | ||
$privateRouteHints | ||
)); | ||
} catch (\Throwable $e) { | ||
echo "Error: " . $e->getMessage(); | ||
} | ||
} | ||
} | ||
|
||
$node = new LightningInternalNodes(); | ||
//$node->getNodeInformation(); | ||
//$node->connectToLightningNode(); | ||
//$node->getChannels(); | ||
//$node->openChannel(); | ||
//$node->getDepositAddress(); | ||
//$node->getInvoice(); | ||
//$node->payLightningInvoice(); | ||
//$node->createLightningInvoice(); |
Oops, something went wrong.