Merge pull request #4 from kakaska/fix-examples
Fix examples and tutorials
This commit is contained in:
commit
cc8e0bc689
@ -66,16 +66,31 @@ $currency->setCode('USD');
|
||||
$invoice->setCurrency($currency);
|
||||
|
||||
/**
|
||||
* Create a new client. You can see the example of how to configure this using
|
||||
* a yml file as well.
|
||||
* To load up keys that you have previously saved, you need to use the same
|
||||
* storage engine. You also need to tell it the location of the key you want
|
||||
* to load.
|
||||
*/
|
||||
$bitpay = new \Bitpay\Bitpay(__DIR__ . '/config.yml');
|
||||
$storageEngine = new \Bitpay\Storage\FilesystemStorage();
|
||||
$privateKey = $storageEngine->load('/tmp/private.key');
|
||||
$publicKey = $storageEngine->load('/tmp/public.key');
|
||||
|
||||
/**
|
||||
* Create a new client.
|
||||
*/
|
||||
$bitpay = new \Bitpay\Bitpay();
|
||||
|
||||
/**
|
||||
* Create the client that will be used to send requests to BitPay's API
|
||||
*/
|
||||
$client = $bitpay->get('client');
|
||||
|
||||
$client->setPrivateKey($privateKey);
|
||||
$client->setPublicKey($publicKey);
|
||||
/**
|
||||
* Add your btcpayserver url
|
||||
*/
|
||||
$client->setUri('https://btcpay.server/');
|
||||
|
||||
/**
|
||||
* You will need to set the token that was returned when you paired your
|
||||
* keys.
|
||||
|
||||
@ -44,16 +44,14 @@ $private->setHex('662be90968bc659873d723374213fa5bf7a30c24f0f0713aa798eb7daa7230
|
||||
$public = new \Bitpay\PublicKey();
|
||||
$public->generate($private);
|
||||
|
||||
$network = new \Bitpay\Network\Testnet();
|
||||
$adapter = new \Bitpay\Client\Adapter\CurlAdapter();
|
||||
|
||||
|
||||
$bitpay = new \Bitpay\Bitpay();
|
||||
|
||||
$client = new \Bitpay\Client\Client();
|
||||
$client->setPrivateKey($private);
|
||||
$client->setPublicKey($public);
|
||||
$client->setNetwork($network);
|
||||
$client->setUri('https://btcpay.server/');
|
||||
$client->setAdapter($adapter);
|
||||
|
||||
$client->createPayout($payout);
|
||||
|
||||
@ -7,6 +7,7 @@ require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$bitpay = new \Bitpay\Bitpay(__DIR__ . '/config.yml');
|
||||
$client = $bitpay->get('client');
|
||||
$client->setUri('https://btcpay.server/');
|
||||
$currencies = $client->getCurrencies();
|
||||
|
||||
/** @var \Bitpay\Currency $currencies[0] **/
|
||||
|
||||
@ -7,9 +7,8 @@ require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$client = new \Bitpay\Client\Client();
|
||||
$client->setAdapter(new \Bitpay\Client\Adapter\CurlAdapter());
|
||||
$client->setNetwork(new \Bitpay\Network\Testnet());
|
||||
$request = new \Bitpay\Client\Request();
|
||||
$request->setHost('test.bitpay.com');
|
||||
$request->setUri('https://btcpay.server/');
|
||||
$request->setMethod(\Bitpay\Client\Request::METHOD_GET);
|
||||
$request->setPath('rates/USD');
|
||||
|
||||
|
||||
@ -14,6 +14,14 @@
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
/**
|
||||
* To load up keys that you have previously saved, you need to use the same
|
||||
* storage engine. You also need to tell it the location of the key you want
|
||||
* to load.
|
||||
*/
|
||||
$storageEngine = new \Bitpay\Storage\FilesystemStorage();
|
||||
$privateKey = $storageEngine->load('/tmp/bitpay.pri');
|
||||
$publicKey = $storageEngine->load('/tmp/bitpay.pub');
|
||||
|
||||
/**
|
||||
* Create a new client. You can see the example of how to configure this using
|
||||
@ -22,7 +30,6 @@ require __DIR__ . '/../vendor/autoload.php';
|
||||
$bitpay = new \Bitpay\Bitpay(
|
||||
array(
|
||||
'bitpay' => array(
|
||||
'network' => 'testnet', // testnet or livenet, default is livenet
|
||||
'public_key' => '/tmp/bitpay.pub', //see tutorial/001.php and 002.php
|
||||
'private_key' => '/tmp/bitpay.pri',
|
||||
'key_storage' => 'Bitpay\Storage\EncryptedFilesystemStorage',
|
||||
@ -36,5 +43,12 @@ $bitpay = new \Bitpay\Bitpay(
|
||||
*/
|
||||
$client = $bitpay->get('client');
|
||||
|
||||
$client->setPrivateKey($privateKey);
|
||||
$client->setPublicKey($publicKey);
|
||||
/**
|
||||
* Add your btcpayserver url
|
||||
*/
|
||||
$client->setUri('https://btcpay.server/');
|
||||
|
||||
$tokens = $client->getTokens();
|
||||
print_r($tokens);
|
||||
|
||||
@ -5,9 +5,6 @@
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// When running bitpay on your local server
|
||||
$network = new Bitpay\Network\Customnet("127.0.0.1", 8088, true);
|
||||
|
||||
// Customize the curl options
|
||||
$curl_options = array(
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
|
||||
@ -28,15 +28,6 @@ $publicKey = $storageEngine->load('/tmp/bitpay.pub');
|
||||
*/
|
||||
$client = new \Bitpay\Client\Client();
|
||||
|
||||
/**
|
||||
* The network is either livenet or testnet. You can also create your
|
||||
* own as long as it implements the NetworkInterface. In this example
|
||||
* we will use testnet
|
||||
*/
|
||||
//$network = new \Bitpay\Network\Testnet();
|
||||
$network = new \Bitpay\Network\Livenet();
|
||||
|
||||
|
||||
/**
|
||||
* The adapter is what will make the calls to BitPay and return the response
|
||||
* from BitPay. This can be updated or changed as long as it implements the
|
||||
@ -49,7 +40,12 @@ $adapter = new \Bitpay\Client\Adapter\CurlAdapter();
|
||||
*/
|
||||
$client->setPrivateKey($privateKey);
|
||||
$client->setPublicKey($publicKey);
|
||||
$client->setNetwork($network);
|
||||
|
||||
/**
|
||||
* Add your btcpayserver url
|
||||
*/
|
||||
$client->setUri('https://btcpay.server/');
|
||||
|
||||
$client->setAdapter($adapter);
|
||||
|
||||
/**
|
||||
|
||||
@ -17,12 +17,10 @@ $storageEngine = new \Bitpay\Storage\EncryptedFilesystemStorage('YourTopSecretPa
|
||||
$privateKey = $storageEngine->load('/tmp/bitpay.pri');
|
||||
$publicKey = $storageEngine->load('/tmp/bitpay.pub');
|
||||
$client = new \Bitpay\Client\Client();
|
||||
//$network = new \Bitpay\Network\Testnet();
|
||||
$network = new \Bitpay\Network\Livenet();
|
||||
$adapter = new \Bitpay\Client\Adapter\CurlAdapter();
|
||||
$client->setPrivateKey($privateKey);
|
||||
$client->setPublicKey($publicKey);
|
||||
$client->setNetwork($network);
|
||||
$client->setUri('https://btcpay.server/');
|
||||
$client->setAdapter($adapter);
|
||||
// ---------------------------
|
||||
|
||||
|
||||
@ -19,11 +19,10 @@ $storageEngine = new \Bitpay\Storage\EncryptedFilesystemStorage('YourTopSecretPa
|
||||
$privateKey = $storageEngine->load('/tmp/bitpay.pri');
|
||||
$publicKey = $storageEngine->load('/tmp/bitpay.pub');
|
||||
$client = new \Bitpay\Client\Client();
|
||||
$network = new \Bitpay\Network\Testnet();
|
||||
$adapter = new \Bitpay\Client\Adapter\CurlAdapter();
|
||||
$client->setPrivateKey($privateKey);
|
||||
$client->setPublicKey($publicKey);
|
||||
$client->setNetwork($network);
|
||||
$client->setUri('https://btcpay.server/');
|
||||
$client->setAdapter($adapter);
|
||||
// ---------------------------
|
||||
|
||||
|
||||
@ -44,10 +44,8 @@ if (true === empty($ipn -> id)) {
|
||||
// This is needed, since the IPN does not contain any authentication
|
||||
|
||||
$client = new \Bitpay\Client\Client();
|
||||
$network = new \Bitpay\Network\Testnet();
|
||||
//$network = new \Bitpay\Network\Livenet();
|
||||
$adapter = new \Bitpay\Client\Adapter\CurlAdapter();
|
||||
$client->setNetwork($network);
|
||||
$client->setUri('https://btcpay.server/');
|
||||
$client->setAdapter($adapter);
|
||||
|
||||
$token = new \Bitpay\Token();
|
||||
@ -69,4 +67,3 @@ fwrite($myfile, "Raw IPN: ". $raw_post_data."\n");
|
||||
//Respond with HTTP 200, so BitPay knows the IPN has been received correctly
|
||||
//If BitPay receives <> HTTP 200, then BitPay will try to send the IPN again with increasing intervals for two more hours.
|
||||
header("HTTP/1.1 200 OK");
|
||||
?>
|
||||
@ -16,10 +16,8 @@ require __DIR__.'/../../vendor/autoload.php';
|
||||
// Now fetch the invoice from BitPay
|
||||
|
||||
$client = new \Bitpay\Client\Client();
|
||||
//$network = new \Bitpay\Network\Testnet();
|
||||
$network = new \Bitpay\Network\Livenet();
|
||||
$adapter = new \Bitpay\Client\Adapter\CurlAdapter();
|
||||
$client->setNetwork($network);
|
||||
$client->setUri('https://btcpay.server/');
|
||||
$client->setAdapter($adapter);
|
||||
|
||||
$token = new \Bitpay\Token();
|
||||
@ -38,5 +36,3 @@ echo (string) $request.PHP_EOL.PHP_EOL.PHP_EOL;
|
||||
echo (string) $response.PHP_EOL.PHP_EOL;
|
||||
|
||||
print_r($invoice);
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user