setNetwork() public method

The network is either livenet or testnet and tells the client where to send the requests.
public setNetwork ( Bitpay\Network\NetworkInterface $network )
$network Bitpay\Network\NetworkInterface
Ejemplo n.º 1
0
 public function confirmBitPayInvoice($bitPayInvoice)
 {
     $storageEngine = new Bitpay\Storage\FilesystemStorage();
     if (_BIT_PAY_PRODUCTION_) {
         $privateKey = $storageEngine->load('/tmp/bitpay.pri');
         $publicKey = $storageEngine->load('/tmp/bitpay.pub');
     } else {
         $privateKey = $storageEngine->load('/tmp/bitpaydev.pri');
         $publicKey = $storageEngine->load('/tmp/bitpaydev.pub');
     }
     $client = new Bitpay\Client\Client();
     if (_BIT_PAY_PRODUCTION_) {
         $network = new Bitpay\Network\Livenet();
     } else {
         $network = new Bitpay\Network\Testnet();
     }
     $adapter = new Bitpay\Client\Adapter\CurlAdapter();
     $client->setPrivateKey($privateKey);
     $client->setPublicKey($publicKey);
     $client->setNetwork($network);
     $client->setAdapter($adapter);
     $token = new Bitpay\Token();
     if (_BIT_PAY_PRODUCTION_) {
         $token->setToken(_BIT_PAY_TOKEN_LIVE_NET_);
     } else {
         $token->setToken(_BIT_PAY_TOKEN_TEST_NET_);
     }
     $client->setToken($token);
     $invoice = $client->getInvoice($bitPayInvoice);
     return $invoice->getStatus();
 }