diff --git a/composer.json b/composer.json index 76843b2..bc5a768 100644 --- a/composer.json +++ b/composer.json @@ -2,12 +2,13 @@ "name": "payvision/payvision-sdk-php", "description": "Payvision PHP SDK", "type": "library", - "version": "2.0.0", + "version": "2.0.1", "license": "MIT", "require": { "php": "^7.0.13|^7.1", "ext-simplexml": "*", "ext-json": "*", + "ext-curl": "*", "guzzlehttp/guzzle": "^6.3", "firebase/php-jwt": "^5.0" }, diff --git a/src/Application/Request/Builder.php b/src/Application/Request/Builder.php index 55cd951..169ed30 100644 --- a/src/Application/Request/Builder.php +++ b/src/Application/Request/Builder.php @@ -18,6 +18,7 @@ class Builder { /** + * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint * @param object $object * @return array * @throws ReflectionException @@ -28,6 +29,7 @@ public static function toArray($object): array } /** + * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint * @param object $object * @return array * @throws ReflectionException @@ -61,6 +63,7 @@ private static function reflectObject($object): array } /** + * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint * @param string $methodName * @param object $object * @return mixed|null diff --git a/src/Domain/Service/Builder.php b/src/Domain/Service/Builder.php index 23c1181..0b37fd7 100644 --- a/src/Domain/Service/Builder.php +++ b/src/Domain/Service/Builder.php @@ -12,6 +12,7 @@ interface Builder { /** + * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint * @return object */ public function build(); diff --git a/src/Domain/Service/Builder/Basic.php b/src/Domain/Service/Builder/Basic.php index 1671632..4ad9501 100644 --- a/src/Domain/Service/Builder/Basic.php +++ b/src/Domain/Service/Builder/Basic.php @@ -25,6 +25,7 @@ public function __construct() } /** + * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint * @return object */ final protected function buildAndReset() @@ -87,6 +88,7 @@ protected function validateRequiredProperties(array $properties) } /** + * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint * @return object */ abstract protected function buildObject(); diff --git a/src/Exception/Api/ErrorResponse.php b/src/Exception/Api/ErrorResponse.php index 1b602da..b748397 100644 --- a/src/Exception/Api/ErrorResponse.php +++ b/src/Exception/Api/ErrorResponse.php @@ -23,6 +23,7 @@ class ErrorResponse extends ApiException /** * ErrorResponse constructor. * + * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint * @param object $errorResponse * @param string $message * @param int $code @@ -39,6 +40,7 @@ public function __construct( } /** + * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint * @return object */ public function getErrorResponse() diff --git a/src/Infrastructure/ApiConnection.php b/src/Infrastructure/ApiConnection.php index 1330b34..8979a6a 100644 --- a/src/Infrastructure/ApiConnection.php +++ b/src/Infrastructure/ApiConnection.php @@ -110,9 +110,7 @@ private function get(Request $request): array { $guzzleResponse = $this->client->get( $request->getUri(), - [ - 'query' => $request->getPathParams(), - ] + $this->buildRequestArray($request) ); $this->lastJsonRequest = $request->getPathParams(); @@ -142,10 +140,7 @@ private function post(Request $request): array $jsonRequest = $this->prepareJsonRequest($request); $guzzleResponse = $this->client->post( $request->getUri(), - [ - 'json' => $jsonRequest, - 'query' => $request->getPathParams(), - ] + $this->buildRequestArray($request, $jsonRequest) ); $this->lastJsonRequest = $jsonRequest; @@ -289,4 +284,25 @@ private function prepareJsonRequest(Request $request): array return $jsonRequest; } + + /** + * @param Request $request + * @param array $jsonRequest + * @return array + */ + private function buildRequestArray(Request $request, array $jsonRequest = null): array + { + $returnValue = [ + 'query' => $request->getPathParams(), + 'curl' => [ + \CURLOPT_SSL_CIPHER_LIST => 'DEFAULT@SECLEVEL=1', + ], + ]; + + if ($jsonRequest !== null) { + $returnValue['json'] = $jsonRequest; + } + + return $returnValue; + } } diff --git a/tests/Test/Unit/Application/Request/BuilderTest.php b/tests/Test/Unit/Application/Request/BuilderTest.php index f526056..300ca00 100644 --- a/tests/Test/Unit/Application/Request/BuilderTest.php +++ b/tests/Test/Unit/Application/Request/BuilderTest.php @@ -54,13 +54,13 @@ protected function setUp() */ public function testBasicReflection() { - $card = new PaymentRequestCard('001', 10, 2020, 'ISAAC', '123', '456'); + $card = new PaymentRequestCard('001', 10, 2020, 'Foo', '123', '456'); $result = Builder::toArray($card); $this->assertEquals([ 'cvv' => '001', 'expiryMonth' => '10', 'expiryYear' => '2020', - 'holderName' => 'ISAAC', + 'holderName' => 'Foo', 'issueNumber' => '123', 'number' => '456', ], $result); diff --git a/tests/Test/Unit/Infrastructure/ApiConnectionTest.php b/tests/Test/Unit/Infrastructure/ApiConnectionTest.php index b00a3f4..bee019a 100644 --- a/tests/Test/Unit/Infrastructure/ApiConnectionTest.php +++ b/tests/Test/Unit/Infrastructure/ApiConnectionTest.php @@ -113,6 +113,9 @@ public function testPostRequest() 'query' => [ 'id' => '67890', ], + 'curl' => [ + \CURLOPT_SSL_CIPHER_LIST => 'DEFAULT@SECLEVEL=1', + ], ] ); $this->mockedResponse->method('getStatusCode')->willReturn(200); @@ -157,6 +160,9 @@ public function testGetRequest() 'query' => [ 'id' => '67890', ], + 'curl' => [ + \CURLOPT_SSL_CIPHER_LIST => 'DEFAULT@SECLEVEL=1', + ], ] ); $this->mockedResponse->method('getStatusCode')->willReturn(200); @@ -286,6 +292,9 @@ public function testTolerantReader() 'query' => [ 'id' => '67890', ], + 'curl' => [ + \CURLOPT_SSL_CIPHER_LIST => 'DEFAULT@SECLEVEL=1', + ], ] ); $this->mockedResponse->method('getStatusCode')->willReturn(200); @@ -344,6 +353,9 @@ public function testExceptionOnMissingRequiredField() 'query' => [ 'id' => '67890', ], + 'curl' => [ + \CURLOPT_SSL_CIPHER_LIST => 'DEFAULT@SECLEVEL=1', + ], ] ); $this->mockedResponse->method('getStatusCode')->willReturn(200);