From e85152fffa9b0a72c6ec26ffc9f381b64b85592d Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Wed, 13 Jul 2022 15:16:52 +0200 Subject: [PATCH 01/15] No longer set payment method on gateway. This was required for the input fields to render, but we revise this. --- src/Gateway.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Gateway.php b/src/Gateway.php index 4c3d1ff..6095084 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -227,12 +227,6 @@ public function payment_fields() { return; } - /* - * Let the gateway know which payment method to use so it can return the correct inputs. - * @since 1.2.1 - */ - $gateway->set_payment_method( $this->payment_method ); - $fields = $gateway->get_input_fields(); // Check if there are fields to display. From 4c8f5e103c981becda8a3a2fc54bb54c291d4c76 Mon Sep 17 00:00:00 2001 From: Gautam Garg <65900807+knit-pay@users.noreply.github.com> Date: Sat, 16 Jul 2022 18:53:04 +0530 Subject: [PATCH 02/15] code updated to work with Easy Digital Downloads v3.0.0 Update Extension.php --- src/Extension.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Extension.php b/src/Extension.php index 2c21337..8447283 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -49,6 +49,8 @@ public function __construct() { $dependencies = $this->get_dependencies(); $dependencies->add( new EasyDigitalDownloadsDependency() ); + + add_action( 'plugins_loaded', [ $this, 'setup_extension' ] ); } /** @@ -56,7 +58,7 @@ public function __construct() { * * @return void */ - public function setup() { + public function setup_extension() { add_filter( 'pronamic_payment_source_text_easydigitaldownloads', [ $this, 'source_text' ], 10, 2 ); add_filter( 'pronamic_payment_source_description_easydigitaldownloads', [ $this, 'source_description' ], 10, 2 ); From a498b8c2034f26e74bfac3674714cfbade853d7c Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Thu, 28 Jul 2022 15:03:46 +0200 Subject: [PATCH 03/15] Update Extension.php --- src/Extension.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Extension.php b/src/Extension.php index 8447283..bf6d458 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -50,15 +50,21 @@ public function __construct() { $dependencies->add( new EasyDigitalDownloadsDependency() ); - add_action( 'plugins_loaded', [ $this, 'setup_extension' ] ); + /** + * Plugins loaded. + * + * @link https://github.com/pronamic/wp-pronamic-pay-easy-digital-downloads/issues/3 + */ + add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] ); } /** - * Setup plugin integration. + * Plugins loaded. * + * @link https://github.com/pronamic/wp-pronamic-pay-easy-digital-downloads/issues/3 * @return void */ - public function setup_extension() { + public function plugins_loaded() { add_filter( 'pronamic_payment_source_text_easydigitaldownloads', [ $this, 'source_text' ], 10, 2 ); add_filter( 'pronamic_payment_source_description_easydigitaldownloads', [ $this, 'source_description' ], 10, 2 ); From db5fd19038b5e67cb8449f71001a3c9cea448f60 Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Wed, 17 Aug 2022 13:15:44 +0200 Subject: [PATCH 04/15] Update Gateway.php --- src/Gateway.php | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/Gateway.php b/src/Gateway.php index 6095084..3bc2c42 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -227,9 +227,14 @@ public function payment_fields() { return; } - $fields = $gateway->get_input_fields(); + $payment_method = $gateway->get_payment_method( $this->payment_method ); + + if ( null === $payment_method ) { + return; + } + + $fields = $payment_method->get_fields(); - // Check if there are fields to display. if ( empty( $fields ) ) { return; } @@ -238,13 +243,23 @@ public function payment_fields() { echo '', \esc_html( $this->checkout_label ), ''; foreach ( $fields as $field ) { - // Make field required. - $field['label'] .= ' *'; - $field['required'] = true; + $label = $field->get_label(); + + if ( $field->is_required() ) { + $label .= ' *'; + } + + echo '

'; + + \printf( + '', + \esc_attr( $field->get_id() ), + \esc_html( $label ) + ); + + $field->output(); - // @codingStandardsIgnoreStart - \printf( '

%s

', Util::input_fields_html( [ $field ] ) ); - // @codingStandardsIgnoreEnd + echo '

'; } echo ''; From 66cdc991d71d7d589869fecc44a588332b439063 Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Wed, 17 Aug 2022 13:18:12 +0200 Subject: [PATCH 05/15] Remove 'edd_cc_fields' HTML id attribute. --- src/Gateway.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gateway.php b/src/Gateway.php index 3bc2c42..c8e8446 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -239,7 +239,7 @@ public function payment_fields() { return; } - echo '
'; + echo '
'; echo '', \esc_html( $this->checkout_label ), ''; foreach ( $fields as $field ) { From 992803b7315b72322223cb7e514699b93a5eadc6 Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Wed, 24 Aug 2022 16:02:22 +0200 Subject: [PATCH 06/15] Remove deprecated RESERVED payment status core. https://github.com/pronamic/wp-pay-core/issues/66 --- src/Extension.php | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/src/Extension.php b/src/Extension.php index bf6d458..0186b56 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -289,48 +289,6 @@ public static function status_update( Payment $payment ) { case Core_Statuses::FAILURE: \edd_update_payment_status( $source_id, EasyDigitalDownloads::ORDER_STATUS_FAILED ); - break; - case Core_Statuses::RESERVED: - $note = [ - \sprintf( - '%s %s.', - PaymentMethods::get_name( $payment->get_payment_method() ), - \__( 'payment reserved at gateway', 'pronamic_ideal' ) - ), - ]; - - $gateway = Plugin::get_gateway( (int) $payment->get_config_id() ); - - if ( null !== $gateway && $gateway->supports( 'reservation_payments' ) ) { - $payment_edit_link = \add_query_arg( - [ - 'post' => $payment->get_id(), - 'action' => 'edit', - ], - \admin_url( 'post.php' ) - ); - - $payment_link = \sprintf( - '%2$s', - $payment_edit_link, - \sprintf( - /* translators: %s: payment id */ - \esc_html( __( 'payment #%s', 'pronamic_ideal' ) ), - $payment->get_id() - ) - ); - - $note[] = \sprintf( - /* translators: %s: payment edit link */ - __( 'Create an invoice at payment gateway for %1$s after processing the order.', 'pronamic_ideal' ), - $payment_link // WPCS: xss ok. - ); - } - - $note = \implode( ' ', $note ); - - \edd_insert_payment_note( $source_id, $note ); - break; case Core_Statuses::SUCCESS: \edd_insert_payment_note( $source_id, __( 'Payment completed.', 'pronamic_ideal' ) ); From faad7dd9619cd8313481c58f737cc7f6d48d6771 Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Wed, 24 Aug 2022 16:14:53 +0200 Subject: [PATCH 07/15] No longer use deprecated `Core_Statuses::RESERVED`. --- src/Extension.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Extension.php b/src/Extension.php index 0186b56..a865580 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -228,7 +228,6 @@ public static function redirect_url( $url, $payment ) { \edd_get_payment_key( $source_id ), \edd_get_success_page_uri() ); - case Core_Statuses::RESERVED: case Core_Statuses::OPEN: return \home_url( '/' ); } From 1f8d44df1c935c2201fb57064abdade85fec3859 Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Thu, 25 Aug 2022 12:35:28 +0200 Subject: [PATCH 08/15] Remove Gulden currency. As far as i know there are not payment providers who offer the Gulden currency. --- src/Extension.php | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/src/Extension.php b/src/Extension.php index a865580..0a6770b 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -106,8 +106,6 @@ public function plugins_loaded() { add_filter( 'edd_accepted_payment_icons', [ __CLASS__, 'accepted_payment_icons' ] ); // Currencies. - add_filter( 'edd_currencies', [ __CLASS__, 'currencies' ], 10, 1 ); - add_filter( 'edd_currency_symbol', [ __CLASS__, 'currency_symbol' ], 10, 2 ); add_filter( 'edd_nlg_currency_filter_before', [ __CLASS__, 'currency_filter_before' ], 10, 3 ); add_filter( 'edd_nlg_currency_filter_after', [ __CLASS__, 'currency_filter_after' ], 10, 3 ); @@ -313,40 +311,6 @@ public static function status_update( Payment $payment ) { } } - /** - * Filter currencies. - * - * @param array $currencies Available currencies. - * @return array - */ - public static function currencies( $currencies ) { - if ( PaymentMethods::is_active( PaymentMethods::GULDEN ) ) { - $currencies['NLG'] = sprintf( - /* translators: %s: Gulden */ - '%s (G)', - PaymentMethods::get_name( PaymentMethods::GULDEN ) - ); - } - - return $currencies; - } - - /** - * Filter currency symbol. - * - * @param string $symbol Symbol. - * @param string $currency Currency. - * - * @return string - */ - public static function currency_symbol( $symbol, $currency ) { - if ( 'NLG' === $currency ) { - $symbol = 'G'; - } - - return $symbol; - } - /** * Filter currency before. * From a0620b792ebe616c45fdb47f011669e003e95f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reu=CC=88el=20van=20der=20Steege?= Date: Mon, 29 Aug 2022 11:05:27 +0200 Subject: [PATCH 09/15] Remove Gulden payment method. --- src/Extension.php | 57 ----------------------------------------------- 1 file changed, 57 deletions(-) diff --git a/src/Extension.php b/src/Extension.php index 0a6770b..d2d12be 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -105,10 +105,6 @@ public function plugins_loaded() { // Icons. add_filter( 'edd_accepted_payment_icons', [ __CLASS__, 'accepted_payment_icons' ] ); - // Currencies. - add_filter( 'edd_nlg_currency_filter_before', [ __CLASS__, 'currency_filter_before' ], 10, 3 ); - add_filter( 'edd_nlg_currency_filter_after', [ __CLASS__, 'currency_filter_after' ], 10, 3 ); - // Statuses. add_filter( 'edd_payment_statuses', [ __CLASS__, 'edd_payment_statuses' ] ); add_filter( 'edd_payments_table_views', [ $this, 'payments_table_views' ] ); @@ -156,7 +152,6 @@ private static function get_payment_methods() { 'pronamic_pay_direct_debit_sofort' => PaymentMethods::DIRECT_DEBIT_SOFORT, 'pronamic_pay_focum' => PaymentMethods::FOCUM, 'pronamic_pay_giropay' => PaymentMethods::GIROPAY, - 'pronamic_pay_gulden' => PaymentMethods::GULDEN, 'pronamic_pay_idealqr' => PaymentMethods::IDEALQR, 'pronamic_pay_in3' => PaymentMethods::IN3, 'pronamic_pay_kbc' => PaymentMethods::KBC, @@ -311,58 +306,6 @@ public static function status_update( Payment $payment ) { } } - /** - * Filter currency before. - * - * @param string $formatted Formatted symbol and price. - * @param string $currency Currency. - * @param string $price Price. - * - * @return string - */ - public static function currency_filter_before( $formatted, $currency, $price ) { - if ( ! function_exists( 'edd_currency_symbol' ) ) { - return $formatted; - } - - $symbol = edd_currency_symbol( $currency ); - - switch ( $currency ) { - case 'NLG': - $formatted = $symbol . $price; - - break; - } - - return $formatted; - } - - /** - * Filter currency after. - * - * @param string $formatted Formatted symbol and price. - * @param string $currency Currency. - * @param string $price Price. - * - * @return string - */ - public static function currency_filter_after( $formatted, $currency, $price ) { - if ( ! function_exists( 'edd_currency_symbol' ) ) { - return $formatted; - } - - $symbol = edd_currency_symbol( $currency ); - - switch ( $currency ) { - case 'NLG': - $formatted = $price . $symbol; - - break; - } - - return $formatted; - } - /** * Source column * From 755ffd88bccee40adc7996767de60e761fe3a616 Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Mon, 29 Aug 2022 16:10:34 +0200 Subject: [PATCH 10/15] Add wp-env. --- .wp-env.json | 12 ++++++++ package.json | 1 + pronamic-pay-easy-digital-downloads.php | 41 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 .wp-env.json create mode 100644 pronamic-pay-easy-digital-downloads.php diff --git a/.wp-env.json b/.wp-env.json new file mode 100644 index 0000000..ca298ef --- /dev/null +++ b/.wp-env.json @@ -0,0 +1,12 @@ +{ + "core": null, + "plugins": [ + ".", + "../../../", + "https://downloads.wordpress.org/plugin/easy-digital-downloads.3.0.3.zip", + "https://downloads.wordpress.org/plugin/query-monitor.zip" + ], + "config": { + "PRONAMIC_PAY_DEBUG": true + } +} diff --git a/package.json b/package.json index de14dfb..068c3b1 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ }, "homepage": "http://www.wp-pay.org/extensions/easy-digital-downloads/", "devDependencies": { + "@wordpress/env": "^5.2.0", "grunt": "~1.0.4", "grunt-contrib-jshint": "^2.1.0", "grunt-phpcs": "^0.4.0", diff --git a/pronamic-pay-easy-digital-downloads.php b/pronamic-pay-easy-digital-downloads.php new file mode 100644 index 0000000..5c415bd --- /dev/null +++ b/pronamic-pay-easy-digital-downloads.php @@ -0,0 +1,41 @@ + + * @copyright 2005-2022 Pronamic + * @license GPL-3.0-or-later + * @package Pronamic\WordPress\Pay\Extensions\EasyDigitalDownloads + */ + +add_filter( + 'pronamic_pay_plugin_integrations', + function ( $integrations ) { + foreach ( $integrations as $integration ) { + if ( $integration instanceof \Pronamic\WordPress\Pay\Extensions\EasyDigitalDownloads\Extension ) { + return $integrations; + } + } + + $integrations[] = new \Pronamic\WordPress\Pay\Extensions\EasyDigitalDownloads\Extension(); + + return $integrations; + } +); From 746e736a883e103aec9478b3a48bae97c05fff0e Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Tue, 30 Aug 2022 14:54:23 +0200 Subject: [PATCH 11/15] wip wp-env --- .wp-env.json | 3 ++- package.json | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.wp-env.json b/.wp-env.json index ca298ef..82bf277 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -4,7 +4,8 @@ ".", "../../../", "https://downloads.wordpress.org/plugin/easy-digital-downloads.3.0.3.zip", - "https://downloads.wordpress.org/plugin/query-monitor.zip" + "https://downloads.wordpress.org/plugin/query-monitor.zip", + "https://downloads.wordpress.org/plugin/one-time-login.zip" ], "config": { "PRONAMIC_PAY_DEBUG": true diff --git a/package.json b/package.json index 068c3b1..5543a98 100644 --- a/package.json +++ b/package.json @@ -43,5 +43,9 @@ "grunt-phpmd": "^0.1.1", "grunt-phpunit": "^0.3.6", "load-grunt-tasks": "^5.1.0" + }, + "scripts": { + "start": "wp-env start", + "login": "wp-env run cli wp user one-time-login admin" } } From 99a61de2df28e1a43c30042a9ac348745aa141fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reu=CC=88el=20van=20der=20Steege?= Date: Thu, 1 Sep 2022 23:26:43 +0200 Subject: [PATCH 12/15] phpcbf --- pronamic-pay-easy-digital-downloads.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pronamic-pay-easy-digital-downloads.php b/pronamic-pay-easy-digital-downloads.php index 5c415bd..f8515ec 100644 --- a/pronamic-pay-easy-digital-downloads.php +++ b/pronamic-pay-easy-digital-downloads.php @@ -28,11 +28,11 @@ add_filter( 'pronamic_pay_plugin_integrations', function ( $integrations ) { - foreach ( $integrations as $integration ) { - if ( $integration instanceof \Pronamic\WordPress\Pay\Extensions\EasyDigitalDownloads\Extension ) { - return $integrations; - } - } + foreach ( $integrations as $integration ) { + if ( $integration instanceof \Pronamic\WordPress\Pay\Extensions\EasyDigitalDownloads\Extension ) { + return $integrations; + } + } $integrations[] = new \Pronamic\WordPress\Pay\Extensions\EasyDigitalDownloads\Extension(); From b061e2687920425f0925e4a2106cf8b70d181dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reu=CC=88el=20van=20der=20Steege?= Date: Mon, 26 Sep 2022 10:28:20 +0200 Subject: [PATCH 13/15] Disable Xdebug in `phpcbf` Composer command. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3ba6e70..d139fb9 100644 --- a/composer.json +++ b/composer.json @@ -60,7 +60,7 @@ }, "scripts": { "coveralls": "vendor/bin/php-coveralls -v", - "phpcbf": "vendor/bin/phpcbf", + "phpcbf": "XDEBUG_MODE=off vendor/bin/phpcbf", "phpcs": "XDEBUG_MODE=off vendor/bin/phpcs -s -v", "phplint": "find src tests -name '*.php' | xargs -n 1 -P 4 php -l", "phpmd": "vendor/bin/phpmd src,tests text phpmd.ruleset.xml --suffixes php", From 6aea7455c830e2666901abb8929926546144eb42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reu=CC=88el=20van=20der=20Steege?= Date: Mon, 26 Sep 2022 14:06:33 +0200 Subject: [PATCH 14/15] Coding standards. --- src/CompanyNameController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CompanyNameController.php b/src/CompanyNameController.php index 81809c1..e28fce7 100644 --- a/src/CompanyNameController.php +++ b/src/CompanyNameController.php @@ -199,7 +199,7 @@ public function purchase_form() { ); ?> - +
Date: Mon, 26 Sep 2022 14:08:03 +0200 Subject: [PATCH 15/15] Getting ready for version 4.2.0. --- CHANGELOG.md | 7 ++++++- package.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aad6fa0..2943fa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C ## [Unreleased][unreleased] - +## [4.2.0] - 2022-09-26 +- Fixed Easy Digital Downloads 3 compatibility. +- Updated for new payment methods and fields registration. + ## [4.1.0] - 2022-04-11 - Add company name controller. @@ -129,7 +133,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C ## 1.0.0 - 2015-01-20 - First release. -[unreleased]: https://github.com/wp-pay-extensions/easy-digital-downloads/compare/4.1.0...HEAD +[unreleased]: https://github.com/wp-pay-extensions/easy-digital-downloads/compare/4.2.0...HEAD +[4.2.0]: https://github.com/pronamic/wp-pronamic-pay-easy-digital-downloads/compare/4.1.0...4.2.0 [4.1.0]: https://github.com/pronamic/wp-pronamic-pay-easy-digital-downloads/compare/4.0.0...4.1.0 [4.0.0]: https://github.com/wp-pay-extensions/easy-digital-downloads/compare/3.0.0...4.0.0 [3.0.0]: https://github.com/wp-pay-extensions/easy-digital-downloads/compare/2.2.0...3.0.0 diff --git a/package.json b/package.json index 5543a98..cf29d21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "easy-digital-downloads", - "version": "4.1.0", + "version": "4.2.0", "description": "Easy Digital Downloads driver for the WordPress payment processing library.", "repository": { "type": "git",