Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release branch for 6.6.1 #7506

Merged
merged 9 commits into from
Oct 19, 2023
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
*** WooPayments Changelog ***

= 6.6.1 - 2023-10-19 =
* Fix - Fix Documents page loading on WooCommerce 8.2.0.
* Fix - Stripe Link eligibility at checkout

= 6.6.0 - 2023-10-11 =
* Add - Add a notice on the Settings page to request JCB capability for Japanese customers.
* Add - Add current user data to the onboarding init request payload. This data is used for fraud prevention.
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/class-wc-payments-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public function add_payments_menu() {
public function register_payments_scripts() {
// TODO: Add check to see if user can manage_woocommerce and exit early if they cannot.

WC_Payments::register_script_with_dependencies( 'WCPAY_DASH_APP', 'dist/index' );
WC_Payments::register_script_with_dependencies( 'WCPAY_DASH_APP', 'dist/index', [ 'wp-api-request' ] );

wp_set_script_translations( 'WCPAY_DASH_APP', 'woocommerce-payments' );

Expand Down
22 changes: 13 additions & 9 deletions includes/class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -1560,23 +1560,27 @@ public function get_payment_method_types( $payment_information ) : array {
public function get_payment_methods_from_gateway_id( $gateway_id, $order_id = null ) {
$split_upe_gateway_prefix = self::GATEWAY_ID . '_';
// If $gateway_id begins with `woocommerce_payments_` payment method is a split UPE LPM.
// Otherwise $gateway_id must be `woocommerce_payments`.
// Otherwise, $gateway_id must be `woocommerce_payments`.
if ( substr( $gateway_id, 0, strlen( $split_upe_gateway_prefix ) ) === $split_upe_gateway_prefix ) {
$payment_methods = [ str_replace( $split_upe_gateway_prefix, '', $gateway_id ) ];
} elseif ( WC_Payments_Features::is_upe_deferred_intent_enabled() ) {
return [ str_replace( $split_upe_gateway_prefix, '', $gateway_id ) ];
}

$eligible_payment_methods = WC_Payments::get_gateway()->get_payment_method_ids_enabled_at_checkout( $order_id, true );

if ( WC_Payments_Features::is_upe_deferred_intent_enabled() ) {
// If split or deferred intent UPE is enabled and $gateway_id is `woocommerce_payments`, this must be the CC gateway.
// We only need to return single `card` payment method, adding `link` since deferred intent UPE gateway is compatible with Link.
$payment_methods = [ Payment_Method::CARD ];
if ( in_array( Payment_Method::LINK, $this->get_upe_enabled_payment_method_ids(), true ) ) {
if ( in_array( Payment_Method::LINK, $eligible_payment_methods, true ) ) {
$payment_methods[] = Payment_Method::LINK;
}
} else {
// $gateway_id must be `woocommerce_payments` and gateway is either legacy UPE or legacy card.
// Find the relevant gateway and return all available payment methods.
$payment_methods = WC_Payments::get_gateway()->get_payment_method_ids_enabled_at_checkout( $order_id, true );

return $payment_methods;
}

return $payment_methods;
// $gateway_id must be `woocommerce_payments` and gateway is either legacy UPE or legacy card.
// Find the relevant gateway and return all available payment methods.
return $eligible_payment_methods;
}

/**
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": "6.6.0",
"version": "6.6.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: payment gateway, payment, apple pay, credit card, google pay, woocommerce
Requires at least: 6.0
Tested up to: 6.2
Requires PHP: 7.3
Stable tag: 6.6.0
Stable tag: 6.6.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 ==

= 6.6.1 - 2023-10-19 =
* Fix - Fix Documents page loading on WooCommerce 8.2.0.
* Fix - Stripe Link eligibility at checkout


= 6.6.0 - 2023-10-11 =
* Add - Add a notice on the Settings page to request JCB capability for Japanese customers.
* Add - Add current user data to the onboarding init request payload. This data is used for fraud prevention.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2348,9 +2348,8 @@ public function test_get_payment_methods_from_gateway_id() {
$this->mock_localization_service,
]
)
->setMethods(
->onlyMethods(
[
'get_upe_enabled_payment_method_ids',
'get_payment_method_ids_enabled_at_checkout',
]
)
Expand All @@ -2359,40 +2358,25 @@ public function test_get_payment_methods_from_gateway_id() {
$gateway = WC_Payments::get_gateway();
WC_Payments::set_gateway( $mock_upe_gateway );

$mock_upe_gateway->expects( $this->any() )
->method( 'get_upe_enabled_payment_method_ids' )
->will(
$this->returnValue( [ Payment_Method::CARD, Payment_Method::LINK ] )
);

$payment_methods = $mock_upe_gateway->get_payment_methods_from_gateway_id( UPE_Split_Payment_Gateway::GATEWAY_ID );

$this->assertSame( [ Payment_Method::CARD, Payment_Method::LINK ], $payment_methods );

$payment_methods = $mock_upe_gateway->get_payment_methods_from_gateway_id( UPE_Split_Payment_Gateway::GATEWAY_ID . '_' . Payment_Method::BANCONTACT );

$this->assertSame( [ Payment_Method::BANCONTACT ], $payment_methods );

update_option( '_wcpay_feature_upe_deferred_intent', '1' );

$mock_upe_gateway->method( 'get_payment_method_ids_enabled_at_checkout' )
->will(
$this->onConsecutiveCalls(
[ Payment_Method::CARD, Payment_Method::LINK ],
[ Payment_Method::CARD, Payment_Method::BANCONTACT ],
[ Payment_Method::CARD ]
)
);
$payment_methods = $mock_upe_gateway->get_payment_methods_from_gateway_id( UPE_Split_Payment_Gateway::GATEWAY_ID );

$this->assertSame( [ Payment_Method::CARD, Payment_Method::LINK ], $payment_methods );

update_option( '_wcpay_feature_upe_split', '0' );
update_option( '_wcpay_feature_upe_deferred_intent', '0' );

$mock_upe_gateway->expects( $this->any() )
->method( 'get_payment_method_ids_enabled_at_checkout' )
->will(
$this->returnValueMap(
[
[ null, true, [ Payment_Method::CARD, Payment_Method::BANCONTACT ] ],
[ $order->get_id(), true, [ Payment_Method::CARD ] ],
]
)
);

$payment_methods = $mock_upe_gateway->get_payment_methods_from_gateway_id( UPE_Split_Payment_Gateway::GATEWAY_ID );

$this->assertSame( [ Payment_Method::CARD, Payment_Method::BANCONTACT ], $payment_methods );
Expand Down
2 changes: 1 addition & 1 deletion woocommerce-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* WC tested up to: 7.8.0
* Requires at least: 6.0
* Requires PHP: 7.3
* Version: 6.6.0
* Version: 6.6.1
*
* @package WooCommerce\Payments
*/
Expand Down