Skip to content

Commit

Permalink
Merge pull request #4 from koalaphils/omnipay-v3-upgrade
Browse files Browse the repository at this point in the history
Omnipay v3 upgrade
  • Loading branch information
dercoder authored Jul 2, 2021
2 parents 825e937 + ce2c6cf commit 6876641
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 38 deletions.
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
"psr-0": { "Omnipay\\Ecopayz\\" : "src/" }
},
"require": {
"omnipay/common": "~2.3"
"omnipay/common": "^3.0"
},
"require-dev": {
"omnipay/tests": "~2.0",
"satooshi/php-coveralls": "1.0.0"
"omnipay/tests": "^3.0.0",
"php-coveralls/php-coveralls": "^2.4.0",
"squizlabs/php_codesniffer": "3.*"
},
"extra": {
"branch-alias": {
Expand Down
3 changes: 0 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
<directory>./tests/</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="Mockery\Adapter\Phpunit\TestListener" file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php" />
</listeners>
<filter>
<whitelist>
<directory>./src</directory>
Expand Down
7 changes: 0 additions & 7 deletions src/Omnipay/Ecopayz/Message/CompletePurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,15 @@ public function getData()
);

if ($xml = $this->httpRequest->request->get('XML')) {

if (!$this->validateChecksum($xml)) {
throw new InvalidRequestException('Invalid XML checksum');
}

return new \SimpleXMLElement($xml);

} elseif ($xml = $this->httpRequest->getContent()) {
return new \SimpleXMLElement($xml);

} else {

throw new InvalidRequestException('Missing XML');

}
}

Expand All @@ -53,7 +48,6 @@ public function getData()
public function sendData($data)
{
if (isset($data->StatusReport)) {

if (in_array($data->StatusReport->Status, array(1, 2, 3))) {
$response = $this->createResponse('OK', 0, 'OK');
} elseif (in_array($data->StatusReport->Status, array(4, 5))) {
Expand All @@ -65,7 +59,6 @@ public function sendData($data)
header('Content-Type: text/xml; charset=utf-8');
echo $response;
die();

} else {
return new CompletePurchaseResponse($this, $data);
}
Expand Down
31 changes: 9 additions & 22 deletions src/Omnipay/Ecopayz/Message/FetchTransactionRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Omnipay\Ecopayz\Message;

use Omnipay\Common\Exception\InvalidRequestException;
Expand All @@ -17,8 +18,8 @@ class FetchTransactionRequest extends AbstractRequest
/**
* Get the data for this request.
*
* @throws InvalidRequestException
* @return string request data
* @throws InvalidRequestException
*/
public function getData()
{
Expand All @@ -43,7 +44,6 @@ public function getData()
);

if ($transactionReference = $this->getTransactionReference()) {

$query = $body->appendChild(
$document->createElement('q0:QueryBySVSTransactionID')
);
Expand All @@ -63,9 +63,7 @@ public function getData()
$request->appendChild(
$document->createElement('q0:SVSTxID', $transactionReference)
);

} elseif ($transactionId = $this->getTransactionId()) {

$query = $body->appendChild(
$document->createElement('q0:QueryByCustomerTransactionID')
);
Expand All @@ -85,11 +83,8 @@ public function getData()
$request->appendChild(
$document->createElement('q0:TxID', $transactionId)
);

} else {

throw new InvalidRequestException('The transactionId or transactionReference parameter is required');

}

return $document->saveXML();
Expand All @@ -98,23 +93,21 @@ public function getData()
/**
* Send the request with specified data
*
* @param mixed $data The data to send
* @throws InvalidResponseException
* @throws InvalidRequestException
* @param mixed $data The data to send
* @return FetchTransactionResponse
* @throws InvalidRequestException
* @throws InvalidResponseException
*/
public function sendData($data)
{
if (strpos($data, 'QueryBySVSTransactionID') !== false) {

$headers = array(
'Content-Type' => 'text/xml; charset=utf-8',
'SOAPAction' => 'http://www.ecocard.com/merchantAPI/QueryBySVSTransactionID'
);

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

Expand All @@ -132,17 +125,14 @@ public function sendData($data)
->QueryBySVSTransactionIDResponse
->TransactionResponse
);

} elseif (strpos($data, 'QueryByCustomerTransactionID') !== false) {

$headers = array(
'Content-Type' => 'text/xml; charset=utf-8',
'SOAPAction' => 'http://www.ecocard.com/merchantAPI/QueryByCustomerTransactionID'
);

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

Expand All @@ -160,11 +150,8 @@ public function sendData($data)
->QueryByCustomerTransactionIDResponse
->TransactionResponse
);

} else {

throw new InvalidRequestException('The transactionId or transactionReference parameter is required');

}
}
}
5 changes: 2 additions & 3 deletions src/Omnipay/Ecopayz/Message/PayoutRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ public function sendData($data)
'SOAPAction' => 'http://www.ecocard.com/merchantAPI/Payout'
);

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

Expand Down

0 comments on commit 6876641

Please sign in to comment.