Skip to content

Commit

Permalink
Merge pull request #4 from PatronBase/master
Browse files Browse the repository at this point in the history
Update to Omnipay 3
  • Loading branch information
leith authored Nov 9, 2020
2 parents 9e3d98d + b2e4a05 commit ec2a5c2
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 48 deletions.
19 changes: 7 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,20 @@ language: php

dist: trusty
php:
- "7.4"
- "7.3"
- "7.2"
- "7.1"
- "7.0"
- "5.6"
- "5.5"
- "5.4"

matrix:
include:
- php: "5.3"
dist: precise

before_script:
- travis_retry composer self-update
- travis_retry composer install --no-interaction --dev --prefer-source
- travis_retry composer install --no-interaction --prefer-source

script:
- bash -c 'if [ "$TRAVIS_PHP_VERSION" == "hhvm" ]; then vendor/bin/phpunit --verbose --coverage-text; fi;'
- bash -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then vendor/bin/phpunit --verbose --coverage-clover build/logs/clover.xml --coverage-text; fi;'
- vendor/bin/phpunit --verbose --coverage-clover coverage.clover --coverage-text

after_success:
- bash -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi;'
- bash -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi;'
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ API Docs: https://docs.paystation.co.nz/
[![Total Downloads](https://poser.pugx.org/burnbright/omnipay-paystation/d/total.png)](https://packagist.org/packages/burnbright/omnipay-paystation)

[Omnipay](https://github.com/omnipay/omnipay) is a framework agnostic, multi-gateway payment
processing library for PHP 5.3+. This package implements Paystation support for Omnipay.
processing library for PHP 5.6+. This package implements Paystation support for Omnipay.

## Installation

Expand All @@ -21,7 +21,7 @@ to your `composer.json` file:
```json
{
"require": {
"burnbright/omnipay-paystation": "~2.0"
"burnbright/omnipay-paystation": "~3.0"
}
}
```
Expand Down
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"omnipay",
"pay",
"paystation",
"payment"
"payment",
"trademe",
"trade me"
],
"homepage": "https://github.com/burnbright/omnipay-paystation",
"license": "MIT",
Expand All @@ -28,14 +30,16 @@
"psr-4": { "Omnipay\\Paystation\\" : "src/" }
},
"require": {
"omnipay/common": "~2.0"
"omnipay/common": "~3.0"
},
"require-dev": {
"omnipay/tests": "~2.0"
"omnipay/tests": "~3.0",
"squizlabs/php_codesniffer": "^3.5"
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
"dev-master": "3.0.x-dev"
}
}
}
},
"prefer-stable": true
}
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
5 changes: 2 additions & 3 deletions src/Message/CompletePurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ public function getData()
public function sendData($data)
{
$postdata = http_build_query($data);
$httpRequest = $this->httpClient->post($this->getEndPoint($postdata), null, $data);
$httpResponse = $httpRequest->send();
$httpResponse = $this->httpClient->request('GET', $this->getEndPoint('').'&'.$postdata, []);

return $this->response = new CompletePurchaseResponse($this, $httpResponse->getBody());
return $this->response = new CompletePurchaseResponse($this, $httpResponse->getBody()->getContents());
}
}
6 changes: 3 additions & 3 deletions src/Message/CompletePurchaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
namespace Omnipay\Paystation\Message;

use DOMDocument;
use Omnipay\Common\Message\AbstractResponse;
use Omnipay\Common\Message\RequestInterface;
use Omnipay\Common\Exception\InvalidResponseException;
use Omnipay\Common\Message\AbstractResponse;
use Omnipay\Paystation\Message\CompletePurchaseRequest;

/**
* Paystation Complete Purchase Response
*/
class CompletePurchaseResponse extends AbstractResponse
{

public function __construct(RequestInterface $request, $data)
public function __construct(CompletePurchaseRequest $request, $data)
{
$this->request = $request;

Expand Down
5 changes: 2 additions & 3 deletions src/Message/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ public function getData()
public function sendData($data)
{
$postdata = http_build_query($data);
$httpRequest = $this->httpClient->post($this->getEndPoint($postdata), null, $postdata);
$httpResponse = $httpRequest->send();
$httpResponse = $this->httpClient->request('POST', $this->getEndPoint($postdata), [], $postdata);

return $this->response = new PurchaseResponse($this, $httpResponse->getBody());
return $this->response = new PurchaseResponse($this, $httpResponse->getBody()->getContents());
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Message/PurchaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
namespace Omnipay\Paystation\Message;

use DOMDocument;
use Omnipay\Common\Message\AbstractResponse;
use Omnipay\Common\Message\RequestInterface;
use Omnipay\Common\Exception\InvalidResponseException;
use Omnipay\Common\Message\AbstractResponse;
use Omnipay\Common\Message\RedirectResponseInterface;
use Omnipay\Paystation\Message\PurchaseRequest;

/**
* Paystation Response
*/
class PurchaseResponse extends AbstractResponse implements RedirectResponseInterface
{

public function __construct(RequestInterface $request, $data)
public function __construct(PurchaseRequest $request, $data)
{
$this->request = $request;

Expand Down
22 changes: 10 additions & 12 deletions tests/HostedGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public function setUp()
$this->gateway->setGatewayId('FOOBAR');
}

public function testSetup() {
public function testSetup()
{
$this->gateway->setHmacKey('abc');

$this->assertEquals('Paystation', $this->gateway->getName());
Expand Down Expand Up @@ -101,7 +102,7 @@ public function testPurchaseNegative()
{
$this->setMockHttpResponse('PurchaseRequestFailure.txt');

$this->setExpectedException('Omnipay\Common\Exception\InvalidRequestException');
$this->expectException('Omnipay\Common\Exception\InvalidRequestException');
$response = $this->gateway->purchase(array(
'amount' => '-12345.00',
'currency' => 'NZD',
Expand All @@ -118,7 +119,7 @@ public function testPurchaseInvalid()
{
$this->setMockHttpResponse('PurchaseResponseInvalid.txt');

$this->setExpectedException('Omnipay\Common\Exception\InvalidResponseException');
$this->expectException('Omnipay\Common\Exception\InvalidResponseException');
$response = $this->gateway->purchase(array(
'amount' => '12345.00',
'currency' => 'NZD',
Expand Down Expand Up @@ -186,10 +187,8 @@ public function testCompletePurchaseInvalid()
);
$this->setMockHttpResponse('CompletePurchaseRequestInvalid.txt');

$this->setExpectedException(
'Omnipay\Common\Exception\InvalidResponseException',
'Access denied for user [123456]'
);
$this->expectException('Omnipay\Common\Exception\InvalidResponseException');
$this->expectExceptionMessage('Access denied for user [123456]');
$response = $this->gateway->completePurchase()->send();
}

Expand Down Expand Up @@ -244,10 +243,9 @@ public function testCompletePurchaseCompletelyInvalid()
);
$this->setMockHttpResponse('PurchaseRequestInvalid.txt');

$this->setExpectedException(
'Omnipay\Common\Exception\InvalidResponseException',
'Invalid response from payment gateway' // default message
);
$this->expectException('Omnipay\Common\Exception\InvalidResponseException');
// default message
$this->expectExceptionMessage('Invalid response from payment gateway');
$response = $this->gateway->completePurchase()->send();
}

Expand All @@ -263,7 +261,7 @@ public function testCompletePurchaseMissingTransactionReference()
);
$this->setMockHttpResponse('CompletePurchaseRequestInvalid.txt');

$this->setExpectedException('Omnipay\Common\Exception\InvalidRequestException');
$this->expectException('Omnipay\Common\Exception\InvalidRequestException');
$response = $this->gateway->completePurchase()->send();
}
}
1 change: 0 additions & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@

// autoload abstract TestCase classes in test directory
$autoloader->add('Omnipay', __DIR__.'/../vendor/omnipay/omnipay/tests');

0 comments on commit ec2a5c2

Please sign in to comment.