Exemple #1
0
 public function create(string $uri, array $query)
 {
     $query = Query::createFromPairs($query);
     $uri = Http::createFromString($uri);
     $modifier = new MergeQuery($query->__toString());
     return (string) $modifier->__invoke($uri);
 }
Exemple #2
0
 /**
  * @param HttpUri $uri
  * @param array $query
  *
  * @return HttpUri
  */
 protected function addQueryToUri(HttpUri $uri, array $query)
 {
     $query = array_replace($uri->query->toArray(), $query);
     $query = array_filter($query, function ($value) {
         return null !== $value;
     });
     return $uri->withQuery((string) Query::createFromArray($query));
 }
 /**
  * {@inheritDoc}
  *
  * @param Capture $request
  */
 public function execute($request)
 {
     RequestNotSupportedException::assertSupports($this, $request);
     $this->gateway->execute($httpRequest = new GetHttpRequest());
     //we are back from be2bill site so we have to just update model.
     if (empty($httpRequest->query['EXTRADATA'])) {
         throw new HttpResponse('The capture is invalid. Code Be2Bell1', 400);
     }
     $extraDataJson = $httpRequest->query['EXTRADATA'];
     if (false == ($extraData = json_decode($extraDataJson, true))) {
         throw new HttpResponse('The capture is invalid. Code Be2Bell2', 400);
     }
     if (empty($extraData['capture_token'])) {
         throw new HttpResponse('The capture is invalid. Code Be2Bell3', 400);
     }
     $this->gateway->execute($getToken = new GetToken($extraData['capture_token']));
     $uri = HttpUri::createFromString($getToken->getToken()->getTargetUrl());
     $uri = $uri->withQuery((string) Query::createFromArray($httpRequest->query));
     throw new HttpRedirect((string) $uri);
 }
 /**
  * Creates a hash based on request parameters.
  *
  * @param string                      $path
  * @param League\Uri\Components\Query $query
  *
  * @return string
  */
 private function generateMac($path, Query $query)
 {
     // build query string from given parameters
     $queryString = (string) $query;
     // combine strings to build the signing string
     $apiId = $query->getValue('api_id');
     $apiTs = $query->getValue('api_ts');
     $signingString = $apiId . "\n" . $apiTs . "\n" . $path . "\n" . $queryString;
     $mac = hash_hmac('sha1', $signingString, $this->secret);
     return $mac;
 }
Exemple #5
0
 /**
  * @param $url
  * @param array $params
  * @return string
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @throws InvalidConfigException
  */
 public function signUrl($url, array $params = [])
 {
     $uri = Http::createFromString($url);
     $paramsQuery = Query::createFromArray($params);
     $path = $uri->getPath();
     $query = $uri->query->merge($paramsQuery);
     $signature = $this->getHttpSignature()->generateSignature($path, $query->toArray());
     $query = $query->merge(Query::createFromArray(['s' => $signature]));
     $uri = $uri->withQuery((string) $query);
     return (string) $uri;
 }