Skip to content

Commit 6876641

Browse files
authored
Merge pull request #4 from koalaphils/omnipay-v3-upgrade
Omnipay v3 upgrade
2 parents 825e937 + ce2c6cf commit 6876641

File tree

5 files changed

+15
-38
lines changed

5 files changed

+15
-38
lines changed

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
"psr-0": { "Omnipay\\Ecopayz\\" : "src/" }
1717
},
1818
"require": {
19-
"omnipay/common": "~2.3"
19+
"omnipay/common": "^3.0"
2020
},
2121
"require-dev": {
22-
"omnipay/tests": "~2.0",
23-
"satooshi/php-coveralls": "1.0.0"
22+
"omnipay/tests": "^3.0.0",
23+
"php-coveralls/php-coveralls": "^2.4.0",
24+
"squizlabs/php_codesniffer": "3.*"
2425
},
2526
"extra": {
2627
"branch-alias": {

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/Omnipay/Ecopayz/Message/CompletePurchaseRequest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,15 @@ public function getData()
2727
);
2828

2929
if ($xml = $this->httpRequest->request->get('XML')) {
30-
3130
if (!$this->validateChecksum($xml)) {
3231
throw new InvalidRequestException('Invalid XML checksum');
3332
}
3433

3534
return new \SimpleXMLElement($xml);
36-
3735
} elseif ($xml = $this->httpRequest->getContent()) {
3836
return new \SimpleXMLElement($xml);
39-
4037
} else {
41-
4238
throw new InvalidRequestException('Missing XML');
43-
4439
}
4540
}
4641

@@ -53,7 +48,6 @@ public function getData()
5348
public function sendData($data)
5449
{
5550
if (isset($data->StatusReport)) {
56-
5751
if (in_array($data->StatusReport->Status, array(1, 2, 3))) {
5852
$response = $this->createResponse('OK', 0, 'OK');
5953
} elseif (in_array($data->StatusReport->Status, array(4, 5))) {
@@ -65,7 +59,6 @@ public function sendData($data)
6559
header('Content-Type: text/xml; charset=utf-8');
6660
echo $response;
6761
die();
68-
6962
} else {
7063
return new CompletePurchaseResponse($this, $data);
7164
}

src/Omnipay/Ecopayz/Message/FetchTransactionRequest.php

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Omnipay\Ecopayz\Message;
34

45
use Omnipay\Common\Exception\InvalidRequestException;
@@ -17,8 +18,8 @@ class FetchTransactionRequest extends AbstractRequest
1718
/**
1819
* Get the data for this request.
1920
*
20-
* @throws InvalidRequestException
2121
* @return string request data
22+
* @throws InvalidRequestException
2223
*/
2324
public function getData()
2425
{
@@ -43,7 +44,6 @@ public function getData()
4344
);
4445

4546
if ($transactionReference = $this->getTransactionReference()) {
46-
4747
$query = $body->appendChild(
4848
$document->createElement('q0:QueryBySVSTransactionID')
4949
);
@@ -63,9 +63,7 @@ public function getData()
6363
$request->appendChild(
6464
$document->createElement('q0:SVSTxID', $transactionReference)
6565
);
66-
6766
} elseif ($transactionId = $this->getTransactionId()) {
68-
6967
$query = $body->appendChild(
7068
$document->createElement('q0:QueryByCustomerTransactionID')
7169
);
@@ -85,11 +83,8 @@ public function getData()
8583
$request->appendChild(
8684
$document->createElement('q0:TxID', $transactionId)
8785
);
88-
8986
} else {
90-
9187
throw new InvalidRequestException('The transactionId or transactionReference parameter is required');
92-
9388
}
9489

9590
return $document->saveXML();
@@ -98,23 +93,21 @@ public function getData()
9893
/**
9994
* Send the request with specified data
10095
*
101-
* @param mixed $data The data to send
102-
* @throws InvalidResponseException
103-
* @throws InvalidRequestException
96+
* @param mixed $data The data to send
10497
* @return FetchTransactionResponse
98+
* @throws InvalidRequestException
99+
* @throws InvalidResponseException
105100
*/
106101
public function sendData($data)
107102
{
108103
if (strpos($data, 'QueryBySVSTransactionID') !== false) {
109-
110104
$headers = array(
111105
'Content-Type' => 'text/xml; charset=utf-8',
112106
'SOAPAction' => 'http://www.ecocard.com/merchantAPI/QueryBySVSTransactionID'
113107
);
114108

115-
$httpRequest = $this->httpClient->createRequest('POST', $this->getEndpoint(), $headers, $data);
116-
$httpResponse = $httpRequest->send();
117-
$xmlResponse = $httpResponse->xml()
109+
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, $data);
110+
$xmlResponse = simplexml_load_string($httpResponse->getBody()->getContents())
118111
->children('http://schemas.xmlsoap.org/soap/envelope/')
119112
->children('http://www.ecocard.com/merchantAPI/');
120113

@@ -132,17 +125,14 @@ public function sendData($data)
132125
->QueryBySVSTransactionIDResponse
133126
->TransactionResponse
134127
);
135-
136128
} elseif (strpos($data, 'QueryByCustomerTransactionID') !== false) {
137-
138129
$headers = array(
139130
'Content-Type' => 'text/xml; charset=utf-8',
140131
'SOAPAction' => 'http://www.ecocard.com/merchantAPI/QueryByCustomerTransactionID'
141132
);
142133

143-
$httpRequest = $this->httpClient->createRequest('POST', $this->getEndpoint(), $headers, $data);
144-
$httpResponse = $httpRequest->send();
145-
$xmlResponse = $httpResponse->xml()
134+
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, $data);
135+
$xmlResponse = simplexml_load_string($httpResponse->getBody()->getContents())
146136
->children('http://schemas.xmlsoap.org/soap/envelope/')
147137
->children('http://www.ecocard.com/merchantAPI/');
148138

@@ -160,11 +150,8 @@ public function sendData($data)
160150
->QueryByCustomerTransactionIDResponse
161151
->TransactionResponse
162152
);
163-
164153
} else {
165-
166154
throw new InvalidRequestException('The transactionId or transactionReference parameter is required');
167-
168155
}
169156
}
170157
}

src/Omnipay/Ecopayz/Message/PayoutRequest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,8 @@ public function sendData($data)
159159
'SOAPAction' => 'http://www.ecocard.com/merchantAPI/Payout'
160160
);
161161

162-
$httpRequest = $this->httpClient->createRequest('POST', $this->getEndpoint(), $headers, $data);
163-
$httpResponse = $httpRequest->send();
164-
$xmlResponse = $httpResponse->xml()
162+
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, $data);
163+
$xmlResponse = simplexml_load_string($httpResponse->getBody()->getContents())
165164
->children('http://schemas.xmlsoap.org/soap/envelope/')
166165
->children('http://www.ecocard.com/merchantAPI/');
167166

0 commit comments

Comments
 (0)