Skip to content

Commit 6f4c9c0

Browse files
committed
Merge branch 'release/3.0.0'
2 parents 54a18d0 + 1e9502b commit 6f4c9c0

16 files changed

Lines changed: 383 additions & 531 deletions

.scrutinizer.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
build:
2+
nodes:
3+
analysis:
4+
tests:
5+
override:
6+
- php-scrutinizer-run
7+
8+
coverage:
9+
tests:
10+
override:
11+
- command: ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml
12+
coverage:
13+
file: build/logs/clover.xml
14+
format: clover
15+
216
environment:
317
php: 7.3.0
418
variables:
519
WP_TESTS_DB_NAME: 'wp_phpunit_tests'
620
WP_TESTS_DB_USER: 'root'
721
WP_TESTS_DB_PASS: ''
8-
WP_TESTS_DB_HOST: 'localhost'
9-
project_setup:
10-
before:
11-
- mysql -e "CREATE DATABASE wp_phpunit_tests"
22+
WP_TESTS_DB_HOST: '127.0.0.1'
23+
24+
services:
25+
mysql: 5.7
26+
1227
dependencies:
1328
override:
1429
- composer install --ignore-platform-reqs --no-interaction
15-
nodes:
16-
coverage:
17-
tests:
18-
override:
19-
- command: ./vendor/bin/phpunit
20-
coverage:
21-
file: build/logs/clover.xml
22-
format: clover
30+
31+
project_setup:
32+
before:
33+
- mysql -e "CREATE DATABASE wp_phpunit_tests"
2334

2435
filter:
2536
excluded_paths:

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
77
## [Unreleased][unreleased]
88
-
99

10+
## [3.0.0] - 2021-08-05
11+
- Updated to `pronamic/wp-pay-core` version `3.0.0`.
12+
- Updated to `pronamic/wp-money` version `2.0.0`.
13+
- Changed `TaxedMoney` to `Money`, no tax info.
14+
- Switched to `pronamic/wp-coding-standards`.
15+
- Simplified gateway registration for all active payment methods.
16+
1017
## [2.2.1] - 2021-04-26
1118
- Happy 2021.
1219

@@ -64,7 +71,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
6471
## 1.0.0 - 2016-03-23
6572
- First release.
6673

67-
[unreleased]: https://github.com/wp-pay-extensions/give/compare/2.2.1...HEAD
74+
[unreleased]: https://github.com/wp-pay-extensions/give/compare/3.0.0...HEAD
75+
[3.0.0]: https://github.com/wp-pay-extensions/give/compare/2.2.1...3.0.0
6876
[2.2.1]: https://github.com/wp-pay-extensions/give/compare/2.2.0...2.2.1
6977
[2.2.0]: https://github.com/wp-pay-extensions/give/compare/2.1.1...2.2.0
7078
[2.1.1]: https://github.com/wp-pay-extensions/give/compare/2.1.0...2.1.1

composer.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,22 @@
4242
],
4343
"require": {
4444
"php": ">=5.6.20",
45-
"wp-pay/core": "^2.6"
45+
"wp-pay/core": "^3.0"
4646
},
4747
"require-dev": {
4848
"bamarni/composer-bin-plugin": "^1.4",
49-
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
5049
"php-coveralls/php-coveralls": "^2.4",
51-
"phpcompatibility/php-compatibility": "^9.1",
52-
"phpcompatibility/phpcompatibility-wp": "^2.0",
5350
"phpmd/phpmd": "^2.7",
5451
"phpunit/phpunit": "^5.7 || ^6.0",
55-
"roots/wordpress": "^5.6",
56-
"squizlabs/php_codesniffer": "^3.4",
57-
"wp-coding-standards/wpcs": "^2.3",
58-
"wp-phpunit/wp-phpunit": "^5.6",
52+
"pronamic/wp-coding-standards": "^1.0",
53+
"roots/wordpress": "^5.8",
54+
"wp-phpunit/wp-phpunit": "^5.8",
5955
"wpackagist-plugin/give": "^2.9"
6056
},
6157
"scripts": {
6258
"coveralls": "vendor/bin/php-coveralls -v",
6359
"phpcbf": "vendor/bin/phpcbf",
64-
"phpcs": "vendor/bin/phpcs -s -v",
60+
"phpcs": "XDEBUG_MODE=off vendor/bin/phpcs -s -v",
6561
"phplint": "find src tests -name '*.php' | xargs -n 1 -P 4 php -l",
6662
"phpmd": "vendor/bin/phpmd src,tests text phpmd.ruleset.xml --suffixes php",
6763
"phpstan": "vendor/bin/phpstan analyse",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "give",
3-
"version": "2.2.1",
3+
"version": "3.0.0",
44
"description": "Give driver for the WordPress payment processing library.",
55
"repository": {
66
"type": "git",

phpcs.xml.dist

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,12 @@
11
<?xml version="1.0"?>
22

33
<ruleset name="WordPress Pay Give rules">
4-
<config name="minimum_supported_wp_version" value="4.7" />
5-
6-
<config name="testVersion" value="5.6-" />
7-
84
<file>.</file>
95

10-
<arg name="colors"/>
11-
<arg name="extensions" value="php" />
12-
<arg value="sp" />
13-
14-
<exclude-pattern>node_modules/*</exclude-pattern>
156
<exclude-pattern>tests/bootstrap.php</exclude-pattern>
167
<exclude-pattern>tests/wp-config.php</exclude-pattern>
17-
<exclude-pattern>vendor/*</exclude-pattern>
18-
<exclude-pattern>wordpress/*</exclude-pattern>
19-
<exclude-pattern type="relative">^wp-content/*</exclude-pattern>
20-
21-
<rule ref="PHPCompatibilityWP" />
22-
23-
<rule ref="WordPress">
24-
<exclude name="Generic.CodeAnalysis.UselessOverridingMethod.Found" />
25-
<exclude name="Generic.Files.LowercasedFilename.NotFound" />
268

9+
<rule ref="PronamicWP">
2710
<exclude name="Squiz.Commenting" />
28-
29-
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
30-
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
31-
32-
<exclude name="WordPress.PHP.DiscouragedFunctions.DiscouragedWithAlternative" />
3311
</rule>
3412
</ruleset>

src/BancontactGateway.php

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

src/BankTransferGateway.php

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

src/CreditCardGateway.php

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

src/DirectDebitGateway.php

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

src/Extension.php

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,30 +93,53 @@ public function give_payment_gateways( $gateways ) {
9393
if ( null === $this->gateways ) {
9494
$this->gateways = array();
9595

96-
$classes = array(
97-
'Gateway',
98-
'BancontactGateway',
99-
'BankTransferGateway',
100-
'CreditCardGateway',
101-
'DirectDebitGateway',
102-
'IDealGateway',
103-
'SofortGateway',
96+
// Get active and remove unsupported recurring-only payment methods.
97+
$payment_methods = array_merge( array( null ), PaymentMethods::get_active_payment_methods() );
98+
99+
$payment_methods = array_diff(
100+
$payment_methods,
101+
\array_keys( PaymentMethods::get_direct_debit_methods() )
104102
);
105103

106-
if ( PaymentMethods::is_active( PaymentMethods::GULDEN ) ) {
107-
$classes[] = 'GuldenGateway';
108-
}
104+
// Create gateways for payment methods.
105+
foreach ( $payment_methods as $payment_method ) {
106+
// Gateway identifier.
107+
$id = 'pronamic_pay';
108+
109+
if ( ! empty( $payment_method ) ) {
110+
$id = \sprintf( 'pronamic_pay_%s', $payment_method );
111+
112+
// Use `mister_cash` instead of `bancontact` for backwards compatibility.
113+
if ( PaymentMethods::BANCONTACT === $payment_method ) {
114+
$id = 'pronamic_pay_mister_cash';
115+
}
116+
}
109117

110-
foreach ( $classes as $class ) {
111-
$class = __NAMESPACE__ . '\\' . $class;
118+
// New gateway.
119+
$gateway = new Gateway( $id, $payment_method );
112120

113-
$gateway = new $class();
121+
$name = PaymentMethods::get_name( $payment_method, __( 'Pronamic', 'pronamic_ideal' ) );
122+
123+
// Admin label.
124+
$admin_label = \__( 'Pronamic', 'pronamic_ideal' );
125+
126+
if ( null !== $payment_method ) {
127+
$admin_label = sprintf( '%s - %s', \__( 'Pronamic', 'pronamic_ideal' ), $name );
128+
}
114129

115130
$this->gateways[ $gateway->id ] = array(
116-
'admin_label' => $gateway->name,
117-
'checkout_label' => $gateway->name,
131+
'admin_label' => $admin_label,
132+
'checkout_label' => $name,
118133
);
119134
}
135+
136+
// Sort gateways alphabetically.
137+
uasort(
138+
$this->gateways,
139+
function ( $a, $b ) {
140+
return strnatcasecmp( $a['admin_label'], $b['admin_label'] );
141+
}
142+
);
120143
}
121144

122145
return array_merge( $gateways, $this->gateways );

0 commit comments

Comments
 (0)