From 10dc94cfdd71a1d92c55a687164889e907502622 Mon Sep 17 00:00:00 2001 From: Ian Paterson Date: Fri, 2 Nov 2018 11:54:02 -0400 Subject: [PATCH 01/11] Update omnipay --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 71bfc3a..43601ff 100644 --- a/composer.json +++ b/composer.json @@ -23,10 +23,11 @@ "psr-4": { "Omnipay\\Beanstream\\" : "src/" } }, "require": { - "omnipay/common": "~2.0" + "omnipay/common": "^3", + "php-http/buzz-adapter": "^1.0" }, "require-dev": { - "omnipay/tests": "~2.0" + "omnipay/tests": "^3.1" }, "extra": { "branch-alias": { From 821e3d266f710cef85942193ae1289fa17ef18e2 Mon Sep 17 00:00:00 2001 From: Ian Paterson Date: Thu, 8 Nov 2018 11:16:02 -0500 Subject: [PATCH 02/11] Update credit card expiry date --- tests/Message/AuthorizeRequestTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Message/AuthorizeRequestTest.php b/tests/Message/AuthorizeRequestTest.php index 68f5d28..b82c966 100644 --- a/tests/Message/AuthorizeRequestTest.php +++ b/tests/Message/AuthorizeRequestTest.php @@ -186,7 +186,7 @@ public function testComplete() 'number' => '4111111111111111', 'cvd' => '123', 'expiry_month' => '01', - 'expiry_year' => '2018' + 'expiry_year' => '2019' ); $this->request->setCard($card); From 7002bd2860274d845f7e321ba1e99221114bdd09 Mon Sep 17 00:00:00 2001 From: Ian Paterson Date: Thu, 8 Nov 2018 11:16:54 -0500 Subject: [PATCH 03/11] Alter AbstractRequest to send requests successfully --- src/Message/AbstractRequest.php | 38 +++++++++++---------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index caa103f..cb7e9e5 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -148,40 +148,28 @@ public function sendData($data) { $header = base64_encode($this->getMerchantId() . ':' . $this->getApiPasscode()); // Don't throw exceptions for 4xx errors - $this->httpClient->getEventDispatcher()->addListener( - 'request.error', - function ($event) { - if ($event['response']->isClientError()) { - $event->stopPropagation(); - } - } - ); - + if (!empty($data)) { - $httpRequest = $this->httpClient->createRequest( + $httpResponse = $this->httpClient->request( $this->getHttpMethod(), $this->getEndpoint(), - null, + [ + 'Content-Type' => 'application/json', + 'Authorization' => 'Passcode ' . $header, + ], json_encode($data) ); } else { - $httpRequest = $this->httpClient->createRequest( + $httpResponse = $this->httpClient->request( $this->getHttpMethod(), - $this->getEndpoint() + $this->getEndpoint(), + [ + 'Content-Type' => 'application/json', + 'Authorization' => 'Passcode ' . $header, + ] ); } - $httpResponse = $httpRequest - ->setHeader( - 'Content-Type', - 'application/json' - ) - ->setHeader( - 'Authorization', - 'Passcode ' . $header - ) - ->send(); - - return $this->response = new Response($this, $httpResponse->json()); + return $this->response = new Response($this, $httpResponse->getBody()->getContents()); } } From fadc0315fef40265f1963bd071529f126f5d16c7 Mon Sep 17 00:00:00 2001 From: Ian Paterson Date: Thu, 8 Nov 2018 11:20:24 -0500 Subject: [PATCH 04/11] Alter AbstractProfileRequest to send requests successfully --- src/Message/AbstractProfileRequest.php | 39 +++++++++----------------- src/Message/AbstractRequest.php | 1 - 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/src/Message/AbstractProfileRequest.php b/src/Message/AbstractProfileRequest.php index d9db67f..37391e8 100644 --- a/src/Message/AbstractProfileRequest.php +++ b/src/Message/AbstractProfileRequest.php @@ -37,41 +37,28 @@ public function setComment($value) public function sendData($data) { $header = base64_encode($this->getMerchantId() . ':' . $this->getApiPasscode()); - // Don't throw exceptions for 4xx errors - $this->httpClient->getEventDispatcher()->addListener( - 'request.error', - function ($event) { - if ($event['response']->isClientError()) { - $event->stopPropagation(); - } - } - ); - + if (!empty($data)) { - $httpRequest = $this->httpClient->createRequest( + $httpResponse = $this->httpClient->request( $this->getHttpMethod(), $this->getEndpoint(), - null, + [ + 'Content-Type' => 'application/json', + 'Authorization' => 'Passcode ' . $header, + ], json_encode($data) ); } else { - $httpRequest = $this->httpClient->createRequest( + $httpResponse = $this->httpClient->request( $this->getHttpMethod(), - $this->getEndpoint() + $this->getEndpoint(), + [ + 'Content-Type' => 'application/json', + 'Authorization' => 'Passcode ' . $header, + ] ); } - $httpResponse = $httpRequest - ->setHeader( - 'Content-Type', - 'application/json' - ) - ->setHeader( - 'Authorization', - 'Passcode ' . $header - ) - ->send(); - - return $this->response = new ProfileResponse($this, $httpResponse->json()); + return $this->response = new Response($this, $httpResponse->getBody()->getContents()); } } diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index cb7e9e5..1258d23 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -147,7 +147,6 @@ public function getHttpMethod() public function sendData($data) { $header = base64_encode($this->getMerchantId() . ':' . $this->getApiPasscode()); - // Don't throw exceptions for 4xx errors if (!empty($data)) { $httpResponse = $this->httpClient->request( From 8ca16fdf4b3ef93561aa1f1c5d5b18972f9ecc7a Mon Sep 17 00:00:00 2001 From: Ian Paterson Date: Thu, 8 Nov 2018 11:21:58 -0500 Subject: [PATCH 05/11] Update credit card expiry --- tests/Message/AuthorizeRequestTest.php | 2 +- tests/Message/PurchaseRequestTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Message/AuthorizeRequestTest.php b/tests/Message/AuthorizeRequestTest.php index b82c966..8496e0c 100644 --- a/tests/Message/AuthorizeRequestTest.php +++ b/tests/Message/AuthorizeRequestTest.php @@ -186,7 +186,7 @@ public function testComplete() 'number' => '4111111111111111', 'cvd' => '123', 'expiry_month' => '01', - 'expiry_year' => '2019' + 'expiry_year' => '2020' ); $this->request->setCard($card); diff --git a/tests/Message/PurchaseRequestTest.php b/tests/Message/PurchaseRequestTest.php index 45eb147..42a610a 100644 --- a/tests/Message/PurchaseRequestTest.php +++ b/tests/Message/PurchaseRequestTest.php @@ -174,7 +174,7 @@ public function testComplete() 'number' => '4111111111111111', 'cvd' => '123', 'expiry_month' => '01', - 'expiry_year' => '2018' + 'expiry_year' => '2020' ); $this->request->setCard($card); From b1a341d8deddb265ddfb72d0796dbd3a2a3ed678 Mon Sep 17 00:00:00 2001 From: Ian Paterson Date: Thu, 8 Nov 2018 13:44:16 -0500 Subject: [PATCH 06/11] Update response to parse data to array --- src/Message/Response.php | 6 ++++++ tests/Message/ResponseTest.php | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Message/Response.php b/src/Message/Response.php index 8be4967..87d85c0 100644 --- a/src/Message/Response.php +++ b/src/Message/Response.php @@ -5,6 +5,12 @@ class Response extends AbstractResponse { + public function __construct(RequestInterface $request, $data) + { + $this->request = $request; + parse_str($data, $this->data); + } + public function isSuccessful() { return (isset($this->data['approved']) && $this->data['approved'] === "1"); diff --git a/tests/Message/ResponseTest.php b/tests/Message/ResponseTest.php index 1181e6f..c690673 100644 --- a/tests/Message/ResponseTest.php +++ b/tests/Message/ResponseTest.php @@ -9,7 +9,7 @@ class ResponseTest extends TestCase public function testPurchaseSuccess() { $httpResponse = $this->getMockHttpResponse('PurchaseSuccess.txt'); - $response = new Response($this->getMockRequest(), $httpResponse->json()); + $response = new Response($this->getMockRequest(), $httpResponse->getBody()); $this->assertTrue($response->isSuccessful()); $this->assertSame('1000001', $response->getTransactionReference()); $this->assertSame('1', $response->getOrderNumber()); @@ -30,7 +30,7 @@ public function testPurchaseSuccess() public function testPurchaseFailure() { $httpResponse = $this->getMockHttpResponse('PurchaseFailure.txt'); - $response = new Response($this->getMockRequest(), $httpResponse->json()); + $response = new Response($this->getMockRequest(), $httpResponse->getBody()); $this->assertSame(49, $response->getCode()); $this->assertSame(3, $response->getCategory()); $this->assertSame('Invalid transaction request string', $response->getMessage()); @@ -48,7 +48,7 @@ public function testPurchaseFailure() public function testAuthorizeSuccess() { $httpResponse = $this->getMockHttpResponse('AuthorizeSuccess.txt'); - $response = new Response($this->getMockRequest(), $httpResponse->json()); + $response = new Response($this->getMockRequest(), $httpResponse->getBody()); $this->assertTrue($response->isSuccessful()); $this->assertSame('1000001', $response->getTransactionReference()); $this->assertSame('1', $response->getOrderNumber()); @@ -69,7 +69,7 @@ public function testAuthorizeSuccess() public function testAuthorizeFailure() { $httpResponse = $this->getMockHttpResponse('AuthorizeFailure.txt'); - $response = new Response($this->getMockRequest(), $httpResponse->json()); + $response = new Response($this->getMockRequest(), $httpResponse->getBody()); $this->assertSame(49, $response->getCode()); $this->assertSame(3, $response->getCategory()); $this->assertSame('Invalid transaction request string', $response->getMessage()); From d9fb22794caca0092dda9d27df46c69bf3829657 Mon Sep 17 00:00:00 2001 From: Ian Paterson Date: Thu, 8 Nov 2018 14:35:39 -0500 Subject: [PATCH 07/11] Convert json to array in response --- src/Message/Response.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Message/Response.php b/src/Message/Response.php index 87d85c0..46832e5 100644 --- a/src/Message/Response.php +++ b/src/Message/Response.php @@ -8,7 +8,7 @@ class Response extends AbstractResponse public function __construct(RequestInterface $request, $data) { $this->request = $request; - parse_str($data, $this->data); + $this->data = json_decode($data, true); } public function isSuccessful() From f3a6278a8ba851f3453cea8bde41555ba549f489 Mon Sep 17 00:00:00 2001 From: Ian Paterson Date: Thu, 8 Nov 2018 14:51:16 -0500 Subject: [PATCH 08/11] Use ProfileResponse instead of Response --- src/Message/AbstractProfileRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Message/AbstractProfileRequest.php b/src/Message/AbstractProfileRequest.php index 37391e8..e84cd67 100644 --- a/src/Message/AbstractProfileRequest.php +++ b/src/Message/AbstractProfileRequest.php @@ -59,6 +59,6 @@ public function sendData($data) ); } - return $this->response = new Response($this, $httpResponse->getBody()->getContents()); + return $this->response = new ProfileResponse($this, $httpResponse->getBody()->getContents()); } } From f2e5c2f8c0b3cd7bad323728208ca5b63ccacf70 Mon Sep 17 00:00:00 2001 From: Kyle Charlebois Date: Fri, 25 Jan 2019 11:15:50 -0500 Subject: [PATCH 09/11] update travis yml --- .travis.yml | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0dfa3e6..8f96ad7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,35 @@ language: php php: - - 5.3 - - 5.4 - - 5.5 - 5.6 - - hhvm + - 7.0 + - 7.1 + - 7.2 + - 7.3 -before_script: - - composer install -n --dev --prefer-source - - composer require satooshi/php-coveralls --dev +# This triggers builds to run on the new TravisCI infrastructure. +# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/ +sudo: false -script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml +## Cache composer +cache: + directories: + - $HOME/.composer/cache -after_script: -- php vendor/bin/coveralls -v +env: + global: + - symfony="*" + +matrix: + include: + - php: 5.6 + env: symfony="^2.1" + - php: 5.6 + env: symfony="^3" + - php: 7.1 + env: symfony="^4" + +install: + - if [[ $symfony != '*' ]]; then travis_retry composer require symfony/http-foundation:${symfony} --no-update --no-interaction; fi + +script: composer install --prefer-dist --no-interaction From d9d34501cf5af708ccfe2513b5c625f14de19afd Mon Sep 17 00:00:00 2001 From: Tymek Date: Fri, 25 Jan 2019 11:32:35 -0500 Subject: [PATCH 10/11] update composer.json - require php ^5.6 or ^7 - set branch-alias to v3 - add 'prefer-stable' --- composer.json | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 43601ff..d27c0ff 100644 --- a/composer.json +++ b/composer.json @@ -23,15 +23,17 @@ "psr-4": { "Omnipay\\Beanstream\\" : "src/" } }, "require": { + "php": "^5.6|^7", "omnipay/common": "^3", - "php-http/buzz-adapter": "^1.0" + "php-http/guzzle6-adapter": "^1.1" }, "require-dev": { "omnipay/tests": "^3.1" }, "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0.x-dev" } - } + }, + "prefer-stable": true } From 935bbf914f02221f7c97f6169c2bf7efc2c95137 Mon Sep 17 00:00:00 2001 From: Tymek Date: Fri, 25 Jan 2019 15:45:39 -0500 Subject: [PATCH 11/11] removed Mockery\Adapter\Phpunit\TestListener in phpunit.xml.dist as mentioned in [omnipay-common/Upgrade.md](https://github.com/thephpleague/omnipay-common/blob/master/UPGRADE.md) --- phpunit.xml.dist | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a35b736..535809e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,9 +14,6 @@ ./tests/ - - - ./src