Skip to content

Commit

Permalink
Merge pull request thephpleague#26 from sudiptpa/v3-release
Browse files Browse the repository at this point in the history
Omnipay v3 release
  • Loading branch information
barryvdh authored May 30, 2018
2 parents 8de212f + 3b62c8f commit 4a0f2e0
Show file tree
Hide file tree
Showing 35 changed files with 316 additions and 319 deletions.
26 changes: 15 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm
- 7.2

env:
global:
- setup=basic

matrix:
include:
- php: 5.6
env: setup=lowest

# This triggers builds to run on the new TravisCI infrastructure.
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: false

## Cache composer
cache:
directories:
- $HOME/.composer/cache
before_install:
- travis_retry composer self-update

before_script:
- composer install -n --dev --prefer-source
install:
- if [[ $setup = 'basic' ]]; then travis_retry composer install --no-interaction --prefer-dist; 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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012-2013 Adrian Macneil
Copyright (c) 2012-2018 Adrian Macneil

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,12 @@ in 8 countries.

## Installation

Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it
to your `composer.json` file:

```json
{
"require": {
"omnipay/eway": "~2.0"
}
}
```
Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply require `league/omnipay` and `omnipay/eway` with Composer:

And run composer to update your dependencies:
```
composer require league/omnipay omnipay/eway
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
```

## Basic Usage

Expand Down
16 changes: 12 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,22 @@
"psr-4": { "Omnipay\\Eway\\" : "src/" }
},
"require": {
"omnipay/common": "~2.0"
"omnipay/common": "^3"
},
"require-dev": {
"omnipay/tests": "~2.0"
"omnipay/tests": "^3",
"squizlabs/php_codesniffer": "^3",
"phpro/grumphp": "^0.14.0"
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
"dev-master": "3.0.x-dev"
}
}
},
"scripts": {
"test": "vendor/bin/phpunit",
"check-style": "phpcs -p --standard=PSR2 src/",
"fix-style": "phpcbf -p --standard=PSR2 src/"
},
"prefer-stable": true
}
15 changes: 15 additions & 0 deletions grumphp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
parameters:
git_dir: .
bin_dir: vendor/bin
tasks:
phpunit:
config_file: ~
testsuite: ~
group: []
always_execute: false
phpcs:
standard: PSR2
warning_severity: ~
ignore_patterns:
- tests/
triggered_by: [php]
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
16 changes: 8 additions & 8 deletions src/DirectGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public function getName()

public function getDefaultParameters()
{
return array(
return [
'customerId' => '',
'testMode' => false,
);
'testMode' => false,
];
}

public function getCustomerId()
Expand All @@ -40,27 +40,27 @@ public function setCustomerId($value)
return $this->setParameter('customerId', $value);
}

public function authorize(array $parameters = array())
public function authorize(array $parameters = [])
{
return $this->createRequest('\Omnipay\Eway\Message\DirectAuthorizeRequest', $parameters);
}

public function capture(array $parameters = array())
public function capture(array $parameters = [])
{
return $this->createRequest('\Omnipay\Eway\Message\DirectCaptureRequest', $parameters);
}

public function purchase(array $parameters = array())
public function purchase(array $parameters = [])
{
return $this->createRequest('\Omnipay\Eway\Message\DirectPurchaseRequest', $parameters);
}

public function refund(array $parameters = array())
public function refund(array $parameters = [])
{
return $this->createRequest('\Omnipay\Eway\Message\DirectRefundRequest', $parameters);
}

public function void(array $parameters = array())
public function void(array $parameters = [])
{
return $this->createRequest('\Omnipay\Eway\Message\DirectVoidRequest', $parameters);
}
Expand Down
7 changes: 5 additions & 2 deletions src/Message/DirectAbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Omnipay\Eway\Message;

use Omnipay\Common\Message\AbstractRequest;
use SimpleXMLElement;

/**
* eWAY Direct Abstract Request
Expand All @@ -12,9 +13,11 @@ abstract class DirectAbstractRequest extends AbstractRequest

public function sendData($data)
{
$httpResponse = $this->httpClient->post($this->getEndpoint(), null, $data->asXML())->send();
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], $data->asXML());

return $this->response = new DirectResponse($this, $httpResponse->xml());
$xml = new SimpleXMLElement($httpResponse->getBody()->getContents());

return $this->response = new DirectResponse($this, $xml);
}

public function getCustomerId()
Expand Down
19 changes: 7 additions & 12 deletions src/Message/RapidCaptureRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public function getData()
{
$this->validate('amount', 'transactionReference');

$data = array();
$data = [];

$data['Payment'] = array();
$data['Payment'] = [];
$data['Payment']['TotalAmount'] = $this->getAmountInteger();
$data['Payment']['InvoiceNumber'] = $this->getTransactionId();
$data['Payment']['InvoiceDescription'] = $this->getDescription();
Expand All @@ -49,20 +49,15 @@ public function getData()

public function getEndpoint()
{
return $this->getEndpointBase().'/CapturePayment';
return $this->getEndpointBase() . '/CapturePayment';
}

public function sendData($data)
{
// This request uses the REST endpoint and requires the JSON content type header
$httpResponse = $this->httpClient->post(
$this->getEndpoint(),
array('content-type' => 'application/json'),
json_encode($data)
)
->setAuth($this->getApiKey(), $this->getPassword())
->send();
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [
'content-type' => 'application/json',
], json_encode($data));

return $this->response = new RapidResponse($this, $httpResponse->json());
return $this->response = new RapidResponse($this, json_decode((string) $httpResponse->getBody(), true));
}
}
8 changes: 3 additions & 5 deletions src/Message/RapidDirectAbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function getBaseData()
}

if ($this->getCard()) {
$data['Customer']['CardDetails'] = array();
$data['Customer']['CardDetails'] = [];
$data['Customer']['CardDetails']['Name'] = $this->getCard()->getName();

if ($this->getCard()->getExpiryYear() && $this->getCard()->getExpiryMonth()) {
Expand Down Expand Up @@ -101,10 +101,8 @@ protected function getBaseData()

public function sendData($data)
{
$httpResponse = $this->httpClient->post($this->getEndpoint(), null, json_encode($data))
->setAuth($this->getApiKey(), $this->getPassword())
->send();
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], json_encode($data));

return $this->response = new RapidResponse($this, $httpResponse->json());
return $this->response = new RapidResponse($this, json_decode((string) $httpResponse->getBody(), true));
}
}
19 changes: 9 additions & 10 deletions src/Message/RapidDirectCreateCardRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

namespace Omnipay\Eway\Message;

use Omnipay\Eway\RapidDirectGateway;
use Omnipay\Omnipay;

/**
Expand Down Expand Up @@ -62,7 +61,7 @@ public function getData()
{
$data = $this->getBaseData();

$data['Payment'] = array();
$data['Payment'] = [];
$data['Payment']['TotalAmount'] = 0;

$data['Method'] = 'CreateTokenCustomer';
Expand All @@ -72,31 +71,31 @@ public function getData()

protected function getEndpoint()
{
return $this->getEndpointBase().'/DirectPayment.json';
return $this->getEndpointBase() . '/DirectPayment.json';
}

public function sendData($data)
{
$httpResponse = $this->httpClient->post($this->getEndpoint(), null, json_encode($data))
->setAuth($this->getApiKey(), $this->getPassword())
->send();
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], json_encode($data));

$this->response = new RapidDirectCreateCardResponse($this, $httpResponse->json());
$this->response = new RapidDirectCreateCardResponse(
$this,
json_decode((string) $httpResponse->getBody(), true)
);

if ($this->getAction() === 'Purchase' && $this->response->isSuccessful()) {
/** @var RapidDirectGateway $purchaseGateway */
$purchaseGateway = Omnipay::create('Eway_RapidDirect');
$purchaseGateway->setApiKey($this->getApiKey());
$purchaseGateway->setPassword($this->getPassword());
$purchaseGateway->setTestMode($this->getTestMode());
$purchaseResponse = $purchaseGateway->purchase(array(
$purchaseResponse = $purchaseGateway->purchase([
'amount' => $this->getAmount(),
'currency' => $this->getCurrency(),
'description' => $this->getDescription(),
'transactionId' => $this->getTransactionId(),
'card' => $this->getCard(),
'cardReference' => $this->response->getCardReference(),
))->send();
])->send();
$this->response->setPurchaseResponse($purchaseResponse);
}

Expand Down
13 changes: 7 additions & 6 deletions src/Message/RapidDirectUpdateCardRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getData()

$this->validate('cardReference');

$data['Payment'] = array();
$data['Payment'] = [];
$data['Payment']['TotalAmount'] = 0;

$data['Customer']['TokenCustomerID'] = $this->getCardReference();
Expand All @@ -76,15 +76,16 @@ public function getData()

protected function getEndpoint()
{
return $this->getEndpointBase().'/DirectPayment.json';
return $this->getEndpointBase() . '/DirectPayment.json';
}

public function sendData($data)
{
$httpResponse = $this->httpClient->post($this->getEndpoint(), null, json_encode($data))
->setAuth($this->getApiKey(), $this->getPassword())
->send();
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], json_encode($data));

return $this->response = new RapidDirectCreateCardResponse($this, $httpResponse->json());
return $this->response = new RapidDirectCreateCardResponse(
$this,
json_decode((string) $httpResponse->getBody(), true)
);
}
}
22 changes: 9 additions & 13 deletions src/Message/RapidDirectVoidRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* eWAY Rapid Void Request
*/

namespace Omnipay\Eway\Message;

class RapidDirectVoidRequest extends AbstractRequest
Expand All @@ -11,27 +11,23 @@ public function getData()
{
$this->validate('transactionReference');

$data = array();
$data = [];
$data['TransactionId'] = $this->getTransactionReference();

return $data;
}

protected function getEndpoint()
{
return $this->getEndpointBase().'/CancelAuthorisation';
return $this->getEndpointBase() . '/CancelAuthorisation';
}

public function sendData($data)
{
// This request uses the REST endpoint and requires the JSON content type header
$httpResponse = $this->httpClient->post(
$this->getEndpoint(),
array('content-type' => 'application/json'),
json_encode($data)
)
->setAuth($this->getApiKey(), $this->getPassword())
->send();
return $this->response = new RapidResponse($this, $httpResponse->json());
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [
'content-type' => 'application/json',
], json_encode($data));

return $this->response = new RapidResponse($this, json_decode((string) $httpResponse->getBody(), true));
}
}
Loading

0 comments on commit 4a0f2e0

Please sign in to comment.