Example #1
0
 /**
  * @param Request\Request $request
  * @return array
  */
 public function buildHeader($request)
 {
     $date = gmdate('D, d M Y H:i:s T');
     $idempotencyKey = $request->getIdempotence() ? md5(uniqid(rand(), true)) : '';
     $signature = Middleware::generateSignature(parse_url($this->apiUrl, PHP_URL_HOST) . ':' . parse_url($this->apiUrl, PHP_URL_PORT), $request->getMethod(), parse_url($this->apiUrl . $request->getPath(), PHP_URL_PATH), parse_url($this->apiUrl, PHP_URL_QUERY), $date, $idempotencyKey, $request->getBody(), $this->paymentKey);
     $header = array("Host: " . parse_url($this->apiUrl, PHP_URL_HOST), "Date: " . $date, "User-Agent: " . $this->userAgent, "Authorization: BZ1-HMAC-SHA256 DivisionId=" . $this->divisionId . ", Signature=" . $signature);
     if ($idempotencyKey !== '') {
         $header[] = "Idempotency-Key: " . $idempotencyKey;
     }
     return $header;
 }