getToken() public method

public getToken ( ) : string
return string
Example #1
0
 /**
  * @inheritdoc
  */
 public function getPayout($payoutId)
 {
     $request = $this->createNewRequest();
     $request->setMethod(Request::METHOD_GET);
     $request->setPath(sprintf('payouts/%s?token=%s', $payoutId, $this->token->getToken()));
     $this->addIdentityHeader($request);
     $this->addSignatureHeader($request);
     $this->request = $request;
     $this->response = $this->sendRequest($this->request);
     $body = json_decode($this->response->getBody(), true);
     if (empty($body['data'])) {
         throw new \Exception('Error with request');
     }
     $data = $body['data'];
     $payout = new \Bitpay\Payout();
     $payout->setId($data['id'])->setAccountId($data['account'])->setStatus($data['status'])->setCurrency(new \Bitpay\Currency($data['currency']))->setRate(@$data['rate'])->setAmount($data['amount'])->setBtcAmount(@$data['btc'])->setPricingMethod(@$data['pricingMethod'])->setReference(@$data['reference'])->setNotificationEmail(@$data['notificationEmail'])->setNotificationUrl(@$data['notificationURL'])->setRequestDate($data['requestDate'])->setEffectiveDate($data['effectiveDate'])->setResponseToken($data['token']);
     array_walk($data['instructions'], function ($value, $key) use(&$payout) {
         $instruction = new \Bitpay\PayoutInstruction();
         $instruction->setId($value['id'])->setLabel($value['label'])->setAddress($value['address'])->setStatus($value['status'])->setAmount($value['amount'])->setBtc($value['btc']);
         array_walk($value['transactions'], function ($value, $key) use(&$instruction) {
             $transaction = new \Bitpay\PayoutTransaction();
             $transaction->setTransactionId($value['txid'])->setAmount($value['amount'])->setDate($value['date']);
             $instruction->addTransaction($transaction);
         });
         $payout->addInstruction($instruction);
     });
     return $payout;
 }
Example #2
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;
 }