Skip to content

Commit

Permalink
Merge release/7.5.1 into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
elazzabi committed Apr 18, 2024
2 parents 1784d15 + 5e9f626 commit 6e2b7cd
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 6 deletions.
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
*** WooPayments Changelog ***

= 7.5.1 - 2024-04-18 =
* Fix - Avoid updating billing details for legacy card objects.
* Fix - fix: BNPL announcement link.

= 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.
Expand Down
6 changes: 6 additions & 0 deletions client/bnpl-announcement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -49,6 +50,11 @@ const Dialog = () => {
</ExternalLink>
<Button
variant="primary"
href={ `${ getAdminUrl( {
page: 'wc-settings',
tab: 'checkout',
section: 'woocommerce_payments',
} ) }#payment-methods` }
onClick={ () => {
recordEvent(
'wcpay_bnpl_april15_feature_announcement_enable_click'
Expand Down
5 changes: 4 additions & 1 deletion includes/class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] );
}
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -94,6 +94,11 @@ Please note that our support for the checkout block is still experimental and th

== Changelog ==

= 7.5.1 - 2024-04-18 =
* Fix - Avoid updating billing details for legacy card objects.
* Fix - fix: BNPL announcement link.


= 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.
Expand Down
79 changes: 79 additions & 0 deletions tests/unit/test-class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion woocommerce-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6e2b7cd

Please sign in to comment.