From acceb2455b4fd889d4a4817597b30a5c066e19c9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 18 Apr 2024 09:40:49 +0000 Subject: [PATCH 1/4] Update version and add changelog entries for release 7.5.1 --- changelog.txt | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- readme.txt | 5 ++++- woocommerce-payments.php | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/changelog.txt b/changelog.txt index c6f3bae6a64..1985a69340c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,7 @@ *** WooPayments Changelog *** += 7.5.1 - 2024-04-18 = + = 7.5.0 - 2024-04-17 = * Add - Add a parent wrapper component for Payment Activity widget. This will be visible on the Payments Overview page * Add - Add a task on WooCommerce Home page to remind accounts operating in sandbox mode to set up live payments. diff --git a/package-lock.json b/package-lock.json index afb8b6a46ab..ed9bbc6f32b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "woocommerce-payments", - "version": "7.5.0", + "version": "7.5.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "woocommerce-payments", - "version": "7.5.0", + "version": "7.5.1", "hasInstallScript": true, "license": "GPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index af425be8173..9a9b04c3508 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "woocommerce-payments", - "version": "7.5.0", + "version": "7.5.1", "main": "webpack.config.js", "author": "Automattic", "license": "GPL-3.0-or-later", diff --git a/readme.txt b/readme.txt index 162f79dfa88..df35ec52a5e 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: woocommerce payments, apple pay, credit card, google pay, payment, payment Requires at least: 6.0 Tested up to: 6.4 Requires PHP: 7.3 -Stable tag: 7.5.0 +Stable tag: 7.5.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -94,6 +94,9 @@ Please note that our support for the checkout block is still experimental and th == Changelog == += 7.5.1 - 2024-04-18 = + + = 7.5.0 - 2024-04-17 = * Add - Add a parent wrapper component for Payment Activity widget. This will be visible on the Payments Overview page * Add - Add a task on WooCommerce Home page to remind accounts operating in sandbox mode to set up live payments. diff --git a/woocommerce-payments.php b/woocommerce-payments.php index d8f723d006d..d99091bde94 100644 --- a/woocommerce-payments.php +++ b/woocommerce-payments.php @@ -11,7 +11,7 @@ * WC tested up to: 8.7.0 * Requires at least: 6.0 * Requires PHP: 7.3 - * Version: 7.5.0 + * Version: 7.5.1 * Requires Plugins: woocommerce * * @package WooCommerce\Payments From 0e260923ee559a588b1f9b9625245e2f74196fb5 Mon Sep 17 00:00:00 2001 From: Timur Karimov Date: Thu, 18 Apr 2024 12:06:57 +0200 Subject: [PATCH 2/4] Avoid updating billing details for legacy card objects (#8664) Co-authored-by: Timur Karimov --- changelog/2024-04-18-09-06-44-606607 | 4 + includes/class-wc-payment-gateway-wcpay.php | 5 +- .../test-class-wc-payment-gateway-wcpay.php | 79 +++++++++++++++++++ 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 changelog/2024-04-18-09-06-44-606607 diff --git a/changelog/2024-04-18-09-06-44-606607 b/changelog/2024-04-18-09-06-44-606607 new file mode 100644 index 00000000000..89a041cc4eb --- /dev/null +++ b/changelog/2024-04-18-09-06-44-606607 @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +Avoid updating billing details for legacy card objects. diff --git a/includes/class-wc-payment-gateway-wcpay.php b/includes/class-wc-payment-gateway-wcpay.php index 7ca12d90326..0c728fb0ff9 100644 --- a/includes/class-wc-payment-gateway-wcpay.php +++ b/includes/class-wc-payment-gateway-wcpay.php @@ -1514,7 +1514,10 @@ public function process_payment_for_order( $cart, $payment_information, $schedul if ( $payment_information->is_using_saved_payment_method() ) { $billing_details = WC_Payments_Utils::get_billing_details_from_order( $order ); - if ( ! empty( $billing_details ) ) { + $is_legacy_card_object = strpos( $payment_information->get_payment_method() ?? '', 'card_' ) === 0; + + // Not updating billing details for legacy card objects because they have a different structure and are no longer supported. + if ( ! empty( $billing_details ) && ! $is_legacy_card_object ) { $request->set_payment_method_update_data( [ 'billing_details' => $billing_details ] ); } } diff --git a/tests/unit/test-class-wc-payment-gateway-wcpay.php b/tests/unit/test-class-wc-payment-gateway-wcpay.php index b1dc008ac7d..1218eeef0a3 100644 --- a/tests/unit/test-class-wc-payment-gateway-wcpay.php +++ b/tests/unit/test-class-wc-payment-gateway-wcpay.php @@ -257,6 +257,18 @@ public function set_up() { ->method( 'get_payment_metadata' ) ->willReturn( [] ); wcpay_get_test_container()->replace( OrderService::class, $mock_order_service ); + $checkout_fields = [ + 'billing' => [ + 'billing_company' => '', + 'billing_country' => '', + 'billing_address_1' => '', + 'billing_address_2' => '', + 'billing_city' => '', + 'billing_state' => '', + 'billing_phone' => '', + ], + ]; + WC()->checkout()->checkout_fields = $checkout_fields; } /** @@ -292,6 +304,7 @@ public function tear_down() { } wcpay_get_test_container()->reset_all_replacements(); + WC()->checkout()->checkout_fields = null; } public function test_process_redirect_payment_intent_processing() { @@ -2429,6 +2442,72 @@ public function test_process_payment_for_order_not_from_request() { $this->card_gateway->process_payment_for_order( WC()->cart, $pi ); } + public function test_no_billing_details_update_for_legacy_card_object() { + $legacy_card = 'card_mock'; + + // There is no payment method data within the request. This is the case e.g. for the automatic subscription renewals. + $_POST['payment_method'] = ''; + + $token = WC_Helper_Token::create_token( $legacy_card ); + + $order = WC_Helper_Order::create_order(); + $order->set_currency( 'USD' ); + $order->set_total( 100 ); + $order->add_payment_token( $token ); + $order->save(); + + $pi = new Payment_Information( $legacy_card, $order, null, $token, null, null, null, '', 'card' ); + $payment_intent = WC_Helper_Intention::create_intention( + [ + 'status' => 'success', + ] + ); + + $request = $this->mock_wcpay_request( Create_And_Confirm_Intention::class ); + + $request->expects( $this->once() ) + ->method( 'format_response' ) + ->will( $this->returnValue( $payment_intent ) ); + + $request->expects( $this->never() ) + ->method( 'set_payment_method_update_data' ); + + $this->card_gateway->process_payment_for_order( WC()->cart, $pi ); + } + + public function test_billing_details_update_if_not_empty() { + // There is no payment method data within the request. This is the case e.g. for the automatic subscription renewals. + $_POST['payment_method'] = ''; + + $token = WC_Helper_Token::create_token( 'pm_mock' ); + + $expected_upe_payment_method = 'card'; + $order = WC_Helper_Order::create_order(); + $order->set_currency( 'USD' ); + $order->set_total( 100 ); + $order->add_payment_token( $token ); + $order->save(); + + $pi = new Payment_Information( 'pm_mock', $order, null, $token, null, null, null, '', 'card' ); + + $payment_intent = WC_Helper_Intention::create_intention( + [ + 'status' => 'success', + ] + ); + + $request = $this->mock_wcpay_request( Create_And_Confirm_Intention::class ); + + $request->expects( $this->once() ) + ->method( 'format_response' ) + ->will( $this->returnValue( $payment_intent ) ); + + $request->expects( $this->once() ) + ->method( 'set_payment_method_update_data' ); + + $this->card_gateway->process_payment_for_order( WC()->cart, $pi ); + } + public function test_process_payment_for_order_rejects_with_cached_minimum_amount() { set_transient( 'wcpay_minimum_amount_usd', '50', DAY_IN_SECONDS ); From 144e06add93a41e41d8be159d85435dace4efac3 Mon Sep 17 00:00:00 2001 From: Francesco Date: Thu, 18 Apr 2024 12:32:01 +0200 Subject: [PATCH 3/4] fix: BNPL announcement link (#8663) --- changelog/fix-bnpl-dialog-link | 4 ++++ client/bnpl-announcement/index.js | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 changelog/fix-bnpl-dialog-link diff --git a/changelog/fix-bnpl-dialog-link b/changelog/fix-bnpl-dialog-link new file mode 100644 index 00000000000..412310cb58f --- /dev/null +++ b/changelog/fix-bnpl-dialog-link @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +fix: BNPL announcement link. diff --git a/client/bnpl-announcement/index.js b/client/bnpl-announcement/index.js index 7a64c93d005..11d22c30051 100644 --- a/client/bnpl-announcement/index.js +++ b/client/bnpl-announcement/index.js @@ -14,6 +14,7 @@ import './style.scss'; import ConfirmationModal from 'wcpay/components/confirmation-modal'; import AfterpayBanner from 'assets/images/bnpl_announcement_afterpay.png?asset'; import ClearpayBanner from 'assets/images/bnpl_announcement_clearpay.png?asset'; +import { getAdminUrl } from 'wcpay/utils'; const BannerIcon = window.wcpayBnplAnnouncement?.accountCountry === 'GB' @@ -49,6 +50,11 @@ const Dialog = () => {