Bitpay\Client\Client::getResponse PHP Method

getResponse() public method

Returns the Response object that BitPay returned from the request that was sent
public getResponse ( ) : Bitpay\Client\ResponseInterface
return Bitpay\Client\ResponseInterface
    public function getResponse()
    {
        return $this->response;
    }

Usage Example

 public function createBitPayInvoice($invoiceList, $amount)
 {
     if ($invoiceList != '' && !empty($amount)) {
         $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);
         $item = new Bitpay\Item();
         $item->setCode($invoiceList);
         $item->setDescription('');
         $item->setPrice($amount);
         $invoice = new Bitpay\Invoice();
         $invoice->setItem($item);
         $invoice->setPosData('{"invoiceList": "' . $invoiceList . '", "amount": "' . $amount . '", "userID": ' . $this->userID . '}');
         $invoice->setNotificationUrl(_DOMAIN_API_HOST_ . '/bit-pay-ipn/');
         $invoice->setCurrency(new Bitpay\Currency('USD'));
         try {
             $client->createInvoice($invoice);
         } catch (\Exception $e) {
             // todo: record failure somewhere? and turn off bitPay until problem is fixed
             //PaymentSystemData::turnOffBitPay(); cant turn it off unless we open up the IPN Need to decide.
             $error = array('Request' => $client->getRequest(), 'Response' => $client->getResponse());
             file_put_contents('bitPayError.txt', print_r($error, true));
         }
         return $invoice->getUrl();
     }
     return false;
 }