Skip to content

Commit 171673a

Browse files
committed
Merge branch 'master' of github.com:superbrave/omnipay-icepay-payments
2 parents fccf004 + c44627c commit 171673a

18 files changed

+269
-40
lines changed

.scrutinizer.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
filter:
2+
paths:
3+
- src/
4+
5+
excluded_paths:
6+
- bin/
7+
- tests
8+
- var/
9+
10+
dependency_paths:
11+
- vendor/
12+
13+
checks:
14+
php: true
15+
16+
build:
17+
dependencies:
18+
override:
19+
- composer install --no-interaction --prefer-dist --optimize-autoloader
20+
21+
nodes:
22+
composer-file-validation:
23+
dependencies:
24+
override:
25+
- true
26+
27+
tests:
28+
override:
29+
- composer validate
30+
31+
code-standards:
32+
tests:
33+
override:
34+
- ./bin/php-cs-fixer fix --dry-run -v
35+
36+
security-check:
37+
requires:
38+
- branch: master
39+
40+
dependencies:
41+
override:
42+
- true
43+
44+
tests:
45+
override:
46+
- if [ -z "$SCRUTINIZER_PR_SOURCE_BRANCH" ]; then curl -o security-checker.phar https://get.sensiolabs.org/security-checker.phar; fi;
47+
- if [ -z "$SCRUTINIZER_PR_SOURCE_BRANCH" ]; then php security-checker.phar security:check; fi;
48+
49+
phpunit:
50+
requires:
51+
- node: composer-file-validation
52+
- node: code-standards
53+
54+
tests:
55+
override:
56+
- command: ./bin/phpunit --coverage-clover=code-coverage
57+
coverage:
58+
file: code-coverage
59+
format: clover
60+
61+
static-code-analysis:
62+
tests:
63+
override:
64+
- php-scrutinizer-run
65+
66+
environment:
67+
php:
68+
version: 7.2
69+
pecl_extensions:
70+
- zip
71+
72+
build_failure_conditions:
73+
- 'elements.rating(<= D).new.exists' # No new classes/methods with a rating of D or worse.
74+
- 'project.metric("scrutinizer.quality", < 8)' # Code Quality Rating drops below 8.
75+
- 'project.metric("scrutinizer.test_coverage", < 0.80)' # Code Coverage drops below 80%.

README.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Omnipay: Icepay Payments (ICEX2.0)
2+
[![Build Status](https://scrutinizer-ci.com/g/superbrave/omnipay-icepay-payments/badges/build.png?b=master)](https://scrutinizer-ci.com/g/superbrave/omnipay-icepay-payments/build-status/master)
3+
[![Code Coverage](https://scrutinizer-ci.com/g/superbrave/omnipay-icepay-payments/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/superbrave/omnipay-icepay-payments/?branch=master)
4+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/superbrave/omnipay-icepay-payments/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/superbrave/omnipay-icepay-payments/?branch=master)
25
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
36

47
## Introduction
@@ -84,37 +87,44 @@ $data = [
8487
],
8588
];
8689

87-
$response = $gateway->authorize($data)->send()->getData();
90+
$request = $gateway->authorize($data);
91+
92+
$response = $response->send();
8893
```
89-
This will return the order details as well as the checkout HTML snippet to render on your site.
9094

9195
[API documentation](http://docs2.icepay.com/calling-our-webservice/transaction-functions/)
9296

9397
### Status
9498

9599
```php
96-
$success = $gateway->fetchTransaction([
100+
$data = [
97101
'ContractProfileId' => '85cf0581-36e2-45c7-8d8c-a24c6f52902c',
98102
'AmountInCents' => 1337,
99103
'CurrencyCode' => 'EUR',
100104
'Reference' => '829c7998-6497-402c-a049-51801ba33662',
101-
])->send()
102-
->isSuccessful();
105+
];
106+
107+
$request = $gateway->fetchTransaction($data);
108+
109+
$response = $request->send();
103110
```
104111

105112
[API documentation](https://icepay2.docs.apiary.io/#reference/0/transaction)
106113

107114
### Refund
108-
*Do note: refunds have not been tested in production*
115+
*Do note: refunds implementation has not been tested.*
109116

110117
```php
111-
$success = $gateway->refund([
118+
$data = [
112119
'ContractProfileId' => '85cf0581-36e2-45c7-8d8c-a24c6f52902c',
113120
'AmountInCents' => 1337,
114121
'CurrencyCode' => 'EUR',
115122
'Reference' => '829c7998-6497-402c-a049-51801ba33662',
116-
])->send()
117-
->isSuccessful();
123+
];
124+
125+
$request = $gateway->refund($data);
126+
127+
$response = $request->send();
118128
```
119129

120130
[API documentation](https://icepay2.docs.apiary.io/#reference/0/transaction/refund)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"autoload-dev": {
2828
"psr-4": {
29-
"Omnipay\\IcepayPayments\\": "tests/"
29+
"Omnipay\\IcepayPayments\\Tests\\": "tests/"
3030
}
3131
},
3232
"config": {

src/Gateway.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class Gateway extends AbstractGateway
3838

3939
/**
4040
* {@inheritdoc}
41+
*
42+
* @codeCoverageIgnore
4143
*/
4244
public function getName(): string
4345
{

src/Message/AbstractRequest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@
55
use DateTimeInterface;
66
use Omnipay\Common\Message\AbstractRequest as OmnipayAbstractRequest;
77
use Psr\Http\Message\ResponseInterface;
8+
use Symfony\Component\HttpFoundation\Request;
89

910
/**
1011
* Class AbstractRequest.
1112
*/
1213
abstract class AbstractRequest extends OmnipayAbstractRequest
1314
{
14-
/**
15-
* @var string
16-
*/
17-
public const METHOD_POST = 'POST';
18-
1915
/**
2016
* @var string
2117
*/
@@ -47,7 +43,7 @@ protected function sendRequest(string $method, string $urlPath, array $data): Re
4743
$headers = $this->getAuthenticationHeaders($securityHash);
4844
$body = null;
4945

50-
if ($method === self::METHOD_POST) {
46+
if ($method === Request::METHOD_POST) {
5147
$headers['Content-Type'] = 'application/json';
5248
$body = json_encode($data);
5349
}

src/Message/CreateTransactionRequest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Omnipay\IcepayPayments\Message;
44

55
use Omnipay\Common\Message\ResponseInterface;
6+
use Symfony\Component\HttpFoundation\Request;
67

78
/**
89
* The request for creating a transaction at Icepay.
@@ -59,7 +60,7 @@ public function getData(): array
5960
public function sendData($data): ResponseInterface
6061
{
6162
$this->sendRequest(
62-
self::METHOD_POST,
63+
Request::METHOD_POST,
6364
'/contract/transaction',
6465
$data
6566
);

src/Message/RefundRequest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Omnipay\Common\Exception\InvalidRequestException;
66
use Omnipay\Common\Message\ResponseInterface;
7+
use Symfony\Component\HttpFoundation\Request;
78

89
/**
910
* The request for refunding at Icepay.
@@ -38,7 +39,7 @@ public function sendData($data): ResponseInterface
3839
}
3940

4041
$this->sendRequest(
41-
self::METHOD_POST,
42+
Request::METHOD_POST,
4243
sprintf(
4344
'/transaction/%s/refund',
4445
$this->getTransactionReference()

src/Message/TransactionStatusRequest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Omnipay\IcepayPayments\Message;
44

55
use Omnipay\Common\Message\ResponseInterface;
6+
use Symfony\Component\HttpFoundation\Request;
67

78
/**
89
* The request for getting the transaction status at Icepay.
@@ -27,7 +28,7 @@ public function getData(): array
2728
public function sendData($data): ResponseInterface
2829
{
2930
$this->sendRequest(
30-
self::METHOD_POST,
31+
Request::METHOD_POST,
3132
sprintf(
3233
'/transaction/%s',
3334
$this->getTransactionReference()

tests/AbstractTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Omnipay\IcepayPayments;
3+
namespace Omnipay\IcepayPayments\Tests;
44

55
use Http\Mock\Client as ClientMock;
66
use Omnipay\Common\Http\Client;

tests/GatewayTest.php

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,43 @@
11
<?php
22

3-
namespace Omnipay\IcepayPayments;
3+
namespace Omnipay\IcepayPayments\Tests;
44

55
use Omnipay\Common\GatewayInterface;
6-
use PHPUnit\Framework\TestCase;
6+
use Omnipay\IcepayPayments\Gateway;
7+
use Omnipay\IcepayPayments\Message\CreateTransactionRequest;
8+
use Omnipay\IcepayPayments\Message\RefundRequest;
9+
use Omnipay\IcepayPayments\Message\TransactionStatusRequest;
710

811
/**
912
* Tests the Icepay gateway.
1013
*/
11-
class GatewayTest extends TestCase
14+
class GatewayTest extends AbstractTestCase
1215
{
1316
/**
1417
* @var GatewayInterface
1518
*/
1619
public $gateway;
1720

21+
/**
22+
* @var array
23+
*/
24+
private $options;
25+
1826
/**
1927
* Creates a new Gateway instance for testing.
2028
*/
2129
protected function setUp(): void
2230
{
23-
$this->gateway = new Gateway();
31+
$this->gateway = new Gateway($this->httpClient, $this->httpRequest);
32+
$this->options = [
33+
'paymentMethod' => 'IDEAL',
34+
'amountInCents' => 1337,
35+
'currencyCode' => 'EUR',
36+
'languageCode' => 'nl',
37+
'countryCode' => 'NL',
38+
'issuerCode' => 'ABNAMRO',
39+
'reference' => '829c7998-6497-402c-a049-51801ba33662',
40+
];
2441
}
2542

2643
/**
@@ -50,13 +67,54 @@ public function testFetchTransactionParameters(): void
5067
$setter = 'set'.ucfirst($this->camelCase($key));
5168
$value = uniqid();
5269
$this->gateway->$setter($value);
70+
$this->assertSame($value, $this->gateway->$getter());
5371

5472
// request should have matching property, with correct value
5573
$request = $this->gateway->fetchTransaction();
56-
$this->assertSame($value, $request->$getter());
74+
$this->assertSame($this->gateway->$getter(), $request->$getter());
5775
}
5876
}
5977

78+
/**
79+
* Tests if Gateway::authorize will return an instance of CreateTransactionRequest.
80+
*/
81+
public function testAuthorize(): void
82+
{
83+
$request = $this->gateway->authorize($this->options);
84+
85+
$this->assertInstanceOf(CreateTransactionRequest::class, $request);
86+
}
87+
88+
/**
89+
* Tests if Gateway::completeAuthorize will return an instance of TransactionStatusRequest.
90+
*/
91+
public function testCompleteAuthorize(): void
92+
{
93+
$request = $this->gateway->completeAuthorize($this->options);
94+
95+
$this->assertInstanceOf(TransactionStatusRequest::class, $request);
96+
}
97+
98+
/**
99+
* Tests if Gateway::capture will return an instance of TransactionStatusRequest.
100+
*/
101+
public function testCapture(): void
102+
{
103+
$request = $this->gateway->capture($this->options);
104+
105+
$this->assertInstanceOf(TransactionStatusRequest::class, $request);
106+
}
107+
108+
/**
109+
* Tests if Gateway::refund will return an instance of RefundRequest.
110+
*/
111+
public function testRefund(): void
112+
{
113+
$request = $this->gateway->refund($this->options);
114+
115+
$this->assertInstanceOf(RefundRequest::class, $request);
116+
}
117+
60118
/**
61119
* Returns the test cases for @see testInitializeSetsBaseUrlBasedOnTestMode.
62120
*

0 commit comments

Comments
 (0)