From 42bde5d06b067dae2b60865ce9a9a89a9bd568bf Mon Sep 17 00:00:00 2001
From: Taha Paksu <3295+tpaksu@users.noreply.github.com>
Date: Wed, 3 Apr 2024 18:43:39 +0300
Subject: [PATCH 1/6] Change IP country fraud rule after selling country
settings change on WC settings (#8524)
---
...pdate-ip-ruleset-after-core-country-change | 4 ++
includes/class-wc-payment-gateway-wcpay.php | 44 ++++++++++++++
.../class-fraud-risk-tools.php | 60 +++++++++++++------
.../test-class-fraud-risk-tools.php | 30 ++++++++--
4 files changed, 114 insertions(+), 24 deletions(-)
create mode 100644 changelog/fix-8134-update-ip-ruleset-after-core-country-change
diff --git a/changelog/fix-8134-update-ip-ruleset-after-core-country-change b/changelog/fix-8134-update-ip-ruleset-after-core-country-change
new file mode 100644
index 00000000000..daf2f9b4590
--- /dev/null
+++ b/changelog/fix-8134-update-ip-ruleset-after-core-country-change
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Change IP country rule after country settings are changed in WC settings page
diff --git a/includes/class-wc-payment-gateway-wcpay.php b/includes/class-wc-payment-gateway-wcpay.php
index fd8e55282d8..ce9fb5063b0 100644
--- a/includes/class-wc-payment-gateway-wcpay.php
+++ b/includes/class-wc-payment-gateway-wcpay.php
@@ -531,6 +531,8 @@ public function init_hooks() {
add_action( 'woocommerce_update_order', [ $this, 'schedule_order_tracking' ], 10, 2 );
add_filter( 'rest_request_before_callbacks', [ $this, 'remove_all_actions_on_preflight_check' ], 10, 3 );
+
+ add_action( 'woocommerce_settings_save_general', [ $this, 'update_fraud_rules_based_on_general_options' ], 20 );
}
$this->maybe_init_subscriptions_hooks();
@@ -2976,6 +2978,48 @@ protected function maybe_refresh_fraud_protection_settings() {
}
}
+ /**
+ * Updates the fraud rules depending on some settings when those settings have changed.
+ *
+ * @return void This is a readonly action.
+ */
+ public function update_fraud_rules_based_on_general_options() {
+ // If the protection level is not "advanced", no need to run this, because it won't contain the IP country filter.
+ if ( 'advanced' !== $this->get_current_protection_level() ) {
+ return;
+ }
+
+ // If the ruleset can't be parsed, skip updating.
+ $ruleset = $this->get_advanced_fraud_protection_settings();
+ if (
+ 'error' === $ruleset
+ || ! is_array( $ruleset )
+ || ! Fraud_Risk_Tools::is_valid_ruleset_array( $ruleset )
+ ) {
+ return;
+ }
+
+ $needs_update = false;
+ foreach ( $ruleset as &$rule_array ) {
+ if ( isset( $rule_array['key'] ) && Fraud_Risk_Tools::RULE_INTERNATIONAL_IP_ADDRESS === $rule_array['key'] ) {
+ $new_rule_array = Fraud_Risk_Tools::get_international_ip_address_rule()->to_array();
+ if ( isset( $rule_array['check'] )
+ && isset( $new_rule_array['check'] )
+ && wp_json_encode( $rule_array['check'] ) !== wp_json_encode( $new_rule_array['check'] )
+ ) {
+ $rule_array = $new_rule_array;
+ $needs_update = true;
+ }
+ }
+ }
+
+ // Update the possibly changed values on the server, and the transient.
+ if ( $needs_update ) {
+ $this->payments_api_client->save_fraud_ruleset( $ruleset );
+ set_transient( 'wcpay_fraud_protection_settings', $ruleset, DAY_IN_SECONDS );
+ }
+ }
+
/**
* The get_icon() method from the WC_Payment_Gateway class wraps the icon URL into a prepared HTML element, but there are situations when this
* element needs to be rendered differently on the UI (e.g. additional styles or `display` property).
diff --git a/includes/fraud-prevention/class-fraud-risk-tools.php b/includes/fraud-prevention/class-fraud-risk-tools.php
index 27cf2dc8154..d79c2774959 100644
--- a/includes/fraud-prevention/class-fraud-risk-tools.php
+++ b/includes/fraud-prevention/class-fraud-risk-tools.php
@@ -13,7 +13,6 @@
use WC_Payments;
use WC_Payments_Account;
use WC_Payments_Features;
-use WC_Payments_API_Client;
use WCPay\Fraud_Prevention\Models\Check;
use WCPay\Fraud_Prevention\Models\Rule;
use WCPay\Constants\Currency_Code;
@@ -126,6 +125,39 @@ public static function get_basic_protection_settings() {
return self::get_ruleset_array( $rules );
}
+ /**
+ * Validates the array to see if it's a valid ruleset.
+ *
+ * @param array $array The array to validate.
+ *
+ * @return bool Whether if the given array is a ruleset, or not.
+ */
+ public static function is_valid_ruleset_array( array $array ) {
+ foreach ( $array as $rule ) {
+ if ( ! Rule::validate_array( $rule ) ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Returns the international IP address rule.
+ *
+ * @return Rule International IP address rule object.
+ */
+ public static function get_international_ip_address_rule() {
+ return new Rule(
+ self::RULE_INTERNATIONAL_IP_ADDRESS,
+ WC_Payments_Features::is_frt_review_feature_active() ? Rule::FRAUD_OUTCOME_REVIEW : Rule::FRAUD_OUTCOME_BLOCK,
+ Check::check(
+ 'ip_country',
+ self::get_selling_locations_type_operator(),
+ self::get_selling_locations_string()
+ )
+ );
+ }
+
/**
* Returns the standard protection rules.
*
@@ -134,19 +166,11 @@ public static function get_basic_protection_settings() {
public static function get_standard_protection_settings() {
$rules = [
// REVIEW An order originates from an IP address outside your country.
- new Rule(
- self::RULE_INTERNATIONAL_IP_ADDRESS,
- Rule::FRAUD_OUTCOME_REVIEW,
- Check::check(
- 'ip_country',
- self::get_selling_locations_type_operator(),
- self::get_selling_locations_string()
- )
- ),
+ self::get_international_ip_address_rule(),
// REVIEW An order exceeds $1,000.00 or 10 items.
new Rule(
self::RULE_ORDER_ITEMS_THRESHOLD,
- Rule::FRAUD_OUTCOME_REVIEW,
+ WC_Payments_Features::is_frt_review_feature_active() ? Rule::FRAUD_OUTCOME_REVIEW : Rule::FRAUD_OUTCOME_BLOCK,
Check::check(
'item_count',
Check::OPERATOR_GT,
@@ -156,7 +180,7 @@ public static function get_standard_protection_settings() {
// REVIEW An order exceeds $1,000.00 or 10 items.
new Rule(
self::RULE_PURCHASE_PRICE_THRESHOLD,
- Rule::FRAUD_OUTCOME_REVIEW,
+ WC_Payments_Features::is_frt_review_feature_active() ? Rule::FRAUD_OUTCOME_REVIEW : Rule::FRAUD_OUTCOME_BLOCK,
Check::check(
'order_total',
Check::OPERATOR_GT,
@@ -166,7 +190,7 @@ public static function get_standard_protection_settings() {
// REVIEW An order is originated from a different country than the shipping country.
new Rule(
self::RULE_IP_ADDRESS_MISMATCH,
- Rule::FRAUD_OUTCOME_REVIEW,
+ WC_Payments_Features::is_frt_review_feature_active() ? Rule::FRAUD_OUTCOME_REVIEW : Rule::FRAUD_OUTCOME_BLOCK,
Check::check(
'ip_billing_country_same',
Check::OPERATOR_EQUALS,
@@ -208,7 +232,7 @@ public static function get_high_protection_settings() {
// REVIEW An order has less than 2 items or more than 10 items.
new Rule(
self::RULE_ORDER_ITEMS_THRESHOLD,
- Rule::FRAUD_OUTCOME_REVIEW,
+ WC_Payments_Features::is_frt_review_feature_active() ? Rule::FRAUD_OUTCOME_REVIEW : Rule::FRAUD_OUTCOME_BLOCK,
Check::list(
Check::LIST_OPERATOR_OR,
[
@@ -220,7 +244,7 @@ public static function get_high_protection_settings() {
// REVIEW The shipping and billing address don't match.
new Rule(
self::RULE_ADDRESS_MISMATCH,
- Rule::FRAUD_OUTCOME_REVIEW,
+ WC_Payments_Features::is_frt_review_feature_active() ? Rule::FRAUD_OUTCOME_REVIEW : Rule::FRAUD_OUTCOME_BLOCK,
Check::check(
'billing_shipping_address_same',
Check::OPERATOR_EQUALS,
@@ -230,7 +254,7 @@ public static function get_high_protection_settings() {
// REVIEW An order is originated from a different country than the shipping country.
new Rule(
self::RULE_IP_ADDRESS_MISMATCH,
- Rule::FRAUD_OUTCOME_REVIEW,
+ WC_Payments_Features::is_frt_review_feature_active() ? Rule::FRAUD_OUTCOME_REVIEW : Rule::FRAUD_OUTCOME_BLOCK,
Check::check(
'ip_billing_country_same',
Check::OPERATOR_EQUALS,
@@ -310,9 +334,9 @@ private static function get_selling_locations_string() {
$selling_locations_type = get_option( 'woocommerce_allowed_countries', 'all' );
switch ( $selling_locations_type ) {
case 'specific':
- return implode( '|', get_option( 'woocommerce_specific_allowed_countries', [] ) );
+ return strtolower( implode( '|', get_option( 'woocommerce_specific_allowed_countries', [] ) ) );
case 'all_except':
- return implode( '|', get_option( 'woocommerce_all_except_countries', [] ) );
+ return strtolower( implode( '|', get_option( 'woocommerce_all_except_countries', [] ) ) );
case 'all':
return '';
default:
diff --git a/tests/unit/fraud-prevention/test-class-fraud-risk-tools.php b/tests/unit/fraud-prevention/test-class-fraud-risk-tools.php
index 249e56badd2..26bfa8108e1 100644
--- a/tests/unit/fraud-prevention/test-class-fraud-risk-tools.php
+++ b/tests/unit/fraud-prevention/test-class-fraud-risk-tools.php
@@ -7,6 +7,7 @@
use WCPay\Constants\Country_Code;
use WCPay\Fraud_Prevention\Fraud_Risk_Tools;
+use WCPay\Fraud_Prevention\Models\Rule;
/**
* Fraud_Prevention_Service_Test unit tests.
@@ -90,7 +91,7 @@ class Fraud_Risk_Tools_Test extends WCPAY_UnitTestCase {
'check' => [
'key' => 'ip_country',
'operator' => 'not_in',
- 'value' => 'US|CA',
+ 'value' => 'us|ca',
],
],
[
@@ -134,7 +135,7 @@ class Fraud_Risk_Tools_Test extends WCPAY_UnitTestCase {
'check' => [
'key' => 'ip_country',
'operator' => 'in',
- 'value' => 'US|CA',
+ 'value' => 'us|ca',
],
],
[
@@ -301,7 +302,8 @@ public function test_registers_action_properly() {
public function test_it_gets_basic_protection_settings() {
update_option( 'woocommerce_allowed_countries', 'all' );
- $settings = $this->fraud_risk_tools->get_basic_protection_settings();
+ $this->basic_protection_level = $this->fix_outcomes( $this->basic_protection_level );
+ $settings = $this->fraud_risk_tools->get_basic_protection_settings();
$this->assertSame( $this->basic_protection_level, $settings );
}
@@ -309,7 +311,8 @@ public function test_it_gets_basic_protection_settings() {
public function test_it_gets_standard_protection_settings() {
update_option( 'woocommerce_allowed_countries', 'all' );
- $settings = $this->fraud_risk_tools->get_standard_protection_settings();
+ $this->standard_protection_level = $this->fix_outcomes( $this->standard_protection_level );
+ $settings = $this->fraud_risk_tools->get_standard_protection_settings();
$this->assertSame( $this->standard_protection_level, $settings );
}
@@ -317,7 +320,8 @@ public function test_it_gets_standard_protection_settings() {
public function test_it_gets_high_protection_settings() {
update_option( 'woocommerce_allowed_countries', 'all' );
- $settings = $this->fraud_risk_tools->get_high_protection_settings();
+ $this->high_protection_level = $this->fix_outcomes( $this->high_protection_level );
+ $settings = $this->fraud_risk_tools->get_high_protection_settings();
$this->assertSame( $this->high_protection_level, $settings );
}
@@ -325,7 +329,8 @@ public function test_it_gets_high_protection_settings() {
public function test_it_gets_high_protection_empty_allowed_countries_settings() {
update_option( 'woocommerce_allowed_countries', '' );
- $settings = $this->fraud_risk_tools->get_high_protection_settings();
+ $this->high_protection_level = $this->fix_outcomes( $this->high_protection_level );
+ $settings = $this->fraud_risk_tools->get_high_protection_settings();
$this->assertSame( $this->high_protection_level, $settings );
}
@@ -334,6 +339,7 @@ public function test_it_gets_the_correct_for_specific_allowed_selling_locations_
update_option( 'woocommerce_allowed_countries', 'specific' );
update_option( 'woocommerce_specific_allowed_countries', [ Country_Code::UNITED_STATES, Country_Code::CANADA ] );
+ $this->standard_protection_level_with_specific_selling_locations = $this->fix_outcomes( $this->standard_protection_level_with_specific_selling_locations );
$settings = $this->fraud_risk_tools->get_standard_protection_settings();
$this->assertSame( $this->standard_protection_level_with_specific_selling_locations, $settings );
@@ -343,6 +349,7 @@ public function test_it_gets_the_correct_for_all_except_selling_locations_type()
update_option( 'woocommerce_allowed_countries', 'all_except' );
update_option( 'woocommerce_all_except_countries', [ Country_Code::UNITED_STATES, Country_Code::CANADA ] );
+ $this->standard_protection_level_with_all_except_selling_locations = $this->fix_outcomes( $this->standard_protection_level_with_all_except_selling_locations );
$settings = $this->fraud_risk_tools->get_standard_protection_settings();
$this->assertSame( $this->standard_protection_level_with_all_except_selling_locations, $settings );
@@ -354,6 +361,7 @@ public function test_it_gets_the_correct_for_all_except_selling_locations_type()
public function test_it_get_matching_protection_level( $ruleset, $expected ) {
update_option( 'woocommerce_allowed_countries', 'all' );
+ $ruleset = $this->fix_outcomes( $ruleset );
$protection_level = $this->fraud_risk_tools->get_matching_protection_level( $ruleset );
$this->assertSame( $expected, $protection_level );
@@ -368,6 +376,16 @@ public function get_matching_protection_level_provider() {
];
}
+ private function fix_outcomes( $ruleset ) {
+ $review_feature_enabled = WC_Payments_Features::is_frt_review_feature_active();
+ foreach ( $ruleset as &$rule ) {
+ if ( Rule::FRAUD_OUTCOME_REVIEW === $rule['outcome'] && ! $review_feature_enabled ) {
+ $rule['outcome'] = Rule::FRAUD_OUTCOME_BLOCK;
+ }
+ }
+ return $ruleset;
+ }
+
/**
* @param bool $is_admin
*/
From a221016cbac400e40f8e80303cfe0d04d38e7724 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Krist=C3=B3fer=20Reykjal=C3=ADn?=
<13835680+reykjalin@users.noreply.github.com>
Date: Wed, 3 Apr 2024 17:11:03 +0000
Subject: [PATCH 2/6] Fix Stripe Billing checkout with different currencies
(#8462)
---
changelog/2024-03-30-01-19-36-005298 | 4 ++
.../stripe-billing-toggle.tsx | 1 +
includes/class-wc-payments.php | 1 +
...ss-cannot-combine-currencies-exception.php | 46 +++++++++++++++++++
...class-wc-payments-subscription-service.php | 10 ++++
.../class-wc-payments-api-client.php | 22 +++++++++
6 files changed, 84 insertions(+)
create mode 100644 changelog/2024-03-30-01-19-36-005298
create mode 100644 includes/exceptions/class-cannot-combine-currencies-exception.php
diff --git a/changelog/2024-03-30-01-19-36-005298 b/changelog/2024-03-30-01-19-36-005298
new file mode 100644
index 00000000000..bd24b302dff
--- /dev/null
+++ b/changelog/2024-03-30-01-19-36-005298
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Add an instructive error message when customer tries to use 2 different currencies for Stripe Billing subscriptions.
diff --git a/client/settings/advanced-settings/stripe-billing-toggle.tsx b/client/settings/advanced-settings/stripe-billing-toggle.tsx
index a340fabbc88..40bfda4f7f0 100644
--- a/client/settings/advanced-settings/stripe-billing-toggle.tsx
+++ b/client/settings/advanced-settings/stripe-billing-toggle.tsx
@@ -60,6 +60,7 @@ const StripeBillingToggle: React.FC< Props > = ( { onChange } ) => {
),
},
} ) }
+ data-testid={ 'stripe-billing-toggle' }
/>
);
};
diff --git a/includes/class-wc-payments.php b/includes/class-wc-payments.php
index 3d0c073fc54..81d04fea858 100644
--- a/includes/class-wc-payments.php
+++ b/includes/class-wc-payments.php
@@ -409,6 +409,7 @@ public static function init() {
include_once __DIR__ . '/exceptions/class-add-payment-method-exception.php';
include_once __DIR__ . '/exceptions/class-amount-too-large-exception.php';
include_once __DIR__ . '/exceptions/class-amount-too-small-exception.php';
+ include_once __DIR__ . '/exceptions/class-cannot-combine-currencies-exception.php';
include_once __DIR__ . '/exceptions/class-intent-authentication-exception.php';
include_once __DIR__ . '/exceptions/class-invalid-payment-method-exception.php';
include_once __DIR__ . '/exceptions/class-process-payment-exception.php';
diff --git a/includes/exceptions/class-cannot-combine-currencies-exception.php b/includes/exceptions/class-cannot-combine-currencies-exception.php
new file mode 100644
index 00000000000..84fcc12797f
--- /dev/null
+++ b/includes/exceptions/class-cannot-combine-currencies-exception.php
@@ -0,0 +1,46 @@
+currency = $currency;
+
+ parent::__construct( $message, 'cannot_combine_currencies', $http_code, null, null, $code, $previous );
+ }
+
+ /**
+ * Returns the currency of the minumum required amount.
+ *
+ * @return string
+ */
+ public function get_currency() {
+ return $this->currency;
+ }
+}
diff --git a/includes/subscriptions/class-wc-payments-subscription-service.php b/includes/subscriptions/class-wc-payments-subscription-service.php
index 79133ca678e..bba9ebc6064 100644
--- a/includes/subscriptions/class-wc-payments-subscription-service.php
+++ b/includes/subscriptions/class-wc-payments-subscription-service.php
@@ -7,6 +7,7 @@
use WCPay\Exceptions\API_Exception;
use WCPay\Exceptions\Amount_Too_Small_Exception;
+use WCPay\Exceptions\Cannot_Combine_Currencies_Exception;
use WCPay\Logger;
/**
@@ -417,6 +418,15 @@ public function create_subscription( WC_Subscription $subscription ) {
''
)
);
+ } elseif ( $e instanceof Cannot_Combine_Currencies_Exception ) {
+ throw new Exception(
+ sprintf(
+ // Translators: %1$s and %2$s are both currency codes, e.g. `USD` or `EUR`.
+ __( 'The subscription couldn\'t be created because it uses a different currency (%1$s) from your existing subscriptions (%2$s). Please ensure all subscriptions use the same currency.', 'woocommerce-payments' ),
+ $subscription->get_currency(),
+ $e->get_currency()
+ )
+ );
}
throw new Exception( $checkout_error_message );
diff --git a/includes/wc-payment-api/class-wc-payments-api-client.php b/includes/wc-payment-api/class-wc-payments-api-client.php
index 37028ab49c2..ba66b392dec 100644
--- a/includes/wc-payment-api/class-wc-payments-api-client.php
+++ b/includes/wc-payment-api/class-wc-payments-api-client.php
@@ -16,9 +16,11 @@
use WCPay\Fraud_Prevention\Buyer_Fingerprinting_Service;
use WCPay\Logger;
use Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore;
+use WCPay\Constants\Currency_Code;
use WCPay\Database_Cache;
use WCPay\Core\Server\Request;
use WCPay\Core\Server\Request\List_Fraud_Outcome_Transactions;
+use WCPay\Exceptions\Cannot_Combine_Currencies_Exception;
/**
* Communicates with WooCommerce Payments API.
@@ -2047,6 +2049,26 @@ protected function check_response_for_errors( $response ) {
} elseif ( isset( $response_body['code'] ) ) {
$this->maybe_act_on_fraud_prevention( $response_body['code'] );
+ if (
+ 'invalid_request_error' === $response_body['code']
+ && 0 === strpos( $response_body['message'], 'You cannot combine currencies on a single customer.' )
+ ) {
+ // Get the currency, which is the last part of the error message,
+ // and remove the period from the end of the error message.
+ $message = $response_body['message'];
+ $currency = substr( $message, -4 );
+ $currency = strtoupper( substr( $currency, 0, 3 ) );
+
+ // Only throw the error if we can find a valid currency.
+ if ( false !== Currency_Code::search( $currency ) ) {
+ throw new Cannot_Combine_Currencies_Exception(
+ $message,
+ $currency,
+ $response_code
+ );
+ }
+ }
+
$error_code = $response_body['code'];
$error_message = $response_body['message'];
} else {
From 644fe9391ad09d3bed5d03c50295389bee32c774 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Krist=C3=B3fer=20Reykjal=C3=ADn?=
<13835680+reykjalin@users.noreply.github.com>
Date: Wed, 3 Apr 2024 17:41:30 +0000
Subject: [PATCH 3/6] Ignore filesystem sniffs for GH workflows and tests
(#8535)
---
changelog/fix-filesystem-phpcs-reports | 4 ++++
phpcs.xml.dist | 10 +++++-----
2 files changed, 9 insertions(+), 5 deletions(-)
create mode 100644 changelog/fix-filesystem-phpcs-reports
diff --git a/changelog/fix-filesystem-phpcs-reports b/changelog/fix-filesystem-phpcs-reports
new file mode 100644
index 00000000000..a1c595cdc25
--- /dev/null
+++ b/changelog/fix-filesystem-phpcs-reports
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+Ignore alternative function WordPress PHPCS sniffs in the GH workflows and tests
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 42248d81011..3c1309f636b 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -35,11 +35,6 @@
-
-
-
-
-
@@ -75,6 +70,11 @@
./tests/*
+
+ tests/
+ .github/
+
+
From 79182cb4f230a010bfe44c989696bc79f51ef896 Mon Sep 17 00:00:00 2001
From: Malith Senaweera <6216000+malithsen@users.noreply.github.com>
Date: Thu, 4 Apr 2024 00:04:02 +0530
Subject: [PATCH 4/6] Migrate woopay skipped tracks event to 'wcpay' prefix
(#8563)
---
.../fix-migrate-woopay-skipped-tracks-event | 5 +++++
client/checkout/woopay/email-input-iframe.js | 2 +-
client/tracks/index.ts | 5 +----
includes/class-woopay-tracker.php | 18 +++---------------
4 files changed, 10 insertions(+), 20 deletions(-)
create mode 100644 changelog/fix-migrate-woopay-skipped-tracks-event
diff --git a/changelog/fix-migrate-woopay-skipped-tracks-event b/changelog/fix-migrate-woopay-skipped-tracks-event
new file mode 100644
index 00000000000..15efc072995
--- /dev/null
+++ b/changelog/fix-migrate-woopay-skipped-tracks-event
@@ -0,0 +1,5 @@
+Significance: patch
+Type: dev
+Comment: Complete WooPay Tracks event migration and cleanup migration related code
+
+
diff --git a/client/checkout/woopay/email-input-iframe.js b/client/checkout/woopay/email-input-iframe.js
index ce3040387e4..22b57d6736b 100644
--- a/client/checkout/woopay/email-input-iframe.js
+++ b/client/checkout/woopay/email-input-iframe.js
@@ -639,7 +639,7 @@ export const handleWooPayEmailInput = async (
dispatchUserExistEvent( true );
}, 2000 );
- recordUserEvent( 'woopay_skipped', {}, true );
+ recordUserEvent( 'woopay_skipped', {} );
searchParams.delete( 'skip_woopay' );
diff --git a/client/tracks/index.ts b/client/tracks/index.ts
index 345da115cd8..5b459fde5fa 100644
--- a/client/tracks/index.ts
+++ b/client/tracks/index.ts
@@ -62,12 +62,10 @@ export const recordEvent = (
*
* @param {string} eventName Name of the event.
* @param {Object} [eventProperties] Event properties (optional).
- * @param {boolean} isLegacy Event properties (optional).
*/
export const recordUserEvent = (
eventName: string,
- eventProperties: Record< string, unknown > = {},
- isLegacy = false
+ eventProperties: Record< string, unknown > = {}
): void => {
const nonce =
getConfig( 'platformTrackerNonce' ) ??
@@ -80,7 +78,6 @@ export const recordUserEvent = (
body.append( 'action', 'platform_tracks' );
body.append( 'tracksEventName', eventName );
body.append( 'tracksEventProp', JSON.stringify( eventProperties ) );
- body.append( 'isLegacy', JSON.stringify( isLegacy ) ); // formData does not allow appending booleans, so we stringify it - it is parsed back to a boolean on the PHP side.
fetch( ajaxUrl, {
method: 'post',
body,
diff --git a/includes/class-woopay-tracker.php b/includes/class-woopay-tracker.php
index ac9df28fef3..04312026ebc 100644
--- a/includes/class-woopay-tracker.php
+++ b/includes/class-woopay-tracker.php
@@ -21,13 +21,6 @@
*/
class WooPay_Tracker extends Jetpack_Tracks_Client {
- /**
- * Legacy prefix used for WooPay user events
- *
- * @var string
- */
- private static $legacy_user_prefix = 'woocommerceanalytics';
-
/**
* WCPay user event prefix
*
@@ -107,10 +100,7 @@ public function ajax_tracks() {
$tracks_data = $event_prop;
}
}
- // Legacy events are shopper events that still use the woocommerceanalytics prefix.
- // These need to be migrated to the wcpay prefix.
- $is_legacy_event = isset( $_REQUEST['isLegacy'] ) ? rest_sanitize_boolean( wc_clean( wp_unslash( $_REQUEST['isLegacy'] ) ) ) : false;
- $this->maybe_record_event( sanitize_text_field( wp_unslash( $_REQUEST['tracksEventName'] ) ), $tracks_data, $is_legacy_event );
+ $this->maybe_record_event( sanitize_text_field( wp_unslash( $_REQUEST['tracksEventName'] ) ), $tracks_data );
wp_send_json_success();
}
@@ -132,13 +122,11 @@ public function ajax_tracks_id() {
*
* @param string $event name of the event.
* @param array $data array of event properties.
- * @param boolean $is_legacy indicate whether this is a legacy event.
*/
- public function maybe_record_event( $event, $data = [], $is_legacy = true ) {
+ public function maybe_record_event( $event, $data = [] ) {
// Top level events should not be namespaced.
if ( '_aliasUser' !== $event ) {
- $prefix = $is_legacy ? self::$legacy_user_prefix : self::$user_prefix;
- $event = $prefix . '_' . $event;
+ $event = self::$user_prefix . '_' . $event;
}
return $this->tracks_record_event( $event, $data );
From ac82b7dd1f4d4be44159b99c4b4793284da7559f Mon Sep 17 00:00:00 2001
From: Cvetan Cvetanov
Date: Thu, 4 Apr 2024 10:20:11 +0300
Subject: [PATCH 5/6] Update Decline button loading state when Accept button is
click on ToS modal (#8565)
---
changelog/fix-7866-tos-decline-busy | 4 ++++
client/tos/modal/index.js | 6 +++++-
2 files changed, 9 insertions(+), 1 deletion(-)
create mode 100644 changelog/fix-7866-tos-decline-busy
diff --git a/changelog/fix-7866-tos-decline-busy b/changelog/fix-7866-tos-decline-busy
new file mode 100644
index 00000000000..d35a3181179
--- /dev/null
+++ b/changelog/fix-7866-tos-decline-busy
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix Decline button state for Accept loading on ToS modal
diff --git a/client/tos/modal/index.js b/client/tos/modal/index.js
index c7369ec9ab1..5b5766e877c 100644
--- a/client/tos/modal/index.js
+++ b/client/tos/modal/index.js
@@ -73,7 +73,11 @@ const TosModalUI = ( { onAccept, onDecline, isBusy, hasError } ) => {
{ message }
-
>
);
diff --git a/client/connect-account-page/test/__snapshots__/index.test.tsx.snap b/client/connect-account-page/test/__snapshots__/index.test.tsx.snap
index 8cf485187f6..13332d592fe 100644
--- a/client/connect-account-page/test/__snapshots__/index.test.tsx.snap
+++ b/client/connect-account-page/test/__snapshots__/index.test.tsx.snap
@@ -107,9 +107,9 @@ exports[`ConnectAccountPage should render correctly 1`] = `
src="assets/images/payment-methods/woo.svg"
/>
- & more.
+ & more
- & more.
+ & more
- & more.
+ & more