Skip to content

Commit 532adb6

Browse files
authored
Merge pull request #28 from ruudk/omnipay-v3
Upgrade to Omnipay v3
2 parents 6d7a6d6 + 5a4b2ea commit 532adb6

15 files changed

+59
-65
lines changed

.travis.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
language: php
22

33
php:
4-
- 5.3
5-
- 5.4
6-
- 5.5
74
- 5.6
8-
- hhvm
5+
- 7.0
6+
- 7.1
7+
- 7.2
8+
9+
# This triggers builds to run on the new TravisCI infrastructure.
10+
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/
11+
sudo: false
12+
13+
## Cache composer
14+
cache:
15+
directories:
16+
- $HOME/.composer/cache
17+
18+
env:
19+
global:
20+
- setup=basic
921

1022
matrix:
11-
allow_failures:
12-
- php: hhvm
23+
include:
24+
- php: 5.6
25+
env: setup=lowest
1326

14-
before_script:
15-
- composer install -n --dev --prefer-source
27+
install:
28+
- if [[ $setup = 'basic' ]]; then travis_retry composer install --prefer-dist --no-interaction; fi
29+
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable; fi
1630

1731
script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@
2727
"psr-4": { "Omnipay\\MultiSafepay\\" : "src/" }
2828
},
2929
"require": {
30-
"omnipay/common": "~2.0"
30+
"omnipay/common": "^3"
3131
},
3232
"require-dev": {
33-
"omnipay/tests": "~2.0"
33+
"omnipay/tests": "^3",
34+
"squizlabs/php_codesniffer": "^3"
3435
},
3536
"extra": {
3637
"branch-alias": {
37-
"dev-master": "2.0.x-dev"
38+
"dev-master": "3.0.x-dev"
3839
}
3940
}
4041
}

phpunit.xml.dist

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
<directory>./tests/</directory>
1515
</testsuite>
1616
</testsuites>
17-
<listeners>
18-
<listener class="Mockery\Adapter\Phpunit\TestListener" file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php" />
19-
</listeners>
2017
<filter>
2118
<whitelist>
2219
<directory>./src</directory>

src/Message/CompletePurchaseRequest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ public function getData()
4141
*/
4242
public function sendData($data)
4343
{
44-
$httpResponse = $this->httpClient->post(
44+
$httpResponse = $this->httpClient->request(
45+
'POST',
4546
$this->getEndpoint(),
4647
$this->getHeaders(),
4748
$data->asXML()
48-
)->send();
49+
);
4950

5051
$this->response = new CompletePurchaseResponse(
5152
$this,
52-
$httpResponse->xml()
53+
simplexml_load_string($httpResponse->getBody()->getContents())
5354
);
5455

5556
return $this->response;

src/Message/CompletePurchaseResponse.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public function isInitialized()
4949
public function isUncleared()
5050
{
5151
return $this->getPaymentStatus() === 'uncleared';
52-
5352
}
5453

5554
/**

src/Message/FetchIssuersRequest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ public function getData()
3636
*/
3737
public function sendData($data)
3838
{
39-
$httpResponse = $this->httpClient->post(
39+
$httpResponse = $this->httpClient->request(
40+
'POST',
4041
$this->getEndpoint(),
4142
$this->getHeaders(),
4243
$data->asXML()
43-
)->send();
44+
);
4445

4546
$this->response = new FetchIssuersResponse(
4647
$this,
47-
$httpResponse->xml()
48+
simplexml_load_string($httpResponse->getBody()->getContents())
4849
);
4950

5051
return $this->response;

src/Message/FetchPaymentMethodsRequest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,16 @@ public function getData()
5959
*/
6060
public function sendData($data)
6161
{
62-
$httpResponse = $this->httpClient->post(
62+
$httpResponse = $this->httpClient->request(
63+
'POST',
6364
$this->getEndpoint(),
6465
$this->getHeaders(),
6566
$data->asXML()
66-
)->send();
67+
);
6768

6869
$this->response = new FetchPaymentMethodsResponse(
6970
$this,
70-
$httpResponse->xml()
71+
simplexml_load_string($httpResponse->getBody()->getContents())
7172
);
7273

7374
return $this->response;

src/Message/PurchaseRequest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,16 @@ public function getData()
258258
*/
259259
public function sendData($data)
260260
{
261-
$httpResponse = $this->httpClient->post(
261+
$httpResponse = $this->httpClient->request(
262+
'POST',
262263
$this->getEndpoint(),
263264
$this->getHeaders(),
264265
$data->asXML()
265-
)->send();
266+
);
266267

267268
$this->response = new PurchaseResponse(
268269
$this,
269-
$httpResponse->xml()
270+
simplexml_load_string($httpResponse->getBody()->getContents())
270271
);
271272

272273
return $this->response;

src/Message/RestAbstractRequest.php

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Omnipay\MultiSafepay\Message;
77

88
use Omnipay\Common\Message\AbstractRequest;
9-
use Guzzle\Common\Event;
9+
use Psr\Http\Message\ResponseInterface;
1010

1111
/**
1212
* MultiSafepay Rest API Abstract Request class.
@@ -147,33 +147,16 @@ protected function getHeaders()
147147
*
148148
* @param $method
149149
* @param $endpoint
150-
* @param null $query
151150
* @param null $data
152-
* @return \Guzzle\Http\Message\Response
151+
* @return ResponseInterface
153152
*/
154-
protected function sendRequest($method, $endpoint, $query = null, $data = null)
153+
protected function sendRequest($method, $endpoint, $data = null)
155154
{
156-
$this->httpClient->getEventDispatcher()->addListener('request.error', function (Event $event) {
157-
$response = $event['response'];
158-
if ($response->isError()) {
159-
$event->stopPropagation();
160-
}
161-
});
162-
163-
$httpRequest = $this->httpClient->createRequest(
155+
return $this->httpClient->request(
164156
$method,
165157
$this->getEndpoint() . $endpoint,
166158
$this->getHeaders(),
167159
$data
168160
);
169-
170-
// Add query parameters
171-
if (is_array($query) && ! empty($query)) {
172-
foreach ($query as $itemKey => $itemValue) {
173-
$httpRequest->getQuery()->add($itemKey, $itemValue);
174-
}
175-
}
176-
177-
return $httpRequest->send();
178161
}
179162
}

src/Message/RestCompletePurchaseRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function sendData($data)
5050

5151
$this->response = new RestCompletePurchaseResponse(
5252
$this,
53-
$httpResponse->json()
53+
json_decode($httpResponse->getBody()->getContents(), true)
5454
);
5555

5656
return $this->response;

src/Message/RestFetchIssuersRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function sendData($data)
5858

5959
$this->response = new RestFetchIssuersResponse(
6060
$this,
61-
$httpResponse->json()
61+
json_decode($httpResponse->getBody()->getContents(), true)
6262
);
6363

6464
return $this->response;

src/Message/RestFetchPaymentMethodsRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ public function getData()
7272
*/
7373
public function sendData($data)
7474
{
75-
$httpResponse = $this->sendRequest('GET', '/gateways', $data);
75+
$httpResponse = $this->sendRequest('GET', '/gateways', json_encode($data));
7676

7777
$this->response = new RestFetchPaymentMethodsResponse(
7878
$this,
79-
$httpResponse->json()
79+
json_decode($httpResponse->getBody()->getContents(), true)
8080
);
8181

8282
return $this->response;

src/Message/RestFetchTransactionRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function sendData($data)
5757

5858
$this->response = new RestFetchTransactionResponse(
5959
$this,
60-
$httpResponse->json()
60+
json_decode($httpResponse->getBody()->getContents(), true)
6161
);
6262

6363
return $this->response;

src/Message/RestPurchaseRequest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ public function setGoogleAnalyticsCode($value)
383383
return $this->setParameter('google_analytics', $value);
384384
}
385385

386-
/**
386+
/**
387387
* Get items HTML
388388
*
389389
* @return string
@@ -393,7 +393,7 @@ public function setItemsHtml($itemsHtml)
393393
$this->setParameter('itemsHtml', $itemsHtml);
394394
}
395395

396-
/**
396+
/**
397397
* Get items HTML
398398
*
399399
* @return string
@@ -474,7 +474,7 @@ protected function getGatewayData()
474474

475475
/**
476476
* Get itembag data.
477-
*
477+
*
478478
* @return array
479479
*/
480480
protected function getItemBagData()
@@ -521,10 +521,7 @@ public function getData()
521521

522522
// When the gateway is set to IDEAL,
523523
// the issuer parameter is required.
524-
if (
525-
$this->getType() == 'direct' &&
526-
$this->getGateway() == 'IDEAL'
527-
) {
524+
if ($this->getType() == 'direct' && $this->getGateway() == 'IDEAL') {
528525
$this->validate('issuer');
529526
}
530527

@@ -580,11 +577,11 @@ public function getData()
580577
*/
581578
public function sendData($data)
582579
{
583-
$httpResponse = $this->sendRequest('POST', '/orders', null, $data);
580+
$httpResponse = $this->sendRequest('POST', '/orders', json_encode($data));
584581

585582
$this->response = new RestPurchaseResponse(
586583
$this,
587-
$httpResponse->json()
584+
json_decode($httpResponse->getBody()->getContents(), true)
588585
);
589586

590587
return $this->response;

src/Message/RestRefundRequest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@ public function sendData($data)
6767
$httpResponse = $this->sendRequest(
6868
'POST',
6969
'/orders/' . $data['id'] . '/refunds',
70-
null,
71-
$data
70+
json_encode($data)
7271
);
7372

7473
$this->response = new RestRefundResponse(
7574
$this,
76-
$httpResponse->json()
75+
json_decode($httpResponse->getBody()->getContents(), true)
7776
);
7877

7978
return $this->response;

0 commit comments

Comments
 (0)