From cdd24a388a65556a1403754bbadd27033a65ed8a Mon Sep 17 00:00:00 2001 From: Payetus Date: Sun, 14 Mar 2021 20:39:04 +0100 Subject: [PATCH 1/3] fix: updates dependencies to adapt to guzzle7-adapter --- composer.json | 4 ++-- tests/Unit/ClientFactoryTest.php | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index f51c5b3..ff6b8eb 100644 --- a/composer.json +++ b/composer.json @@ -11,14 +11,14 @@ ], "require": { "php": "^5.5|>=7.0.8", - "php-http/client-common": "^1.6", + "php-http/client-common": "^2.0", "php-http/discovery": "^1.3" }, "require-dev": { "phpunit/phpunit": "<6.0", "php-http/mock-client": "^1.0", "guzzlehttp/psr7": "^1.0", - "php-http/guzzle6-adapter": "^1.1" + "php-http/guzzle7-adapter": "^1.0" }, "suggest": { "guzzlehttp/guzzle": "Implements a required PSR-7 Http client" diff --git a/tests/Unit/ClientFactoryTest.php b/tests/Unit/ClientFactoryTest.php index 10b929d..7a77786 100644 --- a/tests/Unit/ClientFactoryTest.php +++ b/tests/Unit/ClientFactoryTest.php @@ -101,12 +101,21 @@ public function tryCreteApiClient() $apiClientFactory = new ClientFactoryTestClass( $this->prophesize(RequestFactory::class)->reveal(), $this->prophesize(DiscoveryProxy::class)->reveal(), 'api-key', 'api-url' ); + $uriMock = $this->prophesize(UriInterface::class); + $uriMock + ->getPath() + ->shouldBeCalled() + ->willReturn("api-url"); + $uriMock + ->getHost() + ->shouldBeCalled() + ->willReturn("host"); $uriFactoryMock = $this->prophesize(UriFactory::class); $uriFactoryMock ->createUri('api-url') ->shouldBeCalled() - ->willReturn($this->prophesize(UriInterface::class)->reveal()); + ->willReturn($uriMock->reveal()); $httpClientMock = $this->prophesize(Client::class); From dfc6695093a0ae6abffc9f9575480d3d3ab6b016 Mon Sep 17 00:00:00 2001 From: Payetus Date: Wed, 31 Mar 2021 12:00:23 +0200 Subject: [PATCH 2/3] feat; add url_post parameter to createPayment --- src/Client.php | 4 ++-- src/ClientInterface.php | 4 +++- src/RequestFactory.php | 3 ++- tests/Integration/ClientCreatePaymentTest.php | 2 +- tests/Unit/RequestFactoryTest.php | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Client.php b/src/Client.php index 217ba3d..93e9c68 100644 --- a/src/Client.php +++ b/src/Client.php @@ -114,11 +114,11 @@ public function getTemplate($locale = null) * * @throws ErrorException */ - public function createPayment($customerExtId, $amount, $description, $service, $extraData = []) + public function createPayment($customerExtId, $amount, $description, $service, $url_post = null, $extraData = []) { $request = $this ->apiRequestFactory - ->createPaymentRequest($customerExtId, $amount, $description, $this->getOperative(), $service, $extraData); + ->createPaymentRequest($customerExtId, $amount, $description, $this->getOperative(), $service, $url_post, $extraData); return $this->send($request); } diff --git a/src/ClientInterface.php b/src/ClientInterface.php index d8b5f95..f42c7a1 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -65,7 +65,9 @@ public function retrieveCustomerCards($customerExtId, $status, $unique); * * @return array */ - public function createPayment($customerExtId, $amount, $description, $service, $extraData = []); + public function createPayment($customerExtId, $amount, $description, $service, $url_post = null, $extraData = []); + + /** * Requests Paylands API to pay a previously created order. diff --git a/src/RequestFactory.php b/src/RequestFactory.php index 2bdff5a..4d08474 100644 --- a/src/RequestFactory.php +++ b/src/RequestFactory.php @@ -70,7 +70,7 @@ public function setRequestFactory(HttpRequestFactory $requestFactory = null) * * @return RequestInterface */ - public function createPaymentRequest($customerExtId, $amount, $description, $operative, $service, $extraData = []) + public function createPaymentRequest($customerExtId, $amount, $description, $operative, $service, $url_post = null, $extraData = []) { $data = [ 'customer_ext_id' => (string) $customerExtId, @@ -78,6 +78,7 @@ public function createPaymentRequest($customerExtId, $amount, $description, $ope 'operative' => $operative, 'service' => $service, 'description' => $description, + 'url_post' => $url_post, ]; if (!empty($extraData)) { diff --git a/tests/Integration/ClientCreatePaymentTest.php b/tests/Integration/ClientCreatePaymentTest.php index aa4fee8..d9fde88 100644 --- a/tests/Integration/ClientCreatePaymentTest.php +++ b/tests/Integration/ClientCreatePaymentTest.php @@ -14,7 +14,7 @@ public function testCreatePayment() 'Test payment order', $this->apiPaymentServiceId ); - + var_dump($payment); $this->assertSame('OK', $payment['message']); $this->assertSame(200, $payment['code']); $this->assertFalse($payment['order']['paid']); diff --git a/tests/Unit/RequestFactoryTest.php b/tests/Unit/RequestFactoryTest.php index 3fff58b..38af920 100644 --- a/tests/Unit/RequestFactoryTest.php +++ b/tests/Unit/RequestFactoryTest.php @@ -92,7 +92,8 @@ public function tryCreatePaymentRequest() $data['body']['amount'], $data['body']['description'], $data['body']['operative'], - $data['body']['service'] + $data['body']['service'], + $data['body']['url_post'] ); $this->assertSame($request, $requestMock->reveal()); From 4104ab9cc04eb3e040dac66d35be8699ff767974 Mon Sep 17 00:00:00 2001 From: Payetus Date: Wed, 31 Mar 2021 12:01:03 +0200 Subject: [PATCH 3/3] fix: missing commit --- tests/Unit/RequestFactoryTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Unit/RequestFactoryTest.php b/tests/Unit/RequestFactoryTest.php index 38af920..4998878 100644 --- a/tests/Unit/RequestFactoryTest.php +++ b/tests/Unit/RequestFactoryTest.php @@ -93,7 +93,6 @@ public function tryCreatePaymentRequest() $data['body']['description'], $data['body']['operative'], $data['body']['service'], - $data['body']['url_post'] ); $this->assertSame($request, $requestMock->reveal());