Skip to content

Commit 4c6fdcc

Browse files
committed
New version
* add support for direct payments/MOTO * add unit tests to get coverage back to 100% * add explicit PHP version requirement to composer * add different PHPUnit config for older PHP * change to PatronBase forks of common & tests * change from Travis to Github Actions * update composer dependencies * update PHPUnit config to mimic omnipay-common * fix failing unit test * fix up whitespace/phpcs messages
1 parent c455ece commit 4c6fdcc

13 files changed

+234
-101
lines changed

.github/workflows/phpunit.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: "PHPUnit tests"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- "master"
8+
9+
jobs:
10+
phpunit:
11+
name: "PHPUnit tests"
12+
13+
runs-on: "ubuntu-latest"
14+
15+
strategy:
16+
matrix:
17+
dependencies:
18+
- "highest"
19+
php-version:
20+
- "7.2"
21+
- "7.3"
22+
- "7.4"
23+
- "8.0"
24+
- "8.1"
25+
- "8.2"
26+
- "8.3"
27+
- "8.4"
28+
29+
include:
30+
- php-version: '7.2'
31+
dependencies: "lowest"
32+
33+
steps:
34+
- name: "Checkout"
35+
uses: "actions/checkout@v4"
36+
37+
- name: "Install PHP"
38+
uses: "shivammathur/setup-php@v2"
39+
with:
40+
coverage: "pcov"
41+
php-version: "${{ matrix.php-version }}"
42+
ini-values: memory_limit=-1
43+
tools: composer:v2
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
47+
# Fixes any pubkeys failure (add a `composer diagnose` step to debug if necessary)
48+
- name: "Composer force self-update"
49+
run: "composer self-update"
50+
51+
- name: "Install lowest dependencies"
52+
if: ${{ matrix.dependencies == 'lowest' }}
53+
run: "composer update --prefer-lowest --no-interaction --no-progress"
54+
55+
- name: "Install highest dependencies"
56+
if: ${{ matrix.dependencies == 'highest' }}
57+
run: "composer update --no-interaction --no-progress"
58+
59+
- name: "Tests (PHPUnit 9)"
60+
if: ${{ matrix.php-version <= '8.0' }}
61+
run: "vendor/bin/phpunit --configuration phpunit9.xml.dist"
62+
63+
- name: "Tests (PHPUnit 10+)"
64+
if: ${{ matrix.php-version >= '8.1' }}
65+
run: "vendor/bin/phpunit"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
composer.lock
33
composer.phar
44
phpunit.xml
5+
/.phpunit.result.cache
6+
/build

.travis.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

composer.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,41 @@
3535
"psr-4": { "Omnipay\\Redsys\\" : "tests/" }
3636
},
3737
"require": {
38+
"php": "^7.2|^8.0",
3839
"omnipay/common": "dev-address3-support"
3940
},
4041
"require-dev": {
4142
"omnipay/tests": "dev-address3-support",
42-
"squizlabs/php_codesniffer": "^3.5"
43+
"squizlabs/php_codesniffer": "^3.5",
44+
"http-interop/http-factory-guzzle": "^1.1"
4345
},
4446
"suggest": {
4547
"ext-openssl": "Required for hashing functions to check message signatures"
4648
},
49+
"scripts": {
50+
"test": "phpunit",
51+
"check-style": "phpcs -p --standard=PSR2 src/",
52+
"fix-style": "phpcbf -p --standard=PSR2 src/"
53+
},
4754
"extra": {
4855
"branch-alias": {
49-
"dev-master": "3.2.x-dev"
56+
"dev-master": "4.0.x-dev"
5057
}
5158
},
5259
"repositories": [
5360
{
5461
"type": "vcs",
55-
"url": "https://github.com/CodeDruids/omnipay-common"
62+
"url": "https://github.com/PatronBase/omnipay-common"
5663
},
5764
{
5865
"type": "vcs",
59-
"url": "https://github.com/CodeDruids/omnipay-tests"
66+
"url": "https://github.com/PatronBase/omnipay-tests"
6067
}
6168
],
62-
"prefer-stable": true
69+
"prefer-stable": true,
70+
"config": {
71+
"allow-plugins": {
72+
"php-http/discovery": true
73+
}
74+
}
6375
}

phpunit.xml.dist

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
5+
backupGlobals="false"
6+
backupStaticProperties="false"
57
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
98
processIsolation="false"
10-
stopOnFailure="false"
11-
syntaxCheck="false">
12-
<php>
13-
<ini name="date.timezone" value="UTC" />
14-
</php>
15-
<testsuites>
16-
<testsuite name="Omnipay Test Suite">
17-
<directory>./tests/</directory>
18-
</testsuite>
19-
</testsuites>
20-
<filter>
21-
<whitelist>
22-
<directory>./src</directory>
23-
</whitelist>
24-
</filter>
9+
stopOnFailure="false">
10+
<coverage>
11+
<report>
12+
<clover outputFile="build/logs/clover.xml"/>
13+
<html outputDirectory="build/coverage"/>
14+
<text outputFile="build/coverage.txt"/>
15+
</report>
16+
</coverage>
17+
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
18+
<include>
19+
<directory suffix=".php">src/</directory>
20+
</include>
21+
</source>
22+
<testsuites>
23+
<testsuite name="Omnipay Test Suite">
24+
<directory>tests</directory>
25+
</testsuite>
26+
</testsuites>
27+
<logging>
28+
<junit outputFile="build/report.junit.xml"/>
29+
</logging>
2530
</phpunit>

phpunit9.xml.dist

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
backupGlobals="false"
6+
backupStaticAttributes="false"
7+
colors="true"
8+
verbose="true"
9+
convertErrorsToExceptions="true"
10+
convertNoticesToExceptions="true"
11+
convertWarningsToExceptions="true"
12+
processIsolation="false"
13+
stopOnFailure="false">
14+
<coverage>
15+
<include>
16+
<directory suffix=".php">src/</directory>
17+
</include>
18+
<report>
19+
<clover outputFile="build/logs/clover.xml"/>
20+
<html outputDirectory="build/coverage"/>
21+
<text outputFile="build/coverage.txt"/>
22+
</report>
23+
</coverage>
24+
<testsuites>
25+
<testsuite name="Omnipay Test Suite">
26+
<directory>tests</directory>
27+
</testsuite>
28+
</testsuites>
29+
<logging>
30+
<junit outputFile="build/report.junit.xml"/>
31+
</logging>
32+
</phpunit>

src/Message/PurchaseRequest.php

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function getConsumerLanguage()
161161
/**
162162
* Set the language presented to the consumer
163163
*
164-
* @param null|string|int Either the ISO 639-1 code to be converted, or the gateway's own numeric language code
164+
* @param null|string|int $value The ISO 639-1 code to be converted, or the gateway's own numeric language code
165165
*/
166166
public function setConsumerLanguage($value)
167167
{
@@ -177,6 +177,41 @@ public function setConsumerLanguage($value)
177177
return $this->setParameter('consumerLanguage', $value);
178178
}
179179

180+
public function getDirectPayment()
181+
{
182+
return $this->getParameter('directPayment');
183+
}
184+
185+
/**
186+
* Set the "directness" of payment
187+
*
188+
* Can be true (merchant initiated), false/null (customer initiated) or "MOTO" (usually call centre initiated)
189+
* Invalid values will be converted to null as that's the most secure option
190+
*
191+
* @param null|bool|string $value
192+
*/
193+
public function setDirectPayment($value)
194+
{
195+
if (is_bool($value)) {
196+
// this is fine
197+
} elseif (is_string($value)) {
198+
if (strtoupper($value) == "TRUE") {
199+
$value = true;
200+
} elseif (strtoupper($value) == "FALSE") {
201+
$value = false;
202+
} elseif (strtoupper($value) == "MOTO") {
203+
$value = "MOTO";
204+
} else {
205+
// something invalid
206+
$value = null;
207+
}
208+
} else {
209+
// something invalid
210+
$value = null;
211+
}
212+
return $this->setParameter('directPayment', $value);
213+
}
214+
180215
public function getHmacKey()
181216
{
182217
return $this->getParameter('hmacKey');
@@ -278,11 +313,11 @@ public function setUse3DS($value)
278313
}
279314

280315
/**
281-
* Get the threeDSCompInd field
282-
* Corresponds to the Ds_Merchant_Emv3Ds.threeDSCompInd field in Redsys documentation.
316+
* Get the threeDSCompInd field, which indicates whether the 3DSMethod has been executed
283317
*
284-
* @return null|string
318+
* Corresponds to the Ds_Merchant_Emv3Ds.threeDSCompInd field in Redsys documentation.
285319
*
320+
* @return null|string Y = Successfully completed, N = Completed with errors, U = 3DSMethod not executed
286321
*/
287322
public function getThreeDSCompInd()
288323
{
@@ -303,11 +338,11 @@ public function setThreeDSCompInd($value)
303338
}
304339

305340
/**
306-
* Get the threeDSInfo field
307-
* Corresponds to the Ds_Merchant_Emv3Ds.threeDSInfo field in Redsys documentation.
341+
* Get the threeDSInfo field (the type of request)
308342
*
309-
* @return null|string
343+
* Corresponds to the Ds_Merchant_Emv3Ds.threeDSInfo field in Redsys documentation.
310344
*
345+
* @return null|string Possible values: CardData, AuthenticationData, ChallengeResponse
311346
*/
312347
public function getThreeDSInfo()
313348
{
@@ -1682,31 +1717,6 @@ public function setBrowserUserAgent($value)
16821717
return $this->setParameter('browserUserAgent', $value);
16831718
}
16841719

1685-
/**
1686-
* Get the notificationURL field
1687-
*
1688-
* Corresponds to the Ds_Merchant_Emv3Ds.notificationURL field
1689-
*
1690-
* @return null|string
1691-
*/
1692-
public function getNotificationURL()
1693-
{
1694-
return $this->getParameter('notificationURL');
1695-
}
1696-
1697-
/**
1698-
* Set the notificationURL field
1699-
*
1700-
* Corresponds to the Ds_Merchant_Emv3Ds.notificationURL field
1701-
*
1702-
* @param null|string $value
1703-
* @return self
1704-
*/
1705-
public function setNotificationURL($value)
1706-
{
1707-
return $this->setParameter('notificationURL', $value);
1708-
}
1709-
17101720
/**
17111721
* Get the basic data fields that don't require any 3DS/SCA fields
17121722
*/
@@ -1797,6 +1807,11 @@ public function getMerchantRiskData()
17971807
public function getData()
17981808
{
17991809
$data = $this->getBaseData();
1810+
1811+
if ($this->getDirectPayment() !== null) {
1812+
$data['Ds_Merchant_DirectPayment'] = $this->getDirectPayment();
1813+
}
1814+
18001815
if ($this->getScaExemptionIndicator() !== null) {
18011816
$data['Ds_Merchant_Excep_Sca'] = $this->getScaExemptionIndicator();
18021817
}
@@ -1838,11 +1853,9 @@ public function getData()
18381853
'browserScreenWidth' => $this->getBrowserScreenWidth(),
18391854
'browserTZ' => $this->getBrowserTZ(),
18401855
'browserUserAgent' => $this->getBrowserUserAgent(),
1841-
'notificationURL' => $this->getNotificationURL(),
1856+
'notificationURL' => $this->getNotifyUrl(),
18421857
'protocolVersion' => $this->getProtocolVersion(),
1843-
// Indicates whether the 3DSMethod has been executed. Values ​​accepted: Y= Successfully completed, N = Completed with errors, U = 3DSMethod not executed
18441858
'threeDSCompInd' => $this->getThreeDSCompInd(),
1845-
// Type of request. Possible values: CardData, AuthenticationData, ChallengeResponse
18461859
'threeDSInfo' => $this->getThreeDSInfo(),
18471860
'threeDSServerTransID' => $this->getTransactionId(),
18481861
// optional parameters for v2

0 commit comments

Comments
 (0)