Example #1
0
 /**
  * @inheritdoc
  */
 public function getInvoice($invoiceId)
 {
     $this->request = $this->createNewRequest();
     $this->request->setMethod(Request::METHOD_GET);
     if ($this->token->getFacade() === 'merchant') {
         $this->request->setPath(sprintf('invoices/%s?token=%s', $invoiceId, $this->token->getToken()));
         $this->addIdentityHeader($this->request);
         $this->addSignatureHeader($this->request);
     } else {
         $this->request->setPath(sprintf('invoices/%s', $invoiceId));
     }
     $this->response = $this->sendRequest($this->request);
     $body = json_decode($this->response->getBody(), true);
     if (isset($body['error'])) {
         throw new \Exception($body['error']);
     }
     $data = $body['data'];
     $invoice = new \Bitpay\Invoice();
     $invoiceToken = new \Bitpay\Token();
     $paymentUrls = new \Bitpay\PaymentUrlSet();
     $invoice->setToken($invoiceToken->setToken($data['token']))->setUrl($data['url'])->setPosData($data['posData'])->setStatus($data['status'])->setBtcPrice($data['btcPrice'])->setPrice($data['price'])->setCurrency(new \Bitpay\Currency($data['currency']))->setOrderId($data['orderId'])->setInvoiceTime($data['invoiceTime'])->setExpirationTime($data['expirationTime'])->setCurrentTime($data['currentTime'])->setId($data['id'])->setBtcPaid($data['btcPaid'])->setRate($data['rate'])->setExceptionStatus($data['exceptionStatus']);
     if (isset($data['paymentUrls'])) {
         $invoice->setPaymentUrls($paymentUrls->setUrls($data['paymentUrls']));
     }
     return $invoice;
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function getInvoice($invoiceId)
 {
     $this->request = $this->createNewRequest();
     $this->request->setMethod(Request::METHOD_GET);
     $this->request->setPath(sprintf('invoices/%s', $invoiceId));
     $this->response = $this->sendRequest($this->request);
     $body = json_decode($this->response->getBody(), true);
     if (isset($body['error'])) {
         throw new \Exception($body['error']);
     }
     $data = $body['data'];
     $invoice = new \Bitpay\Invoice();
     $invoice->setUrl($data['url'])->setPosData($data['posData'])->setStatus($data['status'])->setBtcPrice($data['btcPrice'])->setPrice($data['price'])->setCurrency(new \Bitpay\Currency($data['currency']))->setOrderId($data['orderId'])->setInvoiceTime($data['invoiceTime'])->setExpirationTime($data['expirationTime'])->setCurrentTime($data['currentTime'])->setId($data['id'])->setBtcPaid($data['btcPrice'])->setRate($data['rate'])->setExceptionStatus($data['exceptionStatus']);
     return $invoice;
 }