Skip to content

Omnipay v3 upgrade #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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