コード例 #1
0
 public function testServerMetaInfoHeaderFull()
 {
     // create a new CommunicatorConfiguration to not modify the field
     $communicatorConfiguration = new CommunicatorConfiguration($this->getApiKey(), $this->getApiSecret(), $this->getApiEndpoint(), 'Ingenico.Integrator');
     $communicatorConfiguration->setShoppingCartExtension(new ShoppingCartExtension('Ingenico.Creator', 'Extension', '1.0'));
     $requestHeaderGenerator = new RequestHeaderGenerator($communicatorConfiguration, 'GET', '/v1/consumer/ANDR%C3%89E/?q=na%20me');
     $requestHeaders = $requestHeaderGenerator->generateRequestHeaders();
     $serverMetaInfoJson = $requestHeaders['X-GCS-ServerMetaInfo'];
     $serverMetaInfo = json_decode(base64_decode($serverMetaInfoJson));
     $this->assertInstanceOf('\\stdClass', $serverMetaInfo);
     $this->assertObjectHasAttribute('platformIdentifier', $serverMetaInfo);
     $this->assertContains(php_uname(), $serverMetaInfo->platformIdentifier);
     $this->assertContains(phpversion(), $serverMetaInfo->platformIdentifier);
     $this->assertObjectHasAttribute('sdkIdentifier', $serverMetaInfo);
     $this->assertEquals('PHPServerSDK/v' . RequestHeaderGenerator::SDK_VERSION, $serverMetaInfo->sdkIdentifier);
     $this->assertObjectHasAttribute('sdkCreator', $serverMetaInfo);
     $this->assertEquals('Ingenico', $serverMetaInfo->sdkCreator);
     $this->assertObjectHasAttribute('integrator', $serverMetaInfo);
     $this->assertEquals('Ingenico.Integrator', $serverMetaInfo->integrator);
     $this->assertObjectHasAttribute('shoppingCartExtension', $serverMetaInfo);
     $this->assertInstanceOf('\\stdClass', $serverMetaInfo->shoppingCartExtension);
     $this->assertObjectHasAttribute('creator', $serverMetaInfo->shoppingCartExtension);
     $this->assertEquals('Ingenico.Creator', $serverMetaInfo->shoppingCartExtension->creator);
     $this->assertObjectHasAttribute('name', $serverMetaInfo->shoppingCartExtension);
     $this->assertEquals('Extension', $serverMetaInfo->shoppingCartExtension->name);
     $this->assertObjectHasAttribute('version', $serverMetaInfo->shoppingCartExtension);
     $this->assertEquals('1.0', $serverMetaInfo->shoppingCartExtension->version);
 }
コード例 #2
0
 /**
  * @param $relativeUriPath
  * @param RequestObject|null $requestParameters
  * @return string
  * @throws Exception
  */
 protected function getRequestUri($relativeUriPath, RequestObject $requestParameters = null)
 {
     return $this->communicatorConfiguration->getApiEndpoint() . $this->getRelativeUriPathWithRequestParameters($relativeUriPath, $requestParameters);
 }
コード例 #3
0
 /**
  * @param string[] $requestHeaders
  * @return string
  */
 protected function getAuthorizationHeaderValue($requestHeaders)
 {
     return static::AUTHORIZATION_ID . ' ' . static::AUTHORIZATION_TYPE . ':' . $this->communicatorConfiguration->getApiKeyId() . ':' . base64_encode(hash_hmac(static::HASH_ALGORITHM, $this->getSignData($requestHeaders), $this->communicatorConfiguration->getApiSecret(), true));
 }