diff --git a/.travis.yml b/.travis.yml
index fa7b39c8..5f9dcf9a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,19 +1,30 @@
language: php
php:
- - 5.4
- - 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- - hhvm
+
+# This triggers builds to run on the new TravisCI infrastructure.
+# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/
+sudo: false
+
+cache:
+ directories:
+ - $HOME/.composer/cache
+
+env:
+ global:
+ - setup=basic
matrix:
- allow_failures:
- - php: hhvm
+ include:
+ - php: 5.6
+ env: setup=lowest
-before_script:
- - composer install -n --dev --prefer-source
+install:
+ - if [[ $setup = 'basic' ]]; then travis_retry composer install --prefer-dist --no-interaction; fi
+ - if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable; fi
script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text
diff --git a/composer.json b/composer.json
index b03077ec..671d2c0d 100644
--- a/composer.json
+++ b/composer.json
@@ -28,16 +28,23 @@
"psr-4": { "Omnipay\\AuthorizeNet\\" : "src/" }
},
"require": {
- "omnipay/common": "~2.5",
+ "omnipay/common": "^3",
"ext-json": "*",
"ext-simplexml": "*"
},
"require-dev": {
- "omnipay/tests": "~2.0"
+ "omnipay/tests": "^3",
+ "squizlabs/php_codesniffer": "^3"
},
"extra": {
"branch-alias": {
- "dev-master": "2.0.x-dev"
+ "dev-master": "3.0.x-dev"
}
- }
+ },
+ "scripts": {
+ "test": "phpunit",
+ "check-style": "phpcs -p --standard=PSR2 src/",
+ "fix-style": "phpcbf -p --standard=PSR2 src/"
+ },
+ "prefer-stable": true
}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index a35b7362..535809e1 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -14,9 +14,6 @@
./tests/
-
-
-
./src
diff --git a/src/Message/AIMAbstractRequest.php b/src/Message/AIMAbstractRequest.php
index 96799cf8..fd368c65 100644
--- a/src/Message/AIMAbstractRequest.php
+++ b/src/Message/AIMAbstractRequest.php
@@ -170,9 +170,9 @@ public function sendData($data)
{
$headers = array('Content-Type' => 'text/xml; charset=utf-8');
$data = $data->saveXml();
- $httpResponse = $this->httpClient->post($this->getEndpoint(), $headers, $data)->send();
+ $httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, $data);
- return $this->response = new AIMResponse($this, $httpResponse->getBody());
+ return $this->response = new AIMResponse($this, $httpResponse->getBody()->getContents());
}
/**
diff --git a/src/Message/AIMResponse.php b/src/Message/AIMResponse.php
index 4c99215e..5c25a8cc 100644
--- a/src/Message/AIMResponse.php
+++ b/src/Message/AIMResponse.php
@@ -48,7 +48,7 @@ public function isSuccessful()
*/
public function getResultCode()
{
- return intval((string)$this->data->transactionResponse[0]->responseCode);
+ return intval((string)$this->data->transactionResponse->responseCode);
}
/**
@@ -60,13 +60,12 @@ public function getReasonCode()
{
$code = null;
- if (isset($this->data->transactionResponse[0]->messages)) {
+ if (isset($this->data->transactionResponse->messages)) {
// In case of a successful transaction, a "messages" element is present
- $code = intval((string)$this->data->transactionResponse[0]->messages[0]->message[0]->code);
-
- } elseif (isset($this->data->transactionResponse[0]->errors)) {
+ $code = intval((string)$this->data->transactionResponse->messages->message->code);
+ } elseif (isset($this->data->transactionResponse->errors)) {
// In case of an unsuccessful transaction, an "errors" element is present
- $code = intval((string)$this->data->transactionResponse[0]->errors[0]->error[0]->errorCode);
+ $code = intval((string)$this->data->transactionResponse->errors->error->errorCode);
}
return $code;
@@ -81,13 +80,12 @@ public function getMessage()
{
$message = null;
- if (isset($this->data->transactionResponse[0]->messages)) {
+ if (isset($this->data->transactionResponse->messages)) {
// In case of a successful transaction, a "messages" element is present
- $message = (string)$this->data->transactionResponse[0]->messages[0]->message[0]->description;
-
- } elseif (isset($this->data->transactionResponse[0]->errors)) {
+ $message = (string)$this->data->transactionResponse->messages->message->description;
+ } elseif (isset($this->data->transactionResponse->errors)) {
// In case of an unsuccessful transaction, an "errors" element is present
- $message = (string)$this->data->transactionResponse[0]->errors[0]->error[0]->errorText;
+ $message = (string)$this->data->transactionResponse->errors->error->errorText;
}
return $message;
@@ -95,7 +93,7 @@ public function getMessage()
public function getAuthorizationCode()
{
- return (string)$this->data->transactionResponse[0]->authCode;
+ return (string)$this->data->transactionResponse->authCode;
}
/**
@@ -105,7 +103,7 @@ public function getAuthorizationCode()
*/
public function getAVSCode()
{
- return (string)$this->data->transactionResponse[0]->avsResultCode;
+ return (string)$this->data->transactionResponse->avsResultCode;
}
/**
@@ -118,7 +116,7 @@ public function getAVSCode()
public function getTransactionReference($serialize = true)
{
if ($this->isSuccessful()) {
- $body = $this->data->transactionResponse[0];
+ $body = $this->data->transactionResponse;
$transactionRef = new TransactionReference();
$transactionRef->setApprovalCode((string)$body->authCode);
$transactionRef->setTransId((string)$body->transId);
diff --git a/src/Message/CIMAbstractRequest.php b/src/Message/CIMAbstractRequest.php
index 171f0340..2c8fcf81 100644
--- a/src/Message/CIMAbstractRequest.php
+++ b/src/Message/CIMAbstractRequest.php
@@ -101,8 +101,8 @@ public function sendData($data)
{
$headers = array('Content-Type' => 'text/xml; charset=utf-8');
$data = $data->saveXml();
- $httpResponse = $this->httpClient->post($this->getEndpoint(), $headers, $data)->send();
+ $httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, $data);
- return $this->response = new CIMResponse($this, $httpResponse->getBody());
+ return $this->response = new CIMResponse($this, $httpResponse->getBody()->getContents());
}
}
diff --git a/src/Message/CIMAbstractResponse.php b/src/Message/CIMAbstractResponse.php
index 28916d9f..63e386a4 100644
--- a/src/Message/CIMAbstractResponse.php
+++ b/src/Message/CIMAbstractResponse.php
@@ -19,7 +19,7 @@ public function __construct(RequestInterface $request, $data)
// Check if this is an error response
$isError = strpos((string)$data, 'responseType;
+ $xmlRootElement = ($isError !== false ? 'ErrorResponse' : $this->responseType);
// Strip out the xmlns junk so that PHP can parse the XML
$xml = preg_replace('/<' . $xmlRootElement . '[^>]+>/', '<' . $xmlRootElement . '>', (string)$data);
@@ -58,7 +58,6 @@ public function getResultCode()
return 3;
default:
return null;
-
}
}
@@ -125,8 +124,6 @@ public function getCardReference()
}
/**
- * http://bookofzeus.com/articles/convert-simplexml-object-into-php-array/
- *
* Convert a simpleXMLElement in to an array
*
* @param \SimpleXMLElement $xml
diff --git a/src/Message/CIMAuthorizeRequest.php b/src/Message/CIMAuthorizeRequest.php
index dc8d9252..aa440eb1 100644
--- a/src/Message/CIMAuthorizeRequest.php
+++ b/src/Message/CIMAuthorizeRequest.php
@@ -14,7 +14,6 @@ protected function addPayment(\SimpleXMLElement $data)
if ($this->isCardPresent()) {
// Prefer the track data if present over the payment profile (better rate)
return parent::addPayment($data);
-
} else {
$this->validate('cardReference');
diff --git a/src/Message/CIMCreateCardRequest.php b/src/Message/CIMCreateCardRequest.php
index 09ac180a..5a50da3f 100644
--- a/src/Message/CIMCreateCardRequest.php
+++ b/src/Message/CIMCreateCardRequest.php
@@ -152,9 +152,9 @@ public function sendData($data)
{
$headers = array('Content-Type' => 'text/xml; charset=utf-8');
$data = $data->saveXml();
- $httpResponse = $this->httpClient->post($this->getEndpoint(), $headers, $data)->send();
+ $httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, $data);
- $response = new CIMCreateCardResponse($this, $httpResponse->getBody());
+ $response = new CIMCreateCardResponse($this, $httpResponse->getBody()->getContents());
if (!$response->isSuccessful() && $response->getReasonCode() == 'E00039') {
// Duplicate profile. Try adding a new payment profile for the same profile and get the response
diff --git a/src/Message/CIMCreatePaymentProfileRequest.php b/src/Message/CIMCreatePaymentProfileRequest.php
index 5948165b..f2c4ed92 100644
--- a/src/Message/CIMCreatePaymentProfileRequest.php
+++ b/src/Message/CIMCreatePaymentProfileRequest.php
@@ -43,8 +43,8 @@ public function sendData($data)
{
$headers = array('Content-Type' => 'text/xml; charset=utf-8');
$data = $data->saveXml();
- $httpResponse = $this->httpClient->post($this->getEndpoint(), $headers, $data)->send();
+ $httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, $data);
- return $this->response = new CIMCreatePaymentProfileResponse($this, $httpResponse->getBody());
+ return $this->response = new CIMCreatePaymentProfileResponse($this, $httpResponse->getBody()->getContents());
}
}
diff --git a/src/Message/CIMGetPaymentProfileRequest.php b/src/Message/CIMGetPaymentProfileRequest.php
index a8da6cf6..2181fdc4 100644
--- a/src/Message/CIMGetPaymentProfileRequest.php
+++ b/src/Message/CIMGetPaymentProfileRequest.php
@@ -25,8 +25,8 @@ public function sendData($data)
{
$headers = array('Content-Type' => 'text/xml; charset=utf-8');
$data = $data->saveXml();
- $httpResponse = $this->httpClient->post($this->getEndpoint(), $headers, $data)->send();
+ $httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, $data);
- return $this->response = new CIMGetPaymentProfileResponse($this, $httpResponse->getBody());
+ return $this->response = new CIMGetPaymentProfileResponse($this, $httpResponse->getBody()->getContents());
}
}
diff --git a/src/Message/CIMGetProfileRequest.php b/src/Message/CIMGetProfileRequest.php
index 5f755475..caaea8e9 100644
--- a/src/Message/CIMGetProfileRequest.php
+++ b/src/Message/CIMGetProfileRequest.php
@@ -24,8 +24,8 @@ public function sendData($data)
{
$headers = array('Content-Type' => 'text/xml; charset=utf-8');
$data = $data->saveXml();
- $httpResponse = $this->httpClient->post($this->getEndpoint(), $headers, $data)->send();
+ $httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, $data);
- return $this->response = new CIMGetProfileResponse($this, $httpResponse->getBody());
+ return $this->response = new CIMGetProfileResponse($this, $httpResponse->getBody()->getContents());
}
}
diff --git a/src/Message/CIMUpdatePaymentProfileRequest.php b/src/Message/CIMUpdatePaymentProfileRequest.php
index 37a7e1a9..4677adfb 100644
--- a/src/Message/CIMUpdatePaymentProfileRequest.php
+++ b/src/Message/CIMUpdatePaymentProfileRequest.php
@@ -44,8 +44,8 @@ public function sendData($data)
{
$headers = array('Content-Type' => 'text/xml; charset=utf-8');
$data = $data->saveXml();
- $httpResponse = $this->httpClient->post($this->getEndpoint(), $headers, $data)->send();
+ $httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), $headers, $data);
- return $this->response = new CIMUpdatePaymentProfileResponse($this, $httpResponse->getBody());
+ return $this->response = new CIMUpdatePaymentProfileResponse($this, $httpResponse->getBody()->getContents());
}
}
diff --git a/src/Message/SIMAbstractRequest.php b/src/Message/SIMAbstractRequest.php
index 58ae790d..44833f35 100644
--- a/src/Message/SIMAbstractRequest.php
+++ b/src/Message/SIMAbstractRequest.php
@@ -170,9 +170,9 @@ protected function getBillingData()
public function sendData($data)
{
- $httpResponse = $this->httpClient->post($this->getEndpoint(), null, $data)->send();
+ $httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], http_build_query($data));
- return $this->response = new AIMResponse($this, $httpResponse->getBody());
+ return $this->response = new AIMResponse($this, $httpResponse->getBody()->getContents());
}
public function getEndpoint()
diff --git a/tests/CIMGatewayTest.php b/tests/CIMGatewayTest.php
index 9e03603d..f4cfc41a 100644
--- a/tests/CIMGatewayTest.php
+++ b/tests/CIMGatewayTest.php
@@ -200,6 +200,7 @@ public function testPurchaseFailure()
public function testRefundSuccess()
{
+ self::markTestSkipped();
// $this->setMockHttpResponse('CIMRefundSuccess.txt');
//
// $response = $this->gateway->refund($this->refundOptions)->send();
diff --git a/tests/Message/AIMAbstractRequestTest.php b/tests/Message/AIMAbstractRequestTest.php
index 04d01400..c16d1502 100644
--- a/tests/Message/AIMAbstractRequestTest.php
+++ b/tests/Message/AIMAbstractRequestTest.php
@@ -1,12 +1,12 @@
request = $this->getMockForAbstractClass(
'\Omnipay\AuthorizeNet\Message\AIMAbstractRequest',
array(
- $this->getMock('\Guzzle\Http\ClientInterface'),
- $this->getMock('\Symfony\Component\HttpFoundation\Request')
+ $this->createMock(ClientInterface::class),
+ $this->createMock('\Symfony\Component\HttpFoundation\Request')
)
);
}
diff --git a/tests/Message/AIMResponseTest.php b/tests/Message/AIMResponseTest.php
index e0950474..392c20a3 100644
--- a/tests/Message/AIMResponseTest.php
+++ b/tests/Message/AIMResponseTest.php
@@ -18,7 +18,7 @@ public function getMockRequest($className = '\Omnipay\AuthorizeNet\Message\AIMAb
public function testConstructEmpty()
{
- $this->setExpectedException('\Omnipay\Common\Exception\InvalidResponseException');
+ $this->expectException('\Omnipay\Common\Exception\InvalidResponseException');
new AIMResponse($this->getMockRequest(), '');
}
diff --git a/tests/Mock/CIMCreateCardFailure.txt b/tests/Mock/CIMCreateCardFailure.txt
index fe7bdc5a..86ce9e9e 100644
--- a/tests/Mock/CIMCreateCardFailure.txt
+++ b/tests/Mock/CIMCreateCardFailure.txt
@@ -1,8 +1,7 @@
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 746
-Content-Type: text/xml;
-charset=utf-8
+Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
diff --git a/tests/Mock/CIMCreateCardFailureWithDuplicate.txt b/tests/Mock/CIMCreateCardFailureWithDuplicate.txt
index 617eaaad..6fc83e3e 100644
--- a/tests/Mock/CIMCreateCardFailureWithDuplicate.txt
+++ b/tests/Mock/CIMCreateCardFailureWithDuplicate.txt
@@ -1,8 +1,7 @@
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 746
-Content-Type: text/xml;
-charset=utf-8
+Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
diff --git a/tests/Mock/CIMCreateCardSuccess.txt b/tests/Mock/CIMCreateCardSuccess.txt
index 97e06ed2..9e29f906 100644
--- a/tests/Mock/CIMCreateCardSuccess.txt
+++ b/tests/Mock/CIMCreateCardSuccess.txt
@@ -1,8 +1,7 @@
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 746
-Content-Type: text/xml;
-charset=utf-8
+Content-Type: text/xml;charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
diff --git a/tests/Mock/CIMCreatePaymentProfileFailure.txt b/tests/Mock/CIMCreatePaymentProfileFailure.txt
index 91b28e6c..abfebdc9 100644
--- a/tests/Mock/CIMCreatePaymentProfileFailure.txt
+++ b/tests/Mock/CIMCreatePaymentProfileFailure.txt
@@ -1,8 +1,7 @@
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 746
-Content-Type: text/xml;
-charset=utf-8
+Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
diff --git a/tests/Mock/CIMCreatePaymentProfileFailureMaxProfileLimit.txt b/tests/Mock/CIMCreatePaymentProfileFailureMaxProfileLimit.txt
index 98b69db6..8d8ee7a9 100644
--- a/tests/Mock/CIMCreatePaymentProfileFailureMaxProfileLimit.txt
+++ b/tests/Mock/CIMCreatePaymentProfileFailureMaxProfileLimit.txt
@@ -1,8 +1,7 @@
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 746
-Content-Type: text/xml;
-charset=utf-8
+Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
diff --git a/tests/Mock/CIMCreatePaymentProfileSuccess.txt b/tests/Mock/CIMCreatePaymentProfileSuccess.txt
index 40bdb247..e860a255 100644
--- a/tests/Mock/CIMCreatePaymentProfileSuccess.txt
+++ b/tests/Mock/CIMCreatePaymentProfileSuccess.txt
@@ -1,8 +1,7 @@
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 746
-Content-Type: text/xml;
-charset=utf-8
+Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
diff --git a/tests/Mock/CIMGetMultipleProfilesSuccess.txt b/tests/Mock/CIMGetMultipleProfilesSuccess.txt
index 8fedf2f1..33f23ab3 100644
--- a/tests/Mock/CIMGetMultipleProfilesSuccess.txt
+++ b/tests/Mock/CIMGetMultipleProfilesSuccess.txt
@@ -1,8 +1,7 @@
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 746
-Content-Type: text/xml;
-charset=utf-8
+Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
diff --git a/tests/Mock/CIMGetPaymentProfileSuccess.txt b/tests/Mock/CIMGetPaymentProfileSuccess.txt
index 9c4c6782..8e51908f 100644
--- a/tests/Mock/CIMGetPaymentProfileSuccess.txt
+++ b/tests/Mock/CIMGetPaymentProfileSuccess.txt
@@ -1,8 +1,7 @@
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 746
-Content-Type: text/xml;
-charset=utf-8
+Content-Type: text/xml;charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
diff --git a/tests/Mock/CIMGetSingleProfileSuccess.txt b/tests/Mock/CIMGetSingleProfileSuccess.txt
index 27d4120d..3beb50c0 100644
--- a/tests/Mock/CIMGetSingleProfileSuccess.txt
+++ b/tests/Mock/CIMGetSingleProfileSuccess.txt
@@ -1,8 +1,7 @@
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 746
-Content-Type: text/xml;
-charset=utf-8
+Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
diff --git a/tests/Mock/CIMUpdatePaymentProfileSuccess.txt b/tests/Mock/CIMUpdatePaymentProfileSuccess.txt
index 348ab7e0..7d7abd97 100644
--- a/tests/Mock/CIMUpdatePaymentProfileSuccess.txt
+++ b/tests/Mock/CIMUpdatePaymentProfileSuccess.txt
@@ -1,8 +1,7 @@
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 746
-Content-Type: text/xml;
-charset=utf-8
+Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
diff --git a/tests/Model/CardReferenceTest.php b/tests/Model/CardReferenceTest.php
index d471d2a4..7de6fa62 100644
--- a/tests/Model/CardReferenceTest.php
+++ b/tests/Model/CardReferenceTest.php
@@ -2,7 +2,10 @@
namespace Omnipay\AuthorizeNet\Model;
-class CardReferenceTest extends \PHPUnit_Framework_TestCase
+
+use Omnipay\Tests\TestCase;
+
+class CardReferenceTest extends TestCase
{
private $data;
/** @var CardReference */
diff --git a/tests/Model/TransactionReferenceTest.php b/tests/Model/TransactionReferenceTest.php
index b0cf0c80..8c0be267 100644
--- a/tests/Model/TransactionReferenceTest.php
+++ b/tests/Model/TransactionReferenceTest.php
@@ -2,7 +2,9 @@
namespace Omnipay\AuthorizeNet\Model;
-class TransactionReferenceTest extends \PHPUnit_Framework_TestCase
+use Omnipay\Tests\TestCase;
+
+class TransactionReferenceTest extends TestCase
{
private $data;
/** @var TransactionReference */