From 3717ed965535c003a857a6e3b91c2045f62644c4 Mon Sep 17 00:00:00 2001 From: Alefe Souza Date: Wed, 27 Nov 2024 14:44:39 -0300 Subject: [PATCH 1/8] Fix WooPay trial subscriptions purchases (#9778) --- changelog/fix-woopay-trial-subscriptions | 4 ++++ includes/woopay/class-woopay-session.php | 28 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 changelog/fix-woopay-trial-subscriptions diff --git a/changelog/fix-woopay-trial-subscriptions b/changelog/fix-woopay-trial-subscriptions new file mode 100644 index 00000000000..58c43b05c16 --- /dev/null +++ b/changelog/fix-woopay-trial-subscriptions @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix WooPay trial subscriptions purchases. diff --git a/includes/woopay/class-woopay-session.php b/includes/woopay/class-woopay-session.php index f19549cd9fa..dce1878265e 100644 --- a/includes/woopay/class-woopay-session.php +++ b/includes/woopay/class-woopay-session.php @@ -45,6 +45,7 @@ public static function init() { add_filter( 'woocommerce_session_handler', [ __CLASS__, 'add_woopay_store_api_session_handler' ], 20 ); add_action( 'woocommerce_order_payment_status_changed', [ __CLASS__, 'woopay_order_payment_status_changed' ] ); add_action( 'woopay_restore_order_customer_id', [ __CLASS__, 'restore_order_customer_id_from_requests_with_verified_email' ] ); + add_filter( 'woocommerce_order_needs_payment', [ __CLASS__, 'woopay_trial_subscriptions_handler' ], 20, 3 ); register_deactivation_hook( WCPAY_PLUGIN_FILE, [ __CLASS__, 'run_and_remove_woopay_restore_order_customer_id_schedules' ] ); @@ -272,6 +273,33 @@ public static function automatewoo_refer_a_friend_referral_from_parameter( $advo return $automatewoo_referral; } + /** + * Process trial subscriptions for WooPay. + * + * @param bool $needs_payment If the order needs payment. + * @param \WC_Order $order The order. + * @param array $valid_order_statuses The valid order statuses. + */ + public static function woopay_trial_subscriptions_handler( $needs_payment, $order, $valid_order_statuses ) { + if ( ! self::is_request_from_woopay() || ! \WC_Payments_Utils::is_store_api_request() ) { + return $needs_payment; + } + + if ( ! self::is_woopay_enabled() ) { + return $needs_payment; + } + + if ( ! class_exists( 'WC_Subscriptions_Cart' ) || $order->get_total() > 0 ) { + return $needs_payment; + } + + if ( \WC_Subscriptions_Cart::cart_contains_subscription() ) { + return true; + } + + return $needs_payment; + } + /** * Returns the payload from a cart token. * From 1137c625bd02502e003ebd8b09de473e82ea4b3a Mon Sep 17 00:00:00 2001 From: Miguel Gasca Date: Wed, 27 Nov 2024 19:32:20 +0100 Subject: [PATCH 2/8] Fix return types in DocBlocks (#9815) --- changelog/dev-4293-address-additional-union-types | 4 ++++ includes/admin/class-wc-rest-payments-customer-controller.php | 2 +- .../admin/class-wc-rest-payments-onboarding-controller.php | 2 +- ...ass-wc-rest-payments-payment-intents-create-controller.php | 2 +- includes/admin/class-wc-rest-payments-reader-controller.php | 2 +- includes/class-wc-payments-token-service.php | 2 +- ...ass-wc-rest-payments-reports-authorizations-controller.php | 2 +- ...class-wc-rest-payments-reports-transactions-controller.php | 2 +- 8 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 changelog/dev-4293-address-additional-union-types diff --git a/changelog/dev-4293-address-additional-union-types b/changelog/dev-4293-address-additional-union-types new file mode 100644 index 00000000000..361b062f85f --- /dev/null +++ b/changelog/dev-4293-address-additional-union-types @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Fix return types diff --git a/includes/admin/class-wc-rest-payments-customer-controller.php b/includes/admin/class-wc-rest-payments-customer-controller.php index c0f43a97003..93a310ef868 100644 --- a/includes/admin/class-wc-rest-payments-customer-controller.php +++ b/includes/admin/class-wc-rest-payments-customer-controller.php @@ -99,7 +99,7 @@ public function get_customer_payment_methods( $request ) { * @param array|mixed $item Item to prepare. * @param WP_REST_Request $request Request instance. * - * @return WP_REST_Response|WP_Error|WP_REST_Response + * @return WP_REST_Response|WP_Error */ public function prepare_item_for_response( $item, $request ) { diff --git a/includes/admin/class-wc-rest-payments-onboarding-controller.php b/includes/admin/class-wc-rest-payments-onboarding-controller.php index 7a75d3d8de1..3903dad3ff7 100644 --- a/includes/admin/class-wc-rest-payments-onboarding-controller.php +++ b/includes/admin/class-wc-rest-payments-onboarding-controller.php @@ -219,7 +219,7 @@ public function get_embedded_kyc_session( WP_REST_Request $request ) { * * @param WP_REST_Request $request Request object. * - * @return WP_Error|WP_HTTP_Response|WP_REST_Response + * @return WP_REST_Response|WP_Error */ public function finalize_embedded_kyc( WP_REST_Request $request ) { $source = $request->get_param( 'source' ) ?? ''; diff --git a/includes/admin/class-wc-rest-payments-payment-intents-create-controller.php b/includes/admin/class-wc-rest-payments-payment-intents-create-controller.php index 972717724a8..39363cdfc00 100644 --- a/includes/admin/class-wc-rest-payments-payment-intents-create-controller.php +++ b/includes/admin/class-wc-rest-payments-payment-intents-create-controller.php @@ -318,7 +318,7 @@ public function get_item_schema() { * @param array|mixed $item Item to prepare. * @param WP_REST_Request $request Request instance. * - * @return WP_REST_Response|WP_Error|WP_REST_Response + * @return WP_REST_Response|WP_Error */ public function prepare_item_for_response( $item, $request ) { $prepared_item = []; diff --git a/includes/admin/class-wc-rest-payments-reader-controller.php b/includes/admin/class-wc-rest-payments-reader-controller.php index fa6fa5192e0..33c8eaec2dc 100644 --- a/includes/admin/class-wc-rest-payments-reader-controller.php +++ b/includes/admin/class-wc-rest-payments-reader-controller.php @@ -146,7 +146,7 @@ public function register_routes() { * * @param WP_REST_Request $request Full data about the request. * - * @return WP_Error|WP_HTTP_Response|WP_REST_Response + * @return WP_REST_Response|WP_Error */ public function get_summary( $request ) { diff --git a/includes/class-wc-payments-token-service.php b/includes/class-wc-payments-token-service.php index 166ef6c9685..7bfdc482e18 100644 --- a/includes/class-wc-payments-token-service.php +++ b/includes/class-wc-payments-token-service.php @@ -62,7 +62,7 @@ public function __construct( WC_Payments_API_Client $payments_api_client, WC_Pay * * @param array $payment_method Payment method to be added. * @param WP_User $user User to attach payment method to. - * @return WC_Payment_Token|WC_Payment_Token_CC|WC_Payment_Token_WCPay_SEPA The WC object for the payment token. + * @return WC_Payment_Token The WC object for the payment token. */ public function add_token_to_user( $payment_method, $user ) { // Clear cached payment methods. diff --git a/includes/reports/class-wc-rest-payments-reports-authorizations-controller.php b/includes/reports/class-wc-rest-payments-reports-authorizations-controller.php index 0834d078eeb..3f1e60f7e8b 100644 --- a/includes/reports/class-wc-rest-payments-reports-authorizations-controller.php +++ b/includes/reports/class-wc-rest-payments-reports-authorizations-controller.php @@ -127,7 +127,7 @@ public function get_authorization( $request ) { * @param array|mixed $item Item to prepare. * @param WP_REST_Request $request Request instance. * - * @return WP_REST_Response|WP_Error|WP_REST_Response + * @return WP_REST_Response|WP_Error */ public function prepare_item_for_response( $item, $request ) { diff --git a/includes/reports/class-wc-rest-payments-reports-transactions-controller.php b/includes/reports/class-wc-rest-payments-reports-transactions-controller.php index 1e38d6cd746..a307c12c627 100644 --- a/includes/reports/class-wc-rest-payments-reports-transactions-controller.php +++ b/includes/reports/class-wc-rest-payments-reports-transactions-controller.php @@ -115,7 +115,7 @@ public function get_transaction( $request ) { * @param array|mixed $item Item to prepare. * @param WP_REST_Request $request Request instance. * - * @return WP_REST_Response|WP_Error|WP_REST_Response + * @return WP_REST_Response|WP_Error */ public function prepare_item_for_response( $item, $request ) { From e47c67a07b900ccb2605b0520f0470bbd1ae56a1 Mon Sep 17 00:00:00 2001 From: Achyuth Ajoy Date: Thu, 28 Nov 2024 13:34:45 +0530 Subject: [PATCH 3/8] Update references to woocommerce_payments_server (#9824) --- .github/workflows/e2e-pull-request.yml | 34 +++++++++++------------ .github/workflows/e2e-pw-pull-request.yml | 2 +- .github/workflows/e2e-test.yml | 32 ++++++++++----------- changelog/update-server-container-name | 5 ++++ tests/e2e/README.md | 12 ++++---- tests/e2e/env/down.sh | 2 +- tests/e2e/env/setup.sh | 10 +++---- tests/e2e/env/shared.sh | 4 +-- tests/e2e/env/up.sh | 2 +- 9 files changed, 54 insertions(+), 49 deletions(-) create mode 100644 changelog/update-server-container-name diff --git a/.github/workflows/e2e-pull-request.yml b/.github/workflows/e2e-pull-request.yml index aa4748b37d0..4ed61a3882b 100644 --- a/.github/workflows/e2e-pull-request.yml +++ b/.github/workflows/e2e-pull-request.yml @@ -18,23 +18,23 @@ on: description: "Branch to be used for running tests" env: - E2E_GH_TOKEN: ${{ secrets.E2E_GH_TOKEN }} - WCP_DEV_TOOLS_REPO: ${{ secrets.WCP_DEV_TOOLS_REPO }} - WCP_DEV_TOOLS_BRANCH: 'trunk' - WCP_SERVER_REPO: ${{ secrets.WCP_SERVER_REPO }} - WC_SUBSCRIPTIONS_REPO: ${{ secrets.WC_SUBSCRIPTIONS_REPO }} - E2E_BLOG_ID: ${{ secrets.E2E_BLOG_ID }} - E2E_BLOG_TOKEN: ${{ secrets.E2E_BLOG_TOKEN }} - E2E_USER_TOKEN: ${{ secrets.E2E_USER_TOKEN }} - WC_E2E_SCREENSHOTS: 1 - E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }} - E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }} - E2E_USE_LOCAL_SERVER: false - E2E_RESULT_FILEPATH: 'tests/e2e/results.json' - WCPAY_USE_BUILD_ARTIFACT: ${{ inputs.wcpay-use-build-artifact }} - WCPAY_ARTIFACT_DIRECTORY: 'zipfile' - NODE_ENV: 'test' - FORCE_E2E_DEPS_SETUP: true + E2E_GH_TOKEN: ${{ secrets.E2E_GH_TOKEN }} + WCP_DEV_TOOLS_REPO: ${{ secrets.WCP_DEV_TOOLS_REPO }} + WCP_DEV_TOOLS_BRANCH: 'trunk' + TRANSACT_PLATFORM_SERVER_REPO: ${{ secrets.TRANSACT_PLATFORM_SERVER_REPO }} + WC_SUBSCRIPTIONS_REPO: ${{ secrets.WC_SUBSCRIPTIONS_REPO }} + E2E_BLOG_ID: ${{ secrets.E2E_BLOG_ID }} + E2E_BLOG_TOKEN: ${{ secrets.E2E_BLOG_TOKEN }} + E2E_USER_TOKEN: ${{ secrets.E2E_USER_TOKEN }} + WC_E2E_SCREENSHOTS: 1 + E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }} + E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }} + E2E_USE_LOCAL_SERVER: false + E2E_RESULT_FILEPATH: 'tests/e2e/results.json' + WCPAY_USE_BUILD_ARTIFACT: ${{ inputs.wcpay-use-build-artifact }} + WCPAY_ARTIFACT_DIRECTORY: 'zipfile' + NODE_ENV: 'test' + FORCE_E2E_DEPS_SETUP: true concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/e2e-pw-pull-request.yml b/.github/workflows/e2e-pw-pull-request.yml index 0cc22f767c2..da6765fb51b 100644 --- a/.github/workflows/e2e-pw-pull-request.yml +++ b/.github/workflows/e2e-pw-pull-request.yml @@ -21,7 +21,7 @@ env: E2E_GH_TOKEN: ${{ secrets.E2E_GH_TOKEN }} WCP_DEV_TOOLS_REPO: ${{ secrets.WCP_DEV_TOOLS_REPO }} WCP_DEV_TOOLS_BRANCH: 'trunk' - WCP_SERVER_REPO: ${{ secrets.WCP_SERVER_REPO }} + TRANSACT_PLATFORM_SERVER_REPO: ${{ secrets.TRANSACT_PLATFORM_SERVER_REPO }} WC_SUBSCRIPTIONS_REPO: ${{ secrets.WC_SUBSCRIPTIONS_REPO }} E2E_BLOG_ID: ${{ secrets.E2E_BLOG_ID }} E2E_BLOG_TOKEN: ${{ secrets.E2E_BLOG_TOKEN }} diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 04e85183f3e..1d1f0b1bd71 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -10,22 +10,22 @@ on: workflow_dispatch: env: - E2E_GH_TOKEN: ${{ secrets.E2E_GH_TOKEN }} - WCP_DEV_TOOLS_REPO: ${{ secrets.WCP_DEV_TOOLS_REPO }} - WCP_DEV_TOOLS_BRANCH: 'trunk' - WCP_SERVER_REPO: ${{ secrets.WCP_SERVER_REPO }} - WC_SUBSCRIPTIONS_REPO: ${{ secrets.WC_SUBSCRIPTIONS_REPO }} - E2E_BLOG_ID: ${{ secrets.E2E_BLOG_ID }} - E2E_BLOG_TOKEN: ${{ secrets.E2E_BLOG_TOKEN }} - E2E_USER_TOKEN: ${{ secrets.E2E_USER_TOKEN }} - WC_E2E_SCREENSHOTS: 1 - E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }} - E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }} - E2E_USE_LOCAL_SERVER: false - E2E_RESULT_FILEPATH: 'tests/e2e/results.json' - WC_MIN_SUPPORTED_VERSION: '7.6.0' - NODE_ENV: 'test' - FORCE_E2E_DEPS_SETUP: true + E2E_GH_TOKEN: ${{ secrets.E2E_GH_TOKEN }} + WCP_DEV_TOOLS_REPO: ${{ secrets.WCP_DEV_TOOLS_REPO }} + WCP_DEV_TOOLS_BRANCH: 'trunk' + TRANSACT_PLATFORM_SERVER_REPO: ${{ secrets.TRANSACT_PLATFORM_SERVER_REPO }} + WC_SUBSCRIPTIONS_REPO: ${{ secrets.WC_SUBSCRIPTIONS_REPO }} + E2E_BLOG_ID: ${{ secrets.E2E_BLOG_ID }} + E2E_BLOG_TOKEN: ${{ secrets.E2E_BLOG_TOKEN }} + E2E_USER_TOKEN: ${{ secrets.E2E_USER_TOKEN }} + WC_E2E_SCREENSHOTS: 1 + E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }} + E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }} + E2E_USE_LOCAL_SERVER: false + E2E_RESULT_FILEPATH: 'tests/e2e/results.json' + WC_MIN_SUPPORTED_VERSION: '7.6.0' + NODE_ENV: 'test' + FORCE_E2E_DEPS_SETUP: true jobs: generate-matrix: diff --git a/changelog/update-server-container-name b/changelog/update-server-container-name new file mode 100644 index 00000000000..cb9580f8a22 --- /dev/null +++ b/changelog/update-server-container-name @@ -0,0 +1,5 @@ +Significance: patch +Type: dev +Comment: Updates server container name used by E2E tests + + diff --git a/tests/e2e/README.md b/tests/e2e/README.md index 35b5e5c5e5f..38ca21dbdbd 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -24,18 +24,18 @@ DEBUG=false ---
-Choose WCPay Server instance +Choose Transact Platform Server instance

-It is possible to use the live server or a local docker instance of WCPay server locally. On Github Actions, live server is used for tests. Add the following env variables to your `local.env` based on your preference (replace values as required). +It is possible to use the live server or a local docker instance of Transact Platform Server locally. On Github Actions, live server is used for tests. Add the following env variables to your `local.env` based on your preference (replace values as required). **Using Local Server on Docker** -By default, the local E2E environment is configured to use WCPay local server instance. Add the following env variables to configure the local server instance. +By default, the local E2E environment is configured to use Transact Platform local server instance. Add the following env variables to configure the local server instance. ``` -# WooCommerce Payments Server Repo -WCP_SERVER_REPO='https://github.com/server-repo.git or git@github.com:org/server-repo.git' +# Transact Platform Server Repo +TRANSACT_PLATFORM_SERVER_REPO='https://github.com/server-repo.git or git@github.com:org/server-repo.git' # Stripe account data. Need to support level 3 data to run tests successfully. # These values can be obtained from the Stripe Dashboard: https://dashboard.stripe.com/test/apikeys @@ -135,7 +135,7 @@ E2E_WC_VERSION='' - WC E2E Client: http://localhost:8084 - WC E2E Server: http://localhost:8088 (Available only when using local server) - **Note:** Be aware that the server port may change in the `docker-compose.e2e.yml` configuration, so when you can't access the server, try running `docker port woocommerce_payments_server_wordpress_e2e 80` to find out the bound port of the E2E server container. + **Note:** Be aware that the server port may change in the `docker-compose.e2e.yml` configuration, so when you can't access the server, try running `docker port transact_platform_server_wordpress_e2e 80` to find out the bound port of the E2E server container.

diff --git a/tests/e2e/env/down.sh b/tests/e2e/env/down.sh index 6dc112bef7f..ba3cc6f2503 100755 --- a/tests/e2e/env/down.sh +++ b/tests/e2e/env/down.sh @@ -13,7 +13,7 @@ docker compose -f $E2E_ROOT/env/docker-compose.yml down if [[ "$E2E_USE_LOCAL_SERVER" != false ]]; then step "Stopping server containers" - docker compose -f $E2E_ROOT/deps/wcp-server/docker-compose.yml down + docker compose -f $E2E_ROOT/deps/transact-platform-server/docker-compose.yml down fi # Remove auth credentials from the Playwright config. diff --git a/tests/e2e/env/setup.sh b/tests/e2e/env/setup.sh index 50d4313f235..d2aa3a50e89 100755 --- a/tests/e2e/env/setup.sh +++ b/tests/e2e/env/setup.sh @@ -33,19 +33,19 @@ if [[ $FORCE_E2E_DEPS_SETUP ]]; then sudo rm -rf tests/e2e/deps fi -# Setup WCPay local server instance. +# Setup Transact Platform local server instance. # Only if E2E_USE_LOCAL_SERVER is present & equals to true. if [[ "$E2E_USE_LOCAL_SERVER" != false ]]; then if [[ ! -d "$SERVER_PATH" ]]; then - step "Fetching server (branch ${WCP_SERVER_BRANCH-trunk})" + step "Fetching server (branch ${TRANSACT_PLATFORM_SERVER_BRANCH-trunk})" - if [[ -z $WCP_SERVER_REPO ]]; then - echo "WCP_SERVER_REPO env variable is not defined" + if [[ -z $TRANSACT_PLATFORM_SERVER_REPO ]]; then + echo "TRANSACT_PLATFORM_SERVER_REPO env variable is not defined" exit 1; fi rm -rf "$SERVER_PATH" - git clone --depth=1 --branch "${WCP_SERVER_BRANCH-trunk}" "$WCP_SERVER_REPO" "$SERVER_PATH" + git clone --depth=1 --branch "${TRANSACT_PLATFORM_SERVER_BRANCH-trunk}" "$TRANSACT_PLATFORM_SERVER_REPO" "$SERVER_PATH" else echo "Using cached server at ${SERVER_PATH}" fi diff --git a/tests/e2e/env/shared.sh b/tests/e2e/env/shared.sh index 042eb3d615a..39ac4fdd760 100644 --- a/tests/e2e/env/shared.sh +++ b/tests/e2e/env/shared.sh @@ -5,8 +5,8 @@ cwd=$(pwd) export WCP_ROOT=$cwd export E2E_ROOT="$cwd/tests/e2e" export WP_URL="localhost:8084" -export SERVER_PATH="$E2E_ROOT/deps/wcp-server" -export SERVER_CONTAINER="woocommerce_payments_server_wordpress_e2e" +export SERVER_PATH="$E2E_ROOT/deps/transact-platform-server" +export SERVER_CONTAINER="transact_platform_server_wordpress_e2e" export DEV_TOOLS_DIR="wcp-dev-tools" export DEV_TOOLS_PATH="$E2E_ROOT/deps/$DEV_TOOLS_DIR" export CLIENT_CONTAINER="wcp_e2e_wordpress" diff --git a/tests/e2e/env/up.sh b/tests/e2e/env/up.sh index 1a5998b9047..80696a67579 100755 --- a/tests/e2e/env/up.sh +++ b/tests/e2e/env/up.sh @@ -13,5 +13,5 @@ docker compose -f "$E2E_ROOT/env/docker-compose.yml" up -d if [[ "$E2E_USE_LOCAL_SERVER" != false ]]; then step "Starting server containers" - docker compose -f "$E2E_ROOT/deps/wcp-server/docker-compose.yml" up -d + docker compose -f "$E2E_ROOT/deps/transact-platform-server/docker-compose.yml" up -d fi From 082753054ae4bb2112b3249aa33b78a4ac7d09c5 Mon Sep 17 00:00:00 2001 From: Oleksandr Aratovskyi <79862886+oaratovskyi@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:56:56 +0200 Subject: [PATCH 4/8] Allow redirect to the settings page from WCPay connect (#9827) Co-authored-by: oaratovskyi Co-authored-by: Daniel Mallory --- assets/images/illustrations/setup.svg | 1 + ...direct-to-settings-page-from-wcpay-connect | 4 ++ client/connect-account-page/index.tsx | 18 +++--- client/connect-account-page/style.scss | 8 +-- includes/class-wc-payments-account.php | 55 +++++++++++++++---- .../class-wc-payments-redirect-service.php | 28 ++++++++++ tests/unit/test-class-wc-payments-account.php | 47 +++++++++++++++- ...est-class-wc-payments-redirect-service.php | 11 ++++ 8 files changed, 146 insertions(+), 26 deletions(-) create mode 100644 assets/images/illustrations/setup.svg create mode 100644 changelog/dev-allow-redirect-to-settings-page-from-wcpay-connect diff --git a/assets/images/illustrations/setup.svg b/assets/images/illustrations/setup.svg new file mode 100644 index 00000000000..b5c8abde96d --- /dev/null +++ b/assets/images/illustrations/setup.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/changelog/dev-allow-redirect-to-settings-page-from-wcpay-connect b/changelog/dev-allow-redirect-to-settings-page-from-wcpay-connect new file mode 100644 index 00000000000..3fca0c1ff3e --- /dev/null +++ b/changelog/dev-allow-redirect-to-settings-page-from-wcpay-connect @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Allow redirect to the settings page from WCPay connect diff --git a/client/connect-account-page/index.tsx b/client/connect-account-page/index.tsx index ac1668de0a8..faa5d94311c 100644 --- a/client/connect-account-page/index.tsx +++ b/client/connect-account-page/index.tsx @@ -27,11 +27,12 @@ import Incentive from './incentive'; import InfoNotice from './info-notice-modal'; import OnboardingLocationCheckModal from './modal'; import LogoImg from 'assets/images/woopayments.svg?asset'; +import SetupImg from 'assets/images/illustrations/setup.svg?asset'; import strings from './strings'; import './style.scss'; import InlineNotice from 'components/inline-notice'; import { WooPaymentMethodsLogos } from 'components/payment-method-logos'; -import WooPaymentsLogo from 'assets/images/logo.svg?asset'; +import WooLogo from 'assets/images/woo-logo.svg?asset'; import { sanitizeHTML } from 'wcpay/utils/sanitize'; import { isInTestModeOnboarding } from 'wcpay/utils'; import ResetAccountModal from 'wcpay/overview/modal/reset-account'; @@ -52,18 +53,19 @@ const TestDriveLoader: React.FunctionComponent< { progress: number; } > = ( { progress } ) => ( - + + + setup + + - { __( - 'Creating your sandbox account', - 'woocommerce-payments' - ) } + { __( 'Finishing payments setup', 'woocommerce-payments' ) } { __( - 'In just a few moments, you will be ready to test payments on your store.' + "In just a few moments, you'll be ready to test payments on your store." ) } @@ -193,6 +195,8 @@ const ConnectAccountPage: React.FC = () => { 'wcpay-sandbox-success': 'true', source: determineTrackingSource(), from: 'WCPAY_CONNECT', + redirect_to_settings_page: + urlParams.get( 'redirect_to_settings_page' ) || '', } ); } else { setTimeout( checkAccountStatus, 2000 ); diff --git a/client/connect-account-page/style.scss b/client/connect-account-page/style.scss index 41e278c3bc1..96efc3493c2 100644 --- a/client/connect-account-page/style.scss +++ b/client/connect-account-page/style.scss @@ -249,12 +249,12 @@ z-index: 999999; text-align: center; - img { + img.logo { position: absolute; - height: 44px; - width: 167px; + height: 40px; + width: 40px; top: 18px; - left: calc( 50% - 84px ); + left: 36px; } } } diff --git a/includes/class-wc-payments-account.php b/includes/class-wc-payments-account.php index d2a01ec48ff..e884d582ac8 100644 --- a/includes/class-wc-payments-account.php +++ b/includes/class-wc-payments-account.php @@ -1143,12 +1143,12 @@ public function maybe_handle_onboarding() { * * 0. Make changes to the account data if needed (e.g. reset account, disable test mode onboarding) * as instructed by the GET params. - * 0.1 If we reset the account -> redirect to CONNECT PAGE + * 0.1 If we reset the account -> redirect to CONNECT PAGE / SETTINGS PAGE If redirect to settings page flag set * 1. Returning from the WPCOM/Jetpack connection screen. * 1.1 SUCCESSFUL connection * 1.1.1 NO Stripe account connected -> redirect to ONBOARDING WIZARD * 1.1.2 Stripe account connected -> redirect to OVERVIEW PAGE - * 1.2 UNSUCCESSFUL connection -> redirect to CONNECT PAGE with ERROR message + * 1.2 UNSUCCESSFUL connection -> redirect to CONNECT PAGE with ERROR message / SETTINGS PAGE if redirect to settings page flag set * 2. Working WPCOM/Jetpack connection and fully onboarded Stripe account -> redirect to OVERVIEW PAGE * 3. Specific `from` places -> redirect to CONNECT PAGE regardless of the account status * 4. NO [working] WPCOM/Jetpack connection: @@ -1167,6 +1167,7 @@ public function maybe_handle_onboarding() { * 5.1.3 All other cases -> redirect to ONBOARDING WIZARD * 5.2 If PARTIALLY onboarded Stripe account connected -> redirect to STRIPE KYC * 5.3 If fully onboarded Stripe account connected -> redirect to OVERVIEW PAGE + * 5.3.1 If redirect to settings page flags set -> redirect to SETTINGS PAGE * * This logic is so complex because we use connect links as a catch-all place to * handle everything and anything related to the WooPayments account setup. It reduces the complexity on the @@ -1182,6 +1183,7 @@ public function maybe_handle_onboarding() { $progressive = ! empty( $_GET['progressive'] ) && 'true' === $_GET['progressive']; $collect_payout_requirements = ! empty( $_GET['collect_payout_requirements'] ) && 'true' === $_GET['collect_payout_requirements']; $create_test_drive_account = ! empty( $_GET['test_drive'] ) && 'true' === $_GET['test_drive']; + $redirect_to_settings_page = ! empty( $_GET['redirect_to_settings_page'] ) && 'true' === $_GET['redirect_to_settings_page']; // There is no point in auto starting test drive onboarding if we are not in the test drive mode. $auto_start_test_drive_onboarding = $create_test_drive_account && ! empty( $_GET['auto_start_test_drive_onboarding'] ) && @@ -1253,7 +1255,16 @@ public function maybe_handle_onboarding() { $this->cleanup_on_account_reset(); - // When we reset the account we want to always go the Connect page. Redirect immediately! + // When we reset the account and want to go back to the settings page - redirect immediately! + if ( $redirect_to_settings_page ) { + $this->redirect_service->redirect_to_settings_page( + WC_Payments_Onboarding_Service::FROM_RESET_ACCOUNT, + [ 'source' => $onboarding_source ] + ); + return; + } + + // Otherwise, when we reset the account we want to always go the Connect page. Redirect immediately! $this->redirect_service->redirect_to_connect_page( null, WC_Payments_Onboarding_Service::FROM_RESET_ACCOUNT, @@ -1312,6 +1323,16 @@ public function maybe_handle_onboarding() { array_merge( $tracks_props, [ 'mode' => WC_Payments_Onboarding_Service::is_test_mode_enabled() ? 'test' : 'live' ] ) ); + if ( $redirect_to_settings_page ) { + $this->redirect_service->redirect_to_settings_page( + WC_Payments_Onboarding_Service::FROM_WPCOM_CONNECTION, + [ + 'source' => $onboarding_source, + 'wcpay-connect-jetpack-error' => '1', + ] + ); + } + $this->redirect_service->redirect_to_connect_page( sprintf( /* translators: %s: WooPayments */ @@ -1343,15 +1364,23 @@ public function maybe_handle_onboarding() { && $this->has_working_jetpack_connection() && $this->is_stripe_account_valid() ) { + $params = [ + 'source' => $onboarding_source, + // Carry over some parameters as they may be used by our frontend logic. + 'wcpay-connection-success' => ! empty( $_GET['wcpay-connection-success'] ) ? '1' : false, + 'wcpay-sandbox-success' => ! empty( $_GET['wcpay-sandbox-success'] ) ? 'true' : false, + 'test_drive_error' => ! empty( $_GET['test_drive_error'] ) ? 'true' : false, + ]; + if ( $redirect_to_settings_page ) { + $this->redirect_service->redirect_to_settings_page( + $from, + $params + ); + return; + } $this->redirect_service->redirect_to_overview_page( $from, - [ - 'source' => $onboarding_source, - // Carry over some parameters as they may be used by our frontend logic. - 'wcpay-connection-success' => ! empty( $_GET['wcpay-connection-success'] ) ? '1' : false, - 'wcpay-sandbox-success' => ! empty( $_GET['wcpay-sandbox-success'] ) ? 'true' : false, - 'test_drive_error' => ! empty( $_GET['test_drive_error'] ) ? 'true' : false, - ] + $params ); return; } @@ -1361,13 +1390,14 @@ public function maybe_handle_onboarding() { in_array( $from, [ - WC_Payments_Onboarding_Service::FROM_WCADMIN_PAYMENTS_SETTINGS, WC_Payments_Onboarding_Service::FROM_STRIPE, ], true ) // This is a weird case, but it is best to handle it. || ( WC_Payments_Onboarding_Service::FROM_ONBOARDING_WIZARD === $from && ! $this->has_working_jetpack_connection() ) + // Redirect merchants coming from settings page to the connect page only if $redirect_to_settings_page is false. + || ( WC_Payments_Onboarding_Service::FROM_WCADMIN_PAYMENTS_SETTINGS === $from && ! $redirect_to_settings_page ) ) { $this->redirect_service->redirect_to_connect_page( ! empty( $_GET['wcpay-connection-error'] ) ? sprintf( @@ -1410,7 +1440,7 @@ public function maybe_handle_onboarding() { 'auto_start_test_drive_onboarding' => $auto_start_test_drive_onboarding ? 'true' : false, 'from' => WC_Payments_Onboarding_Service::FROM_WPCOM_CONNECTION, 'source' => $onboarding_source, - + 'redirect_to_settings_page' => $redirect_to_settings_page ? 'true' : false, ], self::get_connect_url( $wcpay_connect_param ) // Instruct Jetpack to return here (connect link). ), @@ -1480,6 +1510,7 @@ public function maybe_handle_onboarding() { 'auto_start_test_drive_onboarding' => 'true', // This is critical. 'test_mode' => $should_onboard_in_test_mode ? 'true' : false, 'source' => $onboarding_source, + 'redirect_to_settings_page' => $redirect_to_settings_page ? 'true' : false, ] ); return; diff --git a/includes/class-wc-payments-redirect-service.php b/includes/class-wc-payments-redirect-service.php index 7863cf0aa6d..bae6299664e 100644 --- a/includes/class-wc-payments-redirect-service.php +++ b/includes/class-wc-payments-redirect-service.php @@ -182,6 +182,34 @@ public function redirect_to_onboarding_wizard( ?string $from = null, array $addi $this->redirect_to( admin_url( add_query_arg( $params, 'admin.php' ) ) ); } + /** + * Immediately redirect to the settings page. + * + * Note that this function immediately ends the execution. + * + * @param string|null $from Optional. Source of the redirect. + * @param array $additional_params Optional. Additional URL params to add to the redirect URL. + */ + public function redirect_to_settings_page( ?string $from = null, array $additional_params = [] ): void { + $params = [ + 'page' => 'wc-settings', + 'tab' => 'checkout', + ]; + + if ( count( $params ) === count( array_intersect_assoc( $_GET, $params ) ) ) { // phpcs:disable WordPress.Security.NonceVerification.Recommended + // We are already in the settings page. Do nothing. + return; + } + + $params = array_merge( $params, $additional_params ); + + if ( ! empty( $from ) ) { + $params['from'] = $from; + } + + $this->redirect_to( admin_url( add_query_arg( $params, 'admin.php' ) ) ); + } + /** * Redirect to the overview page. * diff --git a/tests/unit/test-class-wc-payments-account.php b/tests/unit/test-class-wc-payments-account.php index 54ae7dede7e..f0087e3e966 100644 --- a/tests/unit/test-class-wc-payments-account.php +++ b/tests/unit/test-class-wc-payments-account.php @@ -257,6 +257,7 @@ public function test_maybe_handle_onboarding_connect_from_known_from( $has_working_jetpack_connection, $is_stripe_connected, $create_test_drive_account, + $redirect_to_settings_page, $expected_next_step ) { @@ -278,9 +279,10 @@ public function test_maybe_handle_onboarding_connect_from_known_from( $_GET['page'] = 'wc-admin'; $_GET['path'] = '/payments/some-bogus-page'; - $_GET['from'] = $onboarding_from; - $_GET['source'] = $onboarding_source; - $_GET['test_drive'] = $create_test_drive_account ? 'true' : null; + $_GET['from'] = $onboarding_from; + $_GET['source'] = $onboarding_source; + $_GET['test_drive'] = $create_test_drive_account ? 'true' : null; + $_GET['redirect_to_settings_page'] = $redirect_to_settings_page ? 'true' : null; $this->mock_jetpack_connection( $has_working_jetpack_connection ); @@ -398,6 +400,18 @@ public function test_maybe_handle_onboarding_connect_from_known_from( ) ); break; + case 'settings_page': + $this->mock_api_client + ->expects( $this->never() ) + ->method( 'start_server_connection' ); + $mock_redirect_service + ->expects( $this->once() ) + ->method( 'redirect_to' ) + ->with( + // It should redirect to settings page URL. + $this->stringContains( 'page=wc-settings&tab=checkout' ), + ); + break; default: $this->fail( 'Unexpected redirect type: ' . $expected_next_step ); break; @@ -431,6 +445,7 @@ public function provider_onboarding_known_froms() { false, true, false, + false, 'start_jetpack_connection', ], 'From Woo Payments task - Jetpack connection, Stripe not connected' => [ @@ -439,6 +454,7 @@ public function provider_onboarding_known_froms() { true, false, false, + false, 'onboarding_wizard', ], 'From Woo Payments task - Jetpack connection, Stripe connected' => [ @@ -447,6 +463,7 @@ public function provider_onboarding_known_froms() { true, true, false, + false, 'overview_page', ], 'From Connect page - no Jetpack connection, Stripe connected' => [ @@ -455,6 +472,7 @@ public function provider_onboarding_known_froms() { false, true, false, + false, 'start_jetpack_connection', ], 'From Connect page - Jetpack connection, Stripe not connected' => [ @@ -463,6 +481,7 @@ public function provider_onboarding_known_froms() { true, false, false, + false, 'onboarding_wizard', ], 'From Connect page - Jetpack connection, Stripe connected' => [ @@ -471,6 +490,7 @@ public function provider_onboarding_known_froms() { true, true, false, + false, 'overview_page', ], 'From Connect page - no Jetpack connection, Stripe connected - test-drive' => [ @@ -479,6 +499,7 @@ public function provider_onboarding_known_froms() { false, true, true, + false, 'start_jetpack_connection', ], 'From Connect page - Jetpack connection, Stripe not connected - test-drive' => [ @@ -487,6 +508,7 @@ public function provider_onboarding_known_froms() { true, false, true, + false, 'init_stripe_onboarding', ], 'From Connect page - Jetpack connection, Stripe connected - test-drive' => [ @@ -495,14 +517,25 @@ public function provider_onboarding_known_froms() { true, true, true, + false, 'overview_page', ], + 'From Connect page - Jetpack connection, Stripe connected - test-drive, redirect to settings' => [ + WC_Payments_Onboarding_Service::FROM_CONNECT_PAGE, + WC_Payments_Onboarding_Service::SOURCE_WCADMIN_SETTINGS_PAGE, // Some other original source. + true, + true, + true, + true, + 'settings_page', + ], 'From Woo Payments Settings - no Jetpack connection, Stripe connected' => [ WC_Payments_Onboarding_Service::FROM_WCADMIN_PAYMENTS_SETTINGS, WC_Payments_Onboarding_Service::SOURCE_WCADMIN_SETTINGS_PAGE, false, true, false, + false, 'connect_page', ], 'From Woo Payments Settings - Jetpack connection, Stripe not connected' => [ @@ -511,6 +544,7 @@ public function provider_onboarding_known_froms() { true, false, false, + false, 'connect_page', ], 'From Woo Payments Settings - Jetpack connection, Stripe connected' => [ @@ -519,6 +553,7 @@ public function provider_onboarding_known_froms() { true, true, false, + false, 'overview_page', ], 'From Incentive page - no Jetpack connection, Stripe connected' => [ @@ -527,6 +562,7 @@ public function provider_onboarding_known_froms() { false, true, false, + false, 'start_jetpack_connection', ], 'From Incentive page - Jetpack connection, Stripe not connected' => [ @@ -535,6 +571,7 @@ public function provider_onboarding_known_froms() { true, false, false, + false, 'onboarding_wizard', ], 'From Incentive page - Jetpack connection, Stripe connected' => [ @@ -543,6 +580,7 @@ public function provider_onboarding_known_froms() { true, true, false, + false, 'overview_page', ], // This is a weird scenario that should not happen under normal circumstances. @@ -552,6 +590,7 @@ public function provider_onboarding_known_froms() { false, false, false, + false, 'connect_page', ], 'From Onboarding wizard - Jetpack connection, Stripe not connected' => [ @@ -560,6 +599,7 @@ public function provider_onboarding_known_froms() { true, false, false, + false, 'init_stripe_onboarding', ], 'From Onboarding wizard - Jetpack connection, Stripe connected' => [ @@ -568,6 +608,7 @@ public function provider_onboarding_known_froms() { true, true, false, + false, 'overview_page', ], ]; diff --git a/tests/unit/test-class-wc-payments-redirect-service.php b/tests/unit/test-class-wc-payments-redirect-service.php index 931d0e18102..2d2a8173d9a 100644 --- a/tests/unit/test-class-wc-payments-redirect-service.php +++ b/tests/unit/test-class-wc-payments-redirect-service.php @@ -268,4 +268,15 @@ public function test_redirect_to_connect_page_redirects_with_additional_params() // Act. $this->redirect_service->redirect_to_connect_page( null, null, [ 'source' => 'some-source' ] ); } + + public function test_redirect_to_settings_page_redirects() { + // Assert. + $this->redirect_service + ->expects( $this->once() ) + ->method( 'redirect_to' ) + ->with( admin_url( 'admin.php?page=wc-settings&tab=checkout' ) ); + + // Act. + $this->redirect_service->redirect_to_settings_page(); + } } From 24f3972cde01c4a188f48d8edd3a0a83375800ed Mon Sep 17 00:00:00 2001 From: Guilherme Pressutto Date: Thu, 28 Nov 2024 14:19:40 -0300 Subject: [PATCH 5/8] Use paragraph selector instead of label for pmme appearance (#9840) --- changelog/fix-pmme-appearance-blocks | 4 ++++ client/checkout/upe-styles/index.js | 21 ++++++++++++++++----- client/checkout/upe-styles/upe-styles.js | 3 +++ 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 changelog/fix-pmme-appearance-blocks diff --git a/changelog/fix-pmme-appearance-blocks b/changelog/fix-pmme-appearance-blocks new file mode 100644 index 00000000000..bfde3b89bdd --- /dev/null +++ b/changelog/fix-pmme-appearance-blocks @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Use paragraph selector instead of label for pmme appearance diff --git a/client/checkout/upe-styles/index.js b/client/checkout/upe-styles/index.js index cc6a64deebb..5c775caf43e 100644 --- a/client/checkout/upe-styles/index.js +++ b/client/checkout/upe-styles/index.js @@ -23,6 +23,7 @@ export const appearanceSelectors = { appendTarget: '.woocommerce-billing-fields__field-wrapper', upeThemeInputSelector: '#billing_first_name', upeThemeLabelSelector: '.woocommerce-checkout .form-row label', + upeThemeTextSelector: '.woocommerce-checkout .form-row', rowElement: 'p', validClasses: [ 'form-row' ], invalidClasses: [ @@ -46,6 +47,7 @@ export const appearanceSelectors = { appendTarget: '#contact-fields', upeThemeInputSelector: '.wc-block-components-text-input #email', upeThemeLabelSelector: '.wc-block-components-text-input label', + upeThemeTextSelector: '.wc-block-components-text-input', rowElement: 'div', validClasses: [ 'wc-block-components-text-input', 'is-active' ], invalidClasses: [ 'wc-block-components-text-input', 'has-error' ], @@ -73,6 +75,7 @@ export const appearanceSelectors = { appendTarget: '.product .cart .quantity', upeThemeInputSelector: '.product .cart .quantity .qty', upeThemeLabelSelector: '.product .cart .quantity label', + upeThemeTextSelector: '.product .cart .quantity', rowElement: 'div', validClasses: [ 'input-text' ], invalidClasses: [ 'input-text', 'has-error' ], @@ -91,6 +94,7 @@ export const appearanceSelectors = { appendTarget: '.cart .quantity', upeThemeInputSelector: '.cart .quantity .qty', upeThemeLabelSelector: '.cart .quantity label', + upeThemeTextSelector: '.cart .quantity', rowElement: 'div', validClasses: [ 'input-text' ], invalidClasses: [ 'input-text', 'has-error' ], @@ -111,6 +115,7 @@ export const appearanceSelectors = { upeThemeInputSelector: '.wc-block-cart .wc-block-components-quantity-selector .wc-block-components-quantity-selector__input', upeThemeLabelSelector: '.wc-block-components-text-input', + upeThemeTextSelector: '.wc-block-components-text-input', rowElement: 'div', validClasses: [ 'wc-block-components-text-input' ], invalidClasses: [ 'wc-block-components-text-input', 'has-error' ], @@ -133,6 +138,7 @@ export const appearanceSelectors = { appendTarget: '.woocommerce-billing-fields__field-wrapper', upeThemeInputSelector: '#billing_first_name', upeThemeLabelSelector: '.woocommerce-checkout .form-row label', + upeThemeTextSelector: '.woocommerce-checkout .form-row', rowElement: 'p', validClasses: [ 'form-row' ], invalidClasses: [ @@ -476,6 +482,11 @@ export const getAppearance = ( elementsLocation, forWooPay = false ) => { '.Label' ); + const paragraphRules = getFieldStyles( + selectors.upeThemeTextSelector, + '.Text' + ); + const tabRules = getFieldStyles( selectors.upeThemeInputSelector, '.Tab' ); const selectedTabRules = getFieldStyles( selectors.hiddenInput, @@ -505,9 +516,9 @@ export const getAppearance = ( elementsLocation, forWooPay = false ) => { ); const globalRules = { colorBackground: backgroundColor, - colorText: labelRules.color, - fontFamily: labelRules.fontFamily, - fontSizeBase: labelRules.fontSize, + colorText: paragraphRules.color, + fontFamily: paragraphRules.fontFamily, + fontSizeBase: paragraphRules.fontSize, }; const isFloatingLabel = elementsLocation === 'blocks_checkout'; @@ -528,8 +539,8 @@ export const getAppearance = ( elementsLocation, forWooPay = false ) => { '.Tab--selected': selectedTabRules, '.TabIcon:hover': tabIconHoverRules, '.TabIcon--selected': selectedTabIconRules, - '.Text': labelRules, - '.Text--redirect': labelRules, + '.Text': paragraphRules, + '.Text--redirect': paragraphRules, } ) ), }; diff --git a/client/checkout/upe-styles/upe-styles.js b/client/checkout/upe-styles/upe-styles.js index fda1c987f09..b578960317e 100644 --- a/client/checkout/upe-styles/upe-styles.js +++ b/client/checkout/upe-styles/upe-styles.js @@ -55,6 +55,7 @@ const borderOutlineBackgroundProps = [ ]; const upeSupportedProperties = { '.Label': [ ...paddingColorProps, ...textFontTransitionProps ], + '.Text': [ ...paddingColorProps, ...textFontTransitionProps ], '.Input': [ ...paddingColorProps, ...textFontTransitionProps, @@ -112,4 +113,6 @@ export const upeRestrictedProperties = { '.TabLabel': upeSupportedProperties[ '.TabLabel' ], '.Block': upeSupportedProperties[ '.Block' ], '.Container': upeSupportedProperties[ '.Container' ], + '.Text': upeSupportedProperties[ '.Text' ], + '.Text--redirect': upeSupportedProperties[ '.Text' ], }; From 6012025f79d8343dbba852e4fbc444011e72fbb0 Mon Sep 17 00:00:00 2001 From: Alefe Souza Date: Fri, 29 Nov 2024 02:10:28 -0300 Subject: [PATCH 6/8] Fix WooPay component spacing (#9748) --- changelog/fix-woopay-component-spacing | 4 ++ client/checkout/blocks/style.scss | 2 - client/checkout/woopay/index.js | 2 - .../save-user/checkout-page-save-user.js | 16 +------ .../components/woopay/save-user/container.js | 12 +---- client/components/woopay/save-user/style.scss | 44 ------------------- 6 files changed, 7 insertions(+), 73 deletions(-) create mode 100644 changelog/fix-woopay-component-spacing diff --git a/changelog/fix-woopay-component-spacing b/changelog/fix-woopay-component-spacing new file mode 100644 index 00000000000..0939c834ad9 --- /dev/null +++ b/changelog/fix-woopay-component-spacing @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix WooPay component spacing. diff --git a/client/checkout/blocks/style.scss b/client/checkout/blocks/style.scss index a6aa37953b3..3e400b6bfff 100644 --- a/client/checkout/blocks/style.scss +++ b/client/checkout/blocks/style.scss @@ -118,8 +118,6 @@ button.wcpay-stripelink-modal-trigger:hover { } #remember-me { - margin: 36px 0 0 0; - h2 { font-size: 18px; font-weight: 600; diff --git a/client/checkout/woopay/index.js b/client/checkout/woopay/index.js index f6c8902a514..51217c7aa30 100644 --- a/client/checkout/woopay/index.js +++ b/client/checkout/woopay/index.js @@ -46,8 +46,6 @@ const renderSaveUserSection = () => { checkoutPageSaveUserContainer, paymentOptions.nextSibling ); - - paymentOptions.classList.add( 'is-woopay' ); } } diff --git a/client/components/woopay/save-user/checkout-page-save-user.js b/client/components/woopay/save-user/checkout-page-save-user.js index f0563246552..45295c5c170 100644 --- a/client/components/woopay/save-user/checkout-page-save-user.js +++ b/client/components/woopay/save-user/checkout-page-save-user.js @@ -26,7 +26,6 @@ import request from '../../../checkout/utils/request'; import useSelectedPaymentMethod from '../hooks/use-selected-payment-method'; import { recordUserEvent } from 'tracks'; import './style.scss'; -import { compare } from 'compare-versions'; const CheckoutPageSaveUser = ( { isBlocksCheckout } ) => { const errorId = 'invalid-woopay-phone-number'; @@ -57,12 +56,6 @@ const CheckoutPageSaveUser = ( { isBlocksCheckout } ) => { ); const viewportWidth = window.document.documentElement.clientWidth; const viewportHeight = window.document.documentElement.clientHeight; - const wooCommerceVersionString = window.wcSettings?.wcVersion; - const wcVersionGreaterThan91 = compare( - wooCommerceVersionString, - '9.1', - '>=' - ); useEffect( () => { if ( ! isBlocksCheckout ) { @@ -291,10 +284,7 @@ const CheckoutPageSaveUser = ( { isBlocksCheckout } ) => { } return ( - +
{ id="save_user_in_woopay" value="true" className={ `save-details-checkbox ${ - wcVersionGreaterThan91 - ? 'without-margin-right' - : '' - } ${ isBlocksCheckout ? 'wc-block-components-checkbox__input' : '' diff --git a/client/components/woopay/save-user/container.js b/client/components/woopay/save-user/container.js index 470103044ac..7a032fe795f 100644 --- a/client/components/woopay/save-user/container.js +++ b/client/components/woopay/save-user/container.js @@ -3,19 +3,11 @@ */ import { __ } from '@wordpress/i18n'; -const Container = ( { - children, - isBlocksCheckout, - wcVersionGreaterThan91, -} ) => { +const Container = ( { children, isBlocksCheckout } ) => { if ( ! isBlocksCheckout ) return children; return ( <> -
+

{ __( 'Save my info' ) }

{ children }
diff --git a/client/components/woopay/save-user/style.scss b/client/components/woopay/save-user/style.scss index 8561cd4e62b..0e07ed4d611 100644 --- a/client/components/woopay/save-user/style.scss +++ b/client/components/woopay/save-user/style.scss @@ -7,37 +7,6 @@ } } -.is-mobile, -.is-small { - .woopay-save-new-user-container.wc-version-greater-than-91::after { - background: currentColor; - box-shadow: -50vw 0 0 0 currentColor, 50vw 0 0 0 currentColor; - content: ''; - height: 1px; - opacity: 0.11; - width: 100%; - margin-top: 22px; - } -} - -.is-medium, -.is-large { - .woopay-save-new-user-container.wc-version-greater-than-91 { - border-bottom: 1px solid hsla( 0, 0%, 7%, 0.11 ); - margin-bottom: 48px; - } -} - -@media ( max-width: 600px ) { - .is-mobile, - .is-small { - .wc-block-components-form - .wc-block-components-checkout-step.is-woopay::after { - height: 0; - } - } -} - .woopay-save-new-user-container { .save-details { .wc-block-components-text-input input:-webkit-autofill { @@ -45,15 +14,6 @@ } } - &.wc-version-greater-than-91 { - @media ( min-width: 601px ), - ( min-width: 566px ) and ( max-width: 568px ) { - .save-details { - margin-bottom: 48px; - } - } - } - .save-details-header { display: flex; align-items: flex-start; @@ -87,10 +47,6 @@ text-indent: 0; } - input:not( .without-margin-right ) { - margin-right: $gap-small; - } - span { @include breakpoint( '>960px' ) { margin-right: 1.25rem; From b0b67af4f0e478dbacbd33439b82116780bbf1b4 Mon Sep 17 00:00:00 2001 From: Nagesh Pai <4162931+nagpai@users.noreply.github.com> Date: Fri, 29 Nov 2024 17:17:32 +0530 Subject: [PATCH 7/8] Payouts: Add payout bank reference key to payout reports and CSV (#9832) Co-authored-by: Nagesh Pai --- changelog/add-5316-payout-trace-id | 4 + client/deposits/list/index.tsx | 9 ++ .../list/test/__snapshots__/index.tsx.snap | 104 ++++++++++++++++++ client/deposits/list/test/index.tsx | 7 ++ client/types/deposits.d.ts | 10 +- 5 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 changelog/add-5316-payout-trace-id diff --git a/changelog/add-5316-payout-trace-id b/changelog/add-5316-payout-trace-id new file mode 100644 index 00000000000..a5e90413a86 --- /dev/null +++ b/changelog/add-5316-payout-trace-id @@ -0,0 +1,4 @@ +Significance: minor +Type: add + +Add Bank reference key column in Payout reports. This will help reconcile WooPayments Payouts with bank statements. diff --git a/client/deposits/list/index.tsx b/client/deposits/list/index.tsx index c991e7e7ec3..b74c14bca61 100644 --- a/client/deposits/list/index.tsx +++ b/client/deposits/list/index.tsx @@ -97,6 +97,11 @@ const getColumns = ( sortByDate?: boolean ): DepositsTableHeader[] => [ screenReaderLabel: __( 'Bank account', 'woocommerce-payments' ), isLeftAligned: true, }, + { + key: 'bankReferenceKey', + label: __( 'Bank reference key', 'woocommerce-payments' ), + screenReaderLabel: __( 'Bank reference key', 'woocommerce-payments' ), + }, ]; export const DepositsList = (): JSX.Element => { @@ -165,6 +170,10 @@ export const DepositsList = (): JSX.Element => { value: deposit.bankAccount, display: clickable( deposit.bankAccount ), }, + bankReferenceKey: { + value: deposit.bank_reference_key, + display: clickable( deposit.bank_reference_key ?? 'N/A' ), + }, }; return columns.map( ( { key } ) => data[ key ] || { display: null } ); diff --git a/client/deposits/list/test/__snapshots__/index.tsx.snap b/client/deposits/list/test/__snapshots__/index.tsx.snap index 86e84ecd1d1..9e15ae2f735 100644 --- a/client/deposits/list/test/__snapshots__/index.tsx.snap +++ b/client/deposits/list/test/__snapshots__/index.tsx.snap @@ -313,6 +313,22 @@ exports[`Deposits list renders correctly a single deposit 1`] = ` Bank account + + + + Bank reference key + + + + + mock_reference_key + + + + + mock_reference_key + + + + + mock_reference_key + + @@ -949,6 +1001,22 @@ exports[`Deposits list renders correctly with multiple currencies 1`] = ` Bank account + + + + Bank reference key + + + + + mock_reference_key + + + + + mock_reference_key + + + + + mock_reference_key + + diff --git a/client/deposits/list/test/index.tsx b/client/deposits/list/test/index.tsx index d70561fb6d4..628dc670346 100644 --- a/client/deposits/list/test/index.tsx +++ b/client/deposits/list/test/index.tsx @@ -53,6 +53,7 @@ const mockDeposits = [ status: 'paid', bankAccount: 'MOCK BANK •••• 1234 (USD)', currency: 'USD', + bank_reference_key: 'mock_reference_key', } as CachedDeposit, { id: 'po_mock2', @@ -62,6 +63,7 @@ const mockDeposits = [ status: 'pending', bankAccount: 'MOCK BANK •••• 1234 (USD)', currency: 'USD', + bank_reference_key: 'mock_reference_key', } as CachedDeposit, { id: 'po_mock3', @@ -71,6 +73,7 @@ const mockDeposits = [ status: 'paid', bankAccount: 'MOCK BANK •••• 1234 (USD)', currency: 'USD', + bank_reference_key: 'mock_reference_key', } as CachedDeposit, ]; @@ -287,6 +290,7 @@ describe( 'Deposits list', () => { 'Amount', 'Status', '"Bank account"', + '"Bank reference key"', ]; const csvContent = mockDownloadCSVFile.mock.calls[ 0 ][ 1 ]; @@ -332,6 +336,9 @@ describe( 'Deposits list', () => { expect( csvFirstDeposit[ 5 ] ).toBe( `"${ displayFirstDeposit[ 4 ] }"` ); // bank account + expect( csvFirstDeposit[ 6 ] ).toBe( + `${ displayFirstDeposit[ 5 ] }` + ); // bank reference key } ); test( 'should fetch export after confirmation when download button is selected for unfiltered exports larger than 1000.', async () => { diff --git a/client/types/deposits.d.ts b/client/types/deposits.d.ts index ce749a58c30..29ebb263977 100644 --- a/client/types/deposits.d.ts +++ b/client/types/deposits.d.ts @@ -2,7 +2,14 @@ import { TableCardColumn } from '@woocommerce/components'; export interface DepositsTableHeader extends TableCardColumn { - key: 'details' | 'date' | 'type' | 'amount' | 'status' | 'bankAccount'; + key: + | 'details' + | 'date' + | 'type' + | 'amount' + | 'status' + | 'bankAccount' + | 'bankReferenceKey'; cellClassName?: string; } @@ -24,6 +31,7 @@ export interface CachedDeposit { status: DepositStatus; bankAccount: string; automatic: boolean; + bank_reference_key: string; } export interface DepositsSummaryCache { From e0b69be0612c1acf761e65357c38eaec16fc5d7c Mon Sep 17 00:00:00 2001 From: Rafael Zaleski Date: Fri, 29 Nov 2024 15:51:59 -0300 Subject: [PATCH 8/8] Ensure ECE button load events are triggered for multiple buttons on the same page (#9845) --- .../fix-9795-debounce-of-ece-load-events | 4 ++ client/express-checkout/tracking.js | 41 +++++++++++-------- client/tokenized-express-checkout/tracking.js | 41 +++++++++++-------- 3 files changed, 54 insertions(+), 32 deletions(-) create mode 100644 changelog/fix-9795-debounce-of-ece-load-events diff --git a/changelog/fix-9795-debounce-of-ece-load-events b/changelog/fix-9795-debounce-of-ece-load-events new file mode 100644 index 00000000000..f3d98c66136 --- /dev/null +++ b/changelog/fix-9795-debounce-of-ece-load-events @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Ensure ECE button load events are triggered for multiple buttons on the same page. diff --git a/client/express-checkout/tracking.js b/client/express-checkout/tracking.js index 862f6fc587e..b7bfd800a17 100644 --- a/client/express-checkout/tracking.js +++ b/client/express-checkout/tracking.js @@ -17,20 +17,29 @@ export const trackExpressCheckoutButtonClick = ( paymentMethod, source ) => { recordUserEvent( event, { source } ); }; +const debouncedTrackApplePayButtonLoad = debounce( ( { source } ) => { + recordUserEvent( 'applepay_button_load', { source } ); +}, 1000 ); + +const debouncedTrackGooglePayButtonLoad = debounce( ( { source } ) => { + recordUserEvent( 'gpay_button_load', { source } ); +}, 1000 ); + // Track the button load event. -export const trackExpressCheckoutButtonLoad = debounce( - ( { paymentMethods, source } ) => { - const expressPaymentTypeEvents = { - googlePay: 'gpay_button_load', - applePay: 'applepay_button_load', - }; - - for ( const paymentMethod of paymentMethods ) { - const event = expressPaymentTypeEvents[ paymentMethod ]; - if ( ! event ) continue; - - recordUserEvent( event, { source } ); - } - }, - 1000 -); +export const trackExpressCheckoutButtonLoad = ( { + paymentMethods, + source, +} ) => { + const expressPaymentTypeEvents = { + googlePay: debouncedTrackGooglePayButtonLoad, + applePay: debouncedTrackApplePayButtonLoad, + }; + + for ( const paymentMethod of paymentMethods ) { + const debouncedTrackFunction = + expressPaymentTypeEvents[ paymentMethod ]; + if ( ! debouncedTrackFunction ) continue; + + debouncedTrackFunction( { source } ); + } +}; diff --git a/client/tokenized-express-checkout/tracking.js b/client/tokenized-express-checkout/tracking.js index 862f6fc587e..b7bfd800a17 100644 --- a/client/tokenized-express-checkout/tracking.js +++ b/client/tokenized-express-checkout/tracking.js @@ -17,20 +17,29 @@ export const trackExpressCheckoutButtonClick = ( paymentMethod, source ) => { recordUserEvent( event, { source } ); }; +const debouncedTrackApplePayButtonLoad = debounce( ( { source } ) => { + recordUserEvent( 'applepay_button_load', { source } ); +}, 1000 ); + +const debouncedTrackGooglePayButtonLoad = debounce( ( { source } ) => { + recordUserEvent( 'gpay_button_load', { source } ); +}, 1000 ); + // Track the button load event. -export const trackExpressCheckoutButtonLoad = debounce( - ( { paymentMethods, source } ) => { - const expressPaymentTypeEvents = { - googlePay: 'gpay_button_load', - applePay: 'applepay_button_load', - }; - - for ( const paymentMethod of paymentMethods ) { - const event = expressPaymentTypeEvents[ paymentMethod ]; - if ( ! event ) continue; - - recordUserEvent( event, { source } ); - } - }, - 1000 -); +export const trackExpressCheckoutButtonLoad = ( { + paymentMethods, + source, +} ) => { + const expressPaymentTypeEvents = { + googlePay: debouncedTrackGooglePayButtonLoad, + applePay: debouncedTrackApplePayButtonLoad, + }; + + for ( const paymentMethod of paymentMethods ) { + const debouncedTrackFunction = + expressPaymentTypeEvents[ paymentMethod ]; + if ( ! debouncedTrackFunction ) continue; + + debouncedTrackFunction( { source } ); + } +};