From f6010a425ef2d3619c83441552a4fff58c6fcf6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Costa?= <10233985+cesarcosta99@users.noreply.github.com> Date: Fri, 20 Dec 2024 10:38:33 -0300 Subject: [PATCH 1/4] Show "postal code check" label based on store country (#9952) --- changelog/fix-9896-postal-code-label | 4 ++++ .../order-details/test/__snapshots__/index.test.tsx.snap | 2 +- client/payment-details/payment-method/card/index.js | 5 ++++- .../payment-details/test/__snapshots__/index.test.tsx.snap | 4 ++-- client/style.scss | 4 ++++ 5 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 changelog/fix-9896-postal-code-label diff --git a/changelog/fix-9896-postal-code-label b/changelog/fix-9896-postal-code-label new file mode 100644 index 00000000000..dad971912a8 --- /dev/null +++ b/changelog/fix-9896-postal-code-label @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Localize postal code check label based on country. diff --git a/client/payment-details/order-details/test/__snapshots__/index.test.tsx.snap b/client/payment-details/order-details/test/__snapshots__/index.test.tsx.snap index a1af47f03c4..ed6c9656178 100644 --- a/client/payment-details/order-details/test/__snapshots__/index.test.tsx.snap +++ b/client/payment-details/order-details/test/__snapshots__/index.test.tsx.snap @@ -613,7 +613,7 @@ exports[`Order details page should match the snapshot - Charge without payment i

- Zip check + Postal code check

{ diff --git a/client/payment-details/test/__snapshots__/index.test.tsx.snap b/client/payment-details/test/__snapshots__/index.test.tsx.snap index 19af9ff7235..feea948e950 100644 --- a/client/payment-details/test/__snapshots__/index.test.tsx.snap +++ b/client/payment-details/test/__snapshots__/index.test.tsx.snap @@ -485,7 +485,7 @@ exports[`Payment details page should match the snapshot - Charge query param 1`] aria-busy="true" class="is-loadable-placeholder is-block" > - Zip check + Postal code check

- Zip check + Postal code check

Date: Fri, 20 Dec 2024 16:35:13 +0200 Subject: [PATCH 2/4] Fix blank Overview page when WC onboarding is disabled (#10020) Co-authored-by: Cvetan Cvetanov --- changelog/fix-9742-blank-overview-page-without-wc-features | 4 ++++ client/onboarding/utils.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelog/fix-9742-blank-overview-page-without-wc-features diff --git a/changelog/fix-9742-blank-overview-page-without-wc-features b/changelog/fix-9742-blank-overview-page-without-wc-features new file mode 100644 index 00000000000..8d473bd8ab4 --- /dev/null +++ b/changelog/fix-9742-blank-overview-page-without-wc-features @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix blank Payments > Overview page when WC onboarding is disabled. diff --git a/client/onboarding/utils.ts b/client/onboarding/utils.ts index 306328f64f7..809c87a9927 100644 --- a/client/onboarding/utils.ts +++ b/client/onboarding/utils.ts @@ -140,7 +140,7 @@ export const isPoEligible = async ( * @return {string | undefined} The MCC code for the selected industry. Will return undefined if no industry is selected. */ export const getMccFromIndustry = (): string | undefined => { - const industry = wcSettings.admin.onboarding.profile.industry?.[ 0 ]; + const industry = wcSettings.admin?.onboarding?.profile?.industry?.[ 0 ]; if ( ! industry ) { return undefined; } From cd650bd4444cfb6487f05aa4238ae8b7d8044757 Mon Sep 17 00:00:00 2001 From: Malith Senaweera <6216000+malithsen@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:01:43 -0600 Subject: [PATCH 3/4] Show a beta badge next to WooPay theme checkbox (#10000) --- changelog/add-beta-badge-woopay-theme | 5 +++++ .../settings/express-checkout-settings/index.scss | 12 ++++++++++++ .../express-checkout-settings/woopay-settings.js | 15 +++++++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 changelog/add-beta-badge-woopay-theme diff --git a/changelog/add-beta-badge-woopay-theme b/changelog/add-beta-badge-woopay-theme new file mode 100644 index 00000000000..8d379077613 --- /dev/null +++ b/changelog/add-beta-badge-woopay-theme @@ -0,0 +1,5 @@ +Significance: patch +Type: add +Comment: Adds a label to a gated feature. + + diff --git a/client/settings/express-checkout-settings/index.scss b/client/settings/express-checkout-settings/index.scss index f57e1e973e7..7b6bd1ca1fe 100644 --- a/client/settings/express-checkout-settings/index.scss +++ b/client/settings/express-checkout-settings/index.scss @@ -58,6 +58,18 @@ } .woopay-settings { + &__badge { + background-color: $studio-gray-5; + padding: 0 8px; + border-radius: 2px; + font-size: 12px; + line-height: 20px; + margin-left: 4px; + } + &__global-theme-label { + display: inline-flex; + align-items: center; + } &__custom-message-wrapper { position: relative; diff --git a/client/settings/express-checkout-settings/woopay-settings.js b/client/settings/express-checkout-settings/woopay-settings.js index f2a4931f9f6..6f5b16baece 100644 --- a/client/settings/express-checkout-settings/woopay-settings.js +++ b/client/settings/express-checkout-settings/woopay-settings.js @@ -226,10 +226,17 @@ const WooPaySettings = ( { section } ) => { onChange={ updateIsWooPayGlobalThemeSupportEnabled } - label={ __( - 'Enable global theme support', - 'woocommerce-payments' - ) } + label={ +

+ { __( + 'Enable global theme support', + 'woocommerce-payments' + ) } + + Beta + +
+ } help={ interpolateComponents( { mixedString: __( 'When enabled, WooPay checkout will be themed with your store’s brand colors and fonts. ' + From 34e3731ed0424de26dc0cab68751c4c163d10247 Mon Sep 17 00:00:00 2001 From: Cvetan Cvetanov Date: Fri, 20 Dec 2024 18:03:58 +0200 Subject: [PATCH 4/4] Enable Payment Methods preselected by NOX after onboarding accounts (#10018) --- .../add-9973-enable-pms-from-capabilities | 4 + includes/class-wc-payments-account.php | 30 ++++++ .../class-wc-payments-onboarding-service.php | 92 +++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 changelog/add-9973-enable-pms-from-capabilities diff --git a/changelog/add-9973-enable-pms-from-capabilities b/changelog/add-9973-enable-pms-from-capabilities new file mode 100644 index 00000000000..5ecfd2ac5cd --- /dev/null +++ b/changelog/add-9973-enable-pms-from-capabilities @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Enable Payment Methods preselected by NOX after onboarding accounts diff --git a/includes/class-wc-payments-account.php b/includes/class-wc-payments-account.php index dc5430d6f0f..ebe3888afc5 100644 --- a/includes/class-wc-payments-account.php +++ b/includes/class-wc-payments-account.php @@ -2049,6 +2049,21 @@ private function init_stripe_onboarding( string $setup_mode, string $wcpay_conne $gateway->update_option( 'enabled', 'yes' ); $gateway->update_option( 'test_mode', empty( $onboarding_data['is_live'] ) ? 'yes' : 'no' ); + /** + * ================== + * Enforces the update of payment methods to 'enabled' based on the capabilities + * provided during the NOX onboarding process. + * + * @see WC_Payments_Onboarding_Service::update_enabled_payment_methods_ids + * ================== + */ + $capabilities = $this->onboarding_service->get_capabilities_from_request(); + + // Activate enabled Payment Methods IDs. + if ( ! empty( $capabilities ) ) { + $this->onboarding_service->update_enabled_payment_methods_ids( $gateway, $capabilities ); + } + // Store a state after completing KYC for tracks. This is stored temporarily in option because // user might not have agreed to TOS yet. update_option( '_wcpay_onboarding_stripe_connected', [ 'is_existing_stripe_account' => true ] ); @@ -2161,6 +2176,20 @@ private function finalize_connection( string $state, string $mode, array $additi $gateway->update_option( 'enabled', 'yes' ); $gateway->update_option( 'test_mode', 'live' !== $mode ? 'yes' : 'no' ); + /** + * ================== + * Enforces the update of payment methods to 'enabled' based on the capabilities + * provided during the NOX onboarding process. + * + * @see WC_Payments_Onboarding_Service::update_enabled_payment_methods_ids + * ================== + */ + $capabilities = $this->onboarding_service->get_capabilities_from_request(); + // Activate enabled Payment Methods IDs. + if ( ! empty( $capabilities ) ) { + $this->onboarding_service->update_enabled_payment_methods_ids( $gateway, $capabilities ); + } + // Store a state after completing KYC for tracks. This is stored temporarily in option because // user might not have agreed to TOS yet. update_option( '_wcpay_onboarding_stripe_connected', [ 'is_existing_stripe_account' => false ] ); @@ -2570,6 +2599,7 @@ function (): array { ); } + /** * Send a Tracks event. * diff --git a/includes/class-wc-payments-onboarding-service.php b/includes/class-wc-payments-onboarding-service.php index 504ac3bd5e4..cd5fe83d348 100644 --- a/includes/class-wc-payments-onboarding-service.php +++ b/includes/class-wc-payments-onboarding-service.php @@ -277,6 +277,22 @@ public function create_embedded_kyc_session( array $self_assessment_data, bool $ ); $actioned_notes = self::get_actioned_notes(); + /** + * ================== + * Enforces the update of payment methods to 'enabled' based on the capabilities + * provided during the NOX onboarding process. + * + * @see self::update_enabled_payment_methods_ids + * ================== + */ + $capabilities = $this->get_capabilities_from_request(); + $gateway = WC_Payments::get_gateway(); + + // Activate enabled Payment Methods IDs. + if ( ! empty( $capabilities ) ) { + $this->update_enabled_payment_methods_ids( $gateway, $capabilities ); + } + try { $account_session = $this->payments_api_client->initialize_onboarding_embedded_kyc( 'live' === $setup_mode, @@ -1024,4 +1040,80 @@ public function maybe_add_test_drive_settings_to_new_account_request( array $arg return $args; } + + /** + * Update payment methods to 'enabled' based on the capabilities + * provided during the NOX onboarding process. Merchants can preselect their preferred + * payment methods as part of this flow. + * + * The capabilities are provided in the following format: + * + * [ + * 'card' => true, + * 'affirm' => true, + * ... + * ] + * + * @param WC_Payment_Gateway_WCPay $gateway Payment gateway instance. + * @param array $capabilities Provided capabilities. + */ + public function update_enabled_payment_methods_ids( $gateway, $capabilities = [] ): void { + $enabled_gateways = $gateway->get_upe_enabled_payment_method_ids(); + + $enabled_payment_methods = array_unique( + array_merge( + $enabled_gateways, + $this->exclude_placeholder_payment_methods( $capabilities ) + ) + ); + + // Update the gateway option. + $gateway->update_option( 'upe_enabled_payment_method_ids', $enabled_payment_methods ); + + /** + * Keeps the list of enabled payment method IDs synchronized between the default + * `woocommerce_woocommerce_payments_settings` and duplicates in individual gateway settings. + */ + foreach ( $enabled_payment_methods as $payment_method_id ) { + $payment_gateway = WC_Payments::get_payment_gateway_by_id( $payment_method_id ); + if ( $payment_gateway ) { + $payment_gateway->enable(); + $payment_gateway->update_option( 'upe_enabled_payment_method_ids', $enabled_payment_methods ); + } + } + + // If WooPay is enabled, update the gateway option. + if ( ! empty( $capabilities['woopay'] ) ) { + $gateway->update_is_woopay_enabled( true ); + } + + // If Apple Pay and Google Pay are disabled update the gateway option, + // otherwise they are enabled by default. + if ( empty( $capabilities['apple_google'] ) ) { + $gateway->update_option( 'payment_request', 'no' ); + } + } + + /** + * Excludes placeholder payment methods and removes duplicates. + * + * WooPay and Apple Pay & Google Pay are considered placeholder payment methods and are excluded. + * + * @param array $payment_methods Array of payment methods to process. + * + * @return array Filtered array of unique payment methods. + */ + private function exclude_placeholder_payment_methods( array $payment_methods ): array { + // Placeholder payment methods. + $excluded_methods = [ 'woopay', 'apple_google' ]; + + return array_filter( + array_unique( + array_keys( array_filter( $payment_methods ) ) + ), + function ( $payment_method ) use ( $excluded_methods ) { + return ! in_array( $payment_method, $excluded_methods, true ); + } + ); + } }