diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 0e877c6..354c329 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,25 +1,36 @@ build: + nodes: + analysis: + tests: + override: + - php-scrutinizer-run + + coverage: + tests: + override: + - command: ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml + coverage: + file: build/logs/clover.xml + format: clover + environment: php: 7.3.0 variables: WP_TESTS_DB_NAME: 'wp_phpunit_tests' WP_TESTS_DB_USER: 'root' WP_TESTS_DB_PASS: '' - WP_TESTS_DB_HOST: 'localhost' - project_setup: - before: - - mysql -e "CREATE DATABASE wp_phpunit_tests" + WP_TESTS_DB_HOST: '127.0.0.1' + + services: + mysql: 5.7 + dependencies: override: - composer install --ignore-platform-reqs --no-interaction - nodes: - coverage: - tests: - override: - - command: ./vendor/bin/phpunit - coverage: - file: build/logs/clover.xml - format: clover + + project_setup: + before: + - mysql -e "CREATE DATABASE wp_phpunit_tests" checks: php: diff --git a/CHANGELOG.md b/CHANGELOG.md index 690fc3b..d045353 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C ## [Unreleased][unreleased] - +## [3.0.0] - 2021-08-05 +- Updated to `pronamic/wp-pay-core` version `3.0.0`. +- Updated to `pronamic/wp-money` version `2.0.0`. +- Changed `TaxedMoney` to `Money`, no tax info. +- Switched to `pronamic/wp-coding-standards`. +- Added subscription email parameters. + ## [2.3.3] - 2021-06-18 - Added subscription mandate selection link to account update page. - Fixed updating gateway in subscription/transaction on payment method update (via mandate selection URL). @@ -131,7 +138,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C ## 1.0.0 - 2016-02-01 - First release. -[unreleased]: https://github.com/wp-pay-extensions/memberpress/compare/2.3.3...HEAD +[unreleased]: https://github.com/wp-pay-extensions/memberpress/compare/3.0.0...HEAD +[3.0.0]: https://github.com/wp-pay-extensions/memberpress/compare/2.3.3...3.0.0 [2.3.3]: https://github.com/wp-pay-extensions/memberpress/compare/2.3.2...2.3.3 [2.3.2]: https://github.com/wp-pay-extensions/memberpress/compare/2.3.1...2.3.2 [2.3.1]: https://github.com/wp-pay-extensions/memberpress/compare/2.3.0...2.3.1 diff --git a/composer.json b/composer.json index e55baf4..3a24f05 100644 --- a/composer.json +++ b/composer.json @@ -33,20 +33,16 @@ }, "require": { "php": ">=5.6.20", - "wp-pay/core": "^2.6" + "wp-pay/core": "^3.0" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.4", - "dealerdirect/phpcodesniffer-composer-installer": "^0.7", "php-coveralls/php-coveralls": "^2.4", - "phpcompatibility/php-compatibility": "^9.2", - "phpcompatibility/phpcompatibility-wp": "^2.0", "phpmd/phpmd": "^2.7", "phpunit/phpunit": "^5.7 || ^6.0", - "roots/wordpress": "^5.6", - "squizlabs/php_codesniffer": "^3.4", - "wp-coding-standards/wpcs": "^2.3", - "wp-phpunit/wp-phpunit": "^5.6", + "pronamic/wp-coding-standards": "^1.0", + "roots/wordpress": "^5.8", + "wp-phpunit/wp-phpunit": "^5.8", "wp-premium/memberpress-basic": "^1.3" }, "scripts": { diff --git a/package.json b/package.json index b254d40..a216121 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "memberpress", - "version": "2.3.3", + "version": "3.0.0", "description": "MemberPress driver for the WordPress payment processing library.", "repository": { "type": "git", diff --git a/phpcs.xml.dist b/phpcs.xml.dist index c0d8290..25adf5d 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,32 +1,14 @@ - - - - . - - - - - - node_modules/* tests/bootstrap.php tests/wp-config.php - vendor/* - wordpress/* - ^wp-content/* - - - - - + - - + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index bacbac7..6022e07 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -20,10 +20,6 @@ - - - - diff --git a/src/Extension.php b/src/Extension.php index 88db0ff..169d43f 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -81,8 +81,12 @@ public function setup() { \add_action( 'mepr_subscription_transition_status', array( $this, 'memberpress_subscription_transition_status' ), 10, 3 ); + // MemberPress subscription email parameters. + \add_filter( 'mepr_subscription_email_params', array( $this, 'subscription_email_params' ), 10, 2 ); + \add_filter( 'mepr_transaction_email_params', array( $this, 'transaction_email_params' ), 10, 2 ); + // Hide MemberPress columns for payments and subscriptions. - \add_filter( 'registered_post_type', array( $this, 'post_type_columns_hide' ), 15, 1 ); + \add_action( 'registered_post_type', array( $this, 'post_type_columns_hide' ), 15, 1 ); if ( \is_admin() ) { $this->admin_subscriptions = new Admin\AdminSubscriptions(); @@ -399,6 +403,69 @@ public function subscription_pre_delete( $subscription_id ) { } } + /** + * Subscription email parameters. + * + * @param array $params Email parameters. + * @param MeprSubscription $memberpress_subscription MemberPress subscription. + * @return array + */ + public function subscription_email_params( $params, MeprSubscription $memberpress_subscription ) { + $subscriptions = \get_pronamic_subscriptions_by_source( 'memberpress', $memberpress_subscription->id ); + + if ( empty( $subscriptions ) ) { + return $params; + } + + $subscription = reset( $subscriptions ); + + // Add parameters. + $next_payment_date = $subscription->get_next_payment_date(); + + return \array_merge( + $params, + array( + 'pronamic_subscription_id' => $subscription->get_id(), + 'pronamic_subscription_cancel_url' => $subscription->get_cancel_url(), + 'pronamic_subscription_renewal_url' => $subscription->get_renewal_url(), + 'pronamic_subscription_renewal_date' => null === $next_payment_date ? '' : \date_i18n( \get_option( 'date_format' ), $next_payment_date->getTimestamp() ), + ) + ); + } + + /** + * Transaction email parameters. + * + * @param array $params Parameters. + * @param MeprTransaction $transaction MemberPress transaction. + * @return array + */ + public function transaction_email_params( $params, MeprTransaction $transaction ) { + $payments = \get_pronamic_payments_by_source( 'memberpress', $transaction->id ); + + if ( null === $payments ) { + return $params; + } + + $payment = reset( $payments ); + + // Get subscription. + $periods = $payment->get_periods(); + + if ( null === $periods ) { + return $params; + } + + $period = reset( $periods ); + + $subscription = $period->get_phase()->get_subscription(); + + // Add parameters. + $memberpress_subscription = new MeprSubscription( $subscription->get_source_id() ); + + return $this->subscription_email_params( $params, $memberpress_subscription ); + } + /** * Source text. * diff --git a/src/Gateways/Gateway.php b/src/Gateways/Gateway.php index 1f3e5d0..8db0dc8 100644 --- a/src/Gateways/Gateway.php +++ b/src/Gateways/Gateway.php @@ -872,7 +872,7 @@ public function display_payment_form( $amount, $user, $product_id, $txn_id ) {
 
- +