Skip to content

Upgraded to support Omnipay v3 #8

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 4 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,18 @@ language: php

matrix:
allow_failures:
- php: 7.0
- php: 7.2
include:
- php: 5.3
dist: precise
- php: 5.4
- php: 7.2
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'
- php: 5.5
- php: 5.6
- php: 7.0
- php: hhvm

before_script:
- travis_retry composer self-update
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source

script:
- if [ "$TRAVIS_PHP_VERSION" == "hhvm" ]; then vendor/bin/phpunit; fi
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover; fi
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
}
],
"require": {
"php": ">=5.3.0",
"omnipay/common": "~2.0"
"php": ">=7.2",
"omnipay/common": "~3.0"
},
"require-dev": {
"omnipay/tests": "~2.0"
"omnipay/tests": "~3.0",
"phpunit/phpunit": "6.5.9"
},
"autoload": {
"psr-4": {
Expand Down
40 changes: 20 additions & 20 deletions src/Message/AbstractPurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Omnipay\SecureTrading\Message;

use DOMDocument;
use Omnipay\Common\Exception\InvalidCreditCardException;
use Omnipay\Common\Exception\InvalidRequestException;
use DOMDocument;

/**
* AbstractPurchase Request
Expand All @@ -26,15 +26,6 @@ public function getAccept()
? $this->determineAccept() : $this->getParameter('accept');
}

/**
* @param string $value
* @return $this
*/
public function setAccept($value)
{
return $this->setParameter('accept', $value);
}

/**
* @return string
*/
Expand All @@ -45,6 +36,15 @@ protected function determineAccept()
: '';
}

/**
* @param string $value
* @return $this
*/
public function setAccept($value)
{
return $this->setParameter('accept', $value);
}

/**
* The exact content of the HTTP user-agent header field as received from the cardholder’s user agent.
*
Expand All @@ -58,15 +58,6 @@ public function getUserAgent()
? $this->determineUserAgent() : $this->getParameter('userAgent');
}

/**
* @param string $value
* @return $this
*/
public function setUserAgent($value)
{
return $this->setParameter('userAgent', $value);
}

/**
* @return string
*/
Expand All @@ -77,6 +68,15 @@ protected function determineUserAgent()
: '';
}

/**
* @param string $value
* @return $this
*/
public function setUserAgent($value)
{
return $this->setParameter('userAgent', $value);
}

/**
* @return DOMDocument
* @throws InvalidCreditCardException
Expand Down Expand Up @@ -117,7 +117,7 @@ public function getData()
$payment->appendChild($data->createElement('expirydate', $card->getExpiryDate('m/Y')));
$payment->appendChild($data->createElement('securitycode', $card->getCvv()));
}

/** @var DOMDocument $customer */
$customer = $request->getElementsByTagName('customer')->item(0) ?: $request->appendChild($data->createElement('customer'));
$customer->appendChild($data->createElement('ip', $this->getClientIp()));
Expand Down
68 changes: 33 additions & 35 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Omnipay\SecureTrading\Message;

use Omnipay\Common\Message\AbstractRequest as BaseAbstractRequest;
use DOMDocument;
use Omnipay\Common\Message\AbstractRequest as BaseAbstractRequest;

/**
* Abstract Request
Expand All @@ -15,19 +15,6 @@ abstract class AbstractRequest extends BaseAbstractRequest
*/
protected $endpoint = 'https://webservices.securetrading.net:443/xml/';

/**
* @return string
*/
abstract public function getAction();

/**
* @return string
*/
public function getSiteReference()
{
return $this->getParameter('siteReference');
}

/**
* @param string $value
* @return $this
Expand All @@ -37,14 +24,6 @@ public function setSiteReference($value)
return $this->setParameter('siteReference', $value);
}

/**
* @return string
*/
public function getUsername()
{
return $this->getParameter('username');
}

/**
* @param string $value
* @return $this
Expand All @@ -54,14 +33,6 @@ public function setUsername($value)
return $this->setParameter('username', $value);
}

/**
* @return string
*/
public function getPassword()
{
return $this->getParameter('password');
}

/**
* @param string $value
* @return $this
Expand Down Expand Up @@ -135,21 +106,48 @@ public function getBaseData()
return $domTree;
}

/**
* @return string
*/
public function getUsername()
{
return $this->getParameter('username');
}

/**
* @return string
*/
abstract public function getAction();

/**
* @return string
*/
public function getSiteReference()
{
return $this->getParameter('siteReference');
}

/**
* @param DOMDocument $data
* @return Response
*/
public function sendData($data)
{
$headers = array(
$headers = array(
'Content-Type: text/xml;charset=utf-8',
'Accept: text/xml',
'Authorization: ' . base64_encode($this->getUsername() . ':' . $this->getPassword()),
);
$httpRequest = $this->httpClient->post($this->getEndpoint(), $headers, $data->saveXML());
$httpRequest->setAuth($this->getUsername(), $this->getPassword());
$httpResponse = $httpRequest->send();
$response = $this->httpClient->request('POST', $this->getEndpoint(), $headers, $data->saveXML())->getBody()->getContents();
return $this->createResponse($response);
}

return $this->createResponse($httpResponse->xml());
/**
* @return string
*/
public function getPassword()
{
return $this->getParameter('password');
}

/**
Expand Down
34 changes: 17 additions & 17 deletions src/Message/CompletePurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Omnipay\SecureTrading\Message;

use Omnipay\Common\Exception\InvalidRequestException;
use DOMDocument;
use Omnipay\Common\Exception\InvalidRequestException;

/**
* CompletePurchase Request
Expand All @@ -20,14 +20,6 @@ public function getAction()
return 'AUTH';
}

/**
* return string
*/
public function getMd()
{
return $this->getParameter('md');
}

/**
* @param string $value
* @return $this
Expand All @@ -37,14 +29,6 @@ public function setMd($value)
return $this->setParameter('md', $value);
}

/**
* return string
*/
public function getPaRes()
{
return $this->getParameter('paRes');
}

/**
* @param string $value
* @return $this
Expand Down Expand Up @@ -77,4 +61,20 @@ public function getData()

return $data;
}

/**
* return string
*/
public function getMd()
{
return $this->getParameter('md');
}

/**
* return string
*/
public function getPaRes()
{
return $this->getParameter('paRes');
}
}
2 changes: 2 additions & 0 deletions src/Message/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public function getAction()

/**
* @return DOMDocument
* @throws \Omnipay\Common\Exception\InvalidCreditCardException
* @throws \Omnipay\Common\Exception\InvalidRequestException
*/
public function getData()
{
Expand Down
1 change: 1 addition & 0 deletions src/Message/RefundRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function getAction()

/**
* @return DOMDocument
* @throws \Omnipay\Common\Exception\InvalidRequestException
*/
public function getData()
{
Expand Down
Loading