From f17cd9cffa1196788df13299615b7bc7facbd749 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 7 Jul 2024 12:08:17 +0000 Subject: [PATCH 01/10] Update version and add changelog entries for release 7.9.0 --- changelog.txt | 33 +++++++++++++++++ ...-compute-styles-on-add-payment-method-page | 4 --- .../add-8869-pay-for-order-support-in-ece | 4 --- changelog/add-8948-ece-telemetry-events | 4 --- ...51-support-style-settings-with-ece-buttons | 4 --- .../add-8986-post-message-fail-safe-fallback | 4 --- changelog/add-ece-button-radius-support | 4 --- changelog/as-8868-ece-product-page | 4 --- ...disable-woopay-rejected-suspended-accounts | 4 --- .../change-9025-no-printed-receipts-in-wcpay | 4 --- ...-7654-refactor-redirects-logic-in-payments | 4 --- ...ev-add-docker-support-for-local-mu-plugins | 5 --- ...v-migrate-affirm-afterpay-components-to-ts | 4 --- ...rb-blocks-implementation-to-tokenized-cart | 5 --- changelog/fix-5532-fix-compatibility-data | 4 --- changelog/fix-8220-instant-deposit-messaging | 4 --- ...-restrict-klarna-non-domestic-transactions | 4 --- changelog/fix-8781-transaction-search-fields | 4 --- ...-8782-transaction-list-data-filters-mobile | 4 --- .../fix-8863-duplicated-enqueued-scripts | 4 --- ...tokenized-prb-shortcode-cart-total-delayed | 4 --- changelog/fix-9035-disable-link-in-ece | 4 --- ...-the-checkout-form-with-an-invalid-address | 4 --- changelog/fix-empty-country-update | 4 --- .../fix-error-message-location-in-blocks | 4 --- .../fix-token-retrieval-per-payment-method | 4 --- changelog/fix-tokenized-cart-decimals-price | 4 --- ...-tokenized-cart-prbs-refund-amount-display | 4 --- .../fix-tokenized-cart-zero-decimal-currency | 5 --- .../fix-tokenized-payment-request-payment-fix | 4 --- changelog/fix-unnecessary-effect-reruns | 4 --- .../fix-woopay-direct-checkout-feature-check | 4 --- ...tions-fix-script-injection-vulnerabilities | 5 --- ...kreykjalin-8868-ece-cart-and-checkout-page | 4 --- ...prb-tokenized-cart-shortcode-cart-checkout | 4 --- .../revert-8901-update-route-param-validation | 4 --- changelog/update-8385-plugin-wporg-author | 5 --- ...-8972-save-payment-activity-preset-session | 5 --- .../update-8973-payment-activity-tooltips | 5 --- .../update-payment-activity-disputes-tooltip | 5 --- changelog/update-route-regex-validation | 4 --- changelog/update-speedup-phpunit-tests | 5 --- .../update-tracks-onboarding-events-props | 5 --- ...pdate-tracks-onboarding-events-props-take2 | 5 --- package-lock.json | 4 +-- package.json | 2 +- readme.txt | 35 ++++++++++++++++++- woocommerce-payments.php | 2 +- 48 files changed, 71 insertions(+), 188 deletions(-) delete mode 100644 changelog/add-8413-compute-styles-on-add-payment-method-page delete mode 100644 changelog/add-8869-pay-for-order-support-in-ece delete mode 100644 changelog/add-8948-ece-telemetry-events delete mode 100644 changelog/add-8951-support-style-settings-with-ece-buttons delete mode 100644 changelog/add-8986-post-message-fail-safe-fallback delete mode 100644 changelog/add-ece-button-radius-support delete mode 100644 changelog/as-8868-ece-product-page delete mode 100644 changelog/as-disable-woopay-rejected-suspended-accounts delete mode 100644 changelog/change-9025-no-printed-receipts-in-wcpay delete mode 100644 changelog/dev-7654-refactor-redirects-logic-in-payments delete mode 100644 changelog/dev-add-docker-support-for-local-mu-plugins delete mode 100644 changelog/dev-migrate-affirm-afterpay-components-to-ts delete mode 100644 changelog/feat-copy-prb-blocks-implementation-to-tokenized-cart delete mode 100644 changelog/fix-5532-fix-compatibility-data delete mode 100644 changelog/fix-8220-instant-deposit-messaging delete mode 100644 changelog/fix-8718-restrict-klarna-non-domestic-transactions delete mode 100644 changelog/fix-8781-transaction-search-fields delete mode 100644 changelog/fix-8782-transaction-list-data-filters-mobile delete mode 100644 changelog/fix-8863-duplicated-enqueued-scripts delete mode 100644 changelog/fix-9000-tokenized-prb-shortcode-cart-total-delayed delete mode 100644 changelog/fix-9035-disable-link-in-ece delete mode 100644 changelog/fix-9042-afterpay-wrong-error-message-displayed-in-the-checkout-form-with-an-invalid-address delete mode 100644 changelog/fix-empty-country-update delete mode 100644 changelog/fix-error-message-location-in-blocks delete mode 100644 changelog/fix-token-retrieval-per-payment-method delete mode 100644 changelog/fix-tokenized-cart-decimals-price delete mode 100644 changelog/fix-tokenized-cart-prbs-refund-amount-display delete mode 100644 changelog/fix-tokenized-cart-zero-decimal-currency delete mode 100644 changelog/fix-tokenized-payment-request-payment-fix delete mode 100644 changelog/fix-unnecessary-effect-reruns delete mode 100644 changelog/fix-woopay-direct-checkout-feature-check delete mode 100644 changelog/gh-actions-fix-script-injection-vulnerabilities delete mode 100644 changelog/kreykjalin-8868-ece-cart-and-checkout-page delete mode 100644 changelog/prb-tokenized-cart-shortcode-cart-checkout delete mode 100644 changelog/revert-8901-update-route-param-validation delete mode 100644 changelog/update-8385-plugin-wporg-author delete mode 100644 changelog/update-8972-save-payment-activity-preset-session delete mode 100644 changelog/update-8973-payment-activity-tooltips delete mode 100644 changelog/update-payment-activity-disputes-tooltip delete mode 100644 changelog/update-route-regex-validation delete mode 100644 changelog/update-speedup-phpunit-tests delete mode 100644 changelog/update-tracks-onboarding-events-props delete mode 100644 changelog/update-tracks-onboarding-events-props-take2 diff --git a/changelog.txt b/changelog.txt index b0951f1cd02..f2ac74aa9f4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,38 @@ *** WooPayments Changelog *** += 7.9.0 - 2024-07-10 = +* Add - Add a separate transient to save UPE appearance styles for the Add Payment Method standalone page. Correct regression that prevented proper styles calculation in the shortcode checkout. +* Add - Add Pay for Order support in Express Checkout Elements. +* Add - Add support for configuring button radius when ECE is enabled +* Add - Add support for ECE elements on the Shortcode Cart and Checkout pages +* Add - Add support for the Express Checkout Element on product pages. +* Add - Add telemetry events from PRBs into ECE. +* Add - Ensure shoppers can still checkout, even when WooPay is slow or unavailable. +* Add - feat: tokenized cart PRBs on shortcode cart and checkout behind feature flag. +* Add - Support style settings for ECE buttons +* Fix - Clearly display available instant deposit amount on notice and button label on Payment Overview page +* Fix - Disable Stripe Link in ECE. +* Fix - Disable WooPay for suspended and rejected accounts. +* Fix - Display an invalid address error instead of generic one in the checkout form when Afterpay is selected as payment method +* Fix - Display payment error message in the Payment context with Blocks. +* Fix - fix: display refund amount w/ tokenized cart PRBs +* Fix - fix: pricing decimal formatting for tokenized cart +* Fix - fix: tokenized PRBs payment type +* Fix - Fixed an error when renewing subscriptions without a billing country +* Fix - Fix output for compatibility data. +* Fix - Fix transaction list and document list advanced filter styling issue preventing dates to be input on mobile screens. +* Fix - Fix WooPay Direct Checkout feature check. +* Fix - Fix WooPay OTP modal not rendering on the shortcode checkout if BNPL methods are available. +* Fix - Hide payment methods with domestic transactions restrictions (Klarna, Affirm, Afterpay) when conditions are not met. +* Fix - Make the search box, and typed search term visible clearly on the 'Payments > Transactions' page, when there are too many existing search tags. +* Fix - Properly wait for tokenized cart data updates before refreshing PRB data. +* Fix - Retrieve saved tokens only relevant for the specific payment gateway. +* Update - Update payment receipt settings to remove mention of the printed receipts. +* Dev - Add validation for path variables. +* Dev - Migrate Affirm and Afterpay payment method components to TypeScript. +* Dev - Prevent infinite loop in usePaymentFailHandler effect +* Dev - Refactor redirects logic in payments + = 7.8.1 - 2024-06-25 = * Fix - Fix "Dispute not loaded" error that was affecting responding to disputes. diff --git a/changelog/add-8413-compute-styles-on-add-payment-method-page b/changelog/add-8413-compute-styles-on-add-payment-method-page deleted file mode 100644 index 4c51615aba1..00000000000 --- a/changelog/add-8413-compute-styles-on-add-payment-method-page +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: add - -Add a separate transient to save UPE appearance styles for the Add Payment Method standalone page. Correct regression that prevented proper styles calculation in the shortcode checkout. diff --git a/changelog/add-8869-pay-for-order-support-in-ece b/changelog/add-8869-pay-for-order-support-in-ece deleted file mode 100644 index ddf5cba6463..00000000000 --- a/changelog/add-8869-pay-for-order-support-in-ece +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: add - -Add Pay for Order support in Express Checkout Elements. diff --git a/changelog/add-8948-ece-telemetry-events b/changelog/add-8948-ece-telemetry-events deleted file mode 100644 index 51a4cc03c24..00000000000 --- a/changelog/add-8948-ece-telemetry-events +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: add - -Add telemetry events from PRBs into ECE. diff --git a/changelog/add-8951-support-style-settings-with-ece-buttons b/changelog/add-8951-support-style-settings-with-ece-buttons deleted file mode 100644 index acb0ba496fd..00000000000 --- a/changelog/add-8951-support-style-settings-with-ece-buttons +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: add - -Support style settings for ECE buttons diff --git a/changelog/add-8986-post-message-fail-safe-fallback b/changelog/add-8986-post-message-fail-safe-fallback deleted file mode 100644 index f59357501a0..00000000000 --- a/changelog/add-8986-post-message-fail-safe-fallback +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: add - -Ensure shoppers can still checkout, even when WooPay is slow or unavailable. diff --git a/changelog/add-ece-button-radius-support b/changelog/add-ece-button-radius-support deleted file mode 100644 index 214a2da3696..00000000000 --- a/changelog/add-ece-button-radius-support +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: add - -Add support for configuring button radius when ECE is enabled diff --git a/changelog/as-8868-ece-product-page b/changelog/as-8868-ece-product-page deleted file mode 100644 index 25a57735f4c..00000000000 --- a/changelog/as-8868-ece-product-page +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: add - -Add support for the Express Checkout Element on product pages. diff --git a/changelog/as-disable-woopay-rejected-suspended-accounts b/changelog/as-disable-woopay-rejected-suspended-accounts deleted file mode 100644 index 5c5d37f068f..00000000000 --- a/changelog/as-disable-woopay-rejected-suspended-accounts +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: fix - -Disable WooPay for suspended and rejected accounts. diff --git a/changelog/change-9025-no-printed-receipts-in-wcpay b/changelog/change-9025-no-printed-receipts-in-wcpay deleted file mode 100644 index 6829af078d5..00000000000 --- a/changelog/change-9025-no-printed-receipts-in-wcpay +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: update - -Update payment receipt settings to remove mention of the printed receipts. diff --git a/changelog/dev-7654-refactor-redirects-logic-in-payments b/changelog/dev-7654-refactor-redirects-logic-in-payments deleted file mode 100644 index 988c5ba661e..00000000000 --- a/changelog/dev-7654-refactor-redirects-logic-in-payments +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: dev - -Refactor redirects logic in payments diff --git a/changelog/dev-add-docker-support-for-local-mu-plugins b/changelog/dev-add-docker-support-for-local-mu-plugins deleted file mode 100644 index 102e2171756..00000000000 --- a/changelog/dev-add-docker-support-for-local-mu-plugins +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: dev -Comment: Add support for mu-plugins. - - diff --git a/changelog/dev-migrate-affirm-afterpay-components-to-ts b/changelog/dev-migrate-affirm-afterpay-components-to-ts deleted file mode 100644 index d60541e795d..00000000000 --- a/changelog/dev-migrate-affirm-afterpay-components-to-ts +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: dev - -Migrate Affirm and Afterpay payment method components to TypeScript. diff --git a/changelog/feat-copy-prb-blocks-implementation-to-tokenized-cart b/changelog/feat-copy-prb-blocks-implementation-to-tokenized-cart deleted file mode 100644 index 8a16761aea4..00000000000 --- a/changelog/feat-copy-prb-blocks-implementation-to-tokenized-cart +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: dev -Comment: chore: copy PRB blocks to tokenized cart - - diff --git a/changelog/fix-5532-fix-compatibility-data b/changelog/fix-5532-fix-compatibility-data deleted file mode 100644 index 3580c21dd74..00000000000 --- a/changelog/fix-5532-fix-compatibility-data +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fix - -Fix output for compatibility data. diff --git a/changelog/fix-8220-instant-deposit-messaging b/changelog/fix-8220-instant-deposit-messaging deleted file mode 100644 index 15a6be38a63..00000000000 --- a/changelog/fix-8220-instant-deposit-messaging +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fix - -Clearly display available instant deposit amount on notice and button label on Payment Overview page diff --git a/changelog/fix-8718-restrict-klarna-non-domestic-transactions b/changelog/fix-8718-restrict-klarna-non-domestic-transactions deleted file mode 100644 index 60e4a65fba4..00000000000 --- a/changelog/fix-8718-restrict-klarna-non-domestic-transactions +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: fix - -Hide payment methods with domestic transactions restrictions (Klarna, Affirm, Afterpay) when conditions are not met. diff --git a/changelog/fix-8781-transaction-search-fields b/changelog/fix-8781-transaction-search-fields deleted file mode 100644 index ef142316156..00000000000 --- a/changelog/fix-8781-transaction-search-fields +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fix - -Make the search box, and typed search term visible clearly on the 'Payments > Transactions' page, when there are too many existing search tags. diff --git a/changelog/fix-8782-transaction-list-data-filters-mobile b/changelog/fix-8782-transaction-list-data-filters-mobile deleted file mode 100644 index f21f288da32..00000000000 --- a/changelog/fix-8782-transaction-list-data-filters-mobile +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fix - -Fix transaction list and document list advanced filter styling issue preventing dates to be input on mobile screens. diff --git a/changelog/fix-8863-duplicated-enqueued-scripts b/changelog/fix-8863-duplicated-enqueued-scripts deleted file mode 100644 index 1f27da5b3aa..00000000000 --- a/changelog/fix-8863-duplicated-enqueued-scripts +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: fix - -Fix WooPay OTP modal not rendering on the shortcode checkout if BNPL methods are available. diff --git a/changelog/fix-9000-tokenized-prb-shortcode-cart-total-delayed b/changelog/fix-9000-tokenized-prb-shortcode-cart-total-delayed deleted file mode 100644 index dbc646e6e8a..00000000000 --- a/changelog/fix-9000-tokenized-prb-shortcode-cart-total-delayed +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: fix - -Properly wait for tokenized cart data updates before refreshing PRB data. diff --git a/changelog/fix-9035-disable-link-in-ece b/changelog/fix-9035-disable-link-in-ece deleted file mode 100644 index d15fc4e308b..00000000000 --- a/changelog/fix-9035-disable-link-in-ece +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: fix - -Disable Stripe Link in ECE. diff --git a/changelog/fix-9042-afterpay-wrong-error-message-displayed-in-the-checkout-form-with-an-invalid-address b/changelog/fix-9042-afterpay-wrong-error-message-displayed-in-the-checkout-form-with-an-invalid-address deleted file mode 100644 index d9eb6619a20..00000000000 --- a/changelog/fix-9042-afterpay-wrong-error-message-displayed-in-the-checkout-form-with-an-invalid-address +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fix - -Display an invalid address error instead of generic one in the checkout form when Afterpay is selected as payment method diff --git a/changelog/fix-empty-country-update b/changelog/fix-empty-country-update deleted file mode 100644 index 00eea28529a..00000000000 --- a/changelog/fix-empty-country-update +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fix - -Fixed an error when renewing subscriptions without a billing country diff --git a/changelog/fix-error-message-location-in-blocks b/changelog/fix-error-message-location-in-blocks deleted file mode 100644 index ff40aaa06a9..00000000000 --- a/changelog/fix-error-message-location-in-blocks +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: fix - -Display payment error message in the Payment context with Blocks. diff --git a/changelog/fix-token-retrieval-per-payment-method b/changelog/fix-token-retrieval-per-payment-method deleted file mode 100644 index 1ec9a65c246..00000000000 --- a/changelog/fix-token-retrieval-per-payment-method +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: fix - -Retrieve saved tokens only relevant for the specific payment gateway. diff --git a/changelog/fix-tokenized-cart-decimals-price b/changelog/fix-tokenized-cart-decimals-price deleted file mode 100644 index ba840696aff..00000000000 --- a/changelog/fix-tokenized-cart-decimals-price +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fix - -fix: pricing decimal formatting for tokenized cart diff --git a/changelog/fix-tokenized-cart-prbs-refund-amount-display b/changelog/fix-tokenized-cart-prbs-refund-amount-display deleted file mode 100644 index 35888567403..00000000000 --- a/changelog/fix-tokenized-cart-prbs-refund-amount-display +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fix - -fix: display refund amount w/ tokenized cart PRBs diff --git a/changelog/fix-tokenized-cart-zero-decimal-currency b/changelog/fix-tokenized-cart-zero-decimal-currency deleted file mode 100644 index 887eaef6d70..00000000000 --- a/changelog/fix-tokenized-cart-zero-decimal-currency +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: fix -Comment: fix: tokenized PRB with zero decimal currency - - diff --git a/changelog/fix-tokenized-payment-request-payment-fix b/changelog/fix-tokenized-payment-request-payment-fix deleted file mode 100644 index 97d02a7abf8..00000000000 --- a/changelog/fix-tokenized-payment-request-payment-fix +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fix - -fix: tokenized PRBs payment type diff --git a/changelog/fix-unnecessary-effect-reruns b/changelog/fix-unnecessary-effect-reruns deleted file mode 100644 index 76ae72f5168..00000000000 --- a/changelog/fix-unnecessary-effect-reruns +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: dev - -Prevent infinite loop in usePaymentFailHandler effect diff --git a/changelog/fix-woopay-direct-checkout-feature-check b/changelog/fix-woopay-direct-checkout-feature-check deleted file mode 100644 index b52e9e6e556..00000000000 --- a/changelog/fix-woopay-direct-checkout-feature-check +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fix - -Fix WooPay Direct Checkout feature check. diff --git a/changelog/gh-actions-fix-script-injection-vulnerabilities b/changelog/gh-actions-fix-script-injection-vulnerabilities deleted file mode 100644 index 3adabe1e3a2..00000000000 --- a/changelog/gh-actions-fix-script-injection-vulnerabilities +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: dev -Comment: Update direct usage of GitHub contexts on workflows - - diff --git a/changelog/kreykjalin-8868-ece-cart-and-checkout-page b/changelog/kreykjalin-8868-ece-cart-and-checkout-page deleted file mode 100644 index bdb4df869e3..00000000000 --- a/changelog/kreykjalin-8868-ece-cart-and-checkout-page +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: add - -Add support for ECE elements on the Shortcode Cart and Checkout pages diff --git a/changelog/prb-tokenized-cart-shortcode-cart-checkout b/changelog/prb-tokenized-cart-shortcode-cart-checkout deleted file mode 100644 index 1d93781761e..00000000000 --- a/changelog/prb-tokenized-cart-shortcode-cart-checkout +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: add - -feat: tokenized cart PRBs on shortcode cart and checkout behind feature flag. diff --git a/changelog/revert-8901-update-route-param-validation b/changelog/revert-8901-update-route-param-validation deleted file mode 100644 index 77bc7eaeee5..00000000000 --- a/changelog/revert-8901-update-route-param-validation +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fix - -Fix "Dispute not loaded" error that was affecting responding to disputes. diff --git a/changelog/update-8385-plugin-wporg-author b/changelog/update-8385-plugin-wporg-author deleted file mode 100644 index b3847e87826..00000000000 --- a/changelog/update-8385-plugin-wporg-author +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: update -Comment: Just changed the WP.org display author to WooCommerce. - - diff --git a/changelog/update-8972-save-payment-activity-preset-session b/changelog/update-8972-save-payment-activity-preset-session deleted file mode 100644 index 869e0b298e5..00000000000 --- a/changelog/update-8972-save-payment-activity-preset-session +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: update -Comment: Part of Payment Activity Card. Persist selected preset date in session. - - diff --git a/changelog/update-8973-payment-activity-tooltips b/changelog/update-8973-payment-activity-tooltips deleted file mode 100644 index defc9d3fdc3..00000000000 --- a/changelog/update-8973-payment-activity-tooltips +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: update -Comment: Part of Payment Activity Card. Improved tooltips. - - diff --git a/changelog/update-payment-activity-disputes-tooltip b/changelog/update-payment-activity-disputes-tooltip deleted file mode 100644 index 8dd12d04f8b..00000000000 --- a/changelog/update-payment-activity-disputes-tooltip +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: update -Comment: Payment Activity Card - minor improvement to tooltip. - - diff --git a/changelog/update-route-regex-validation b/changelog/update-route-regex-validation deleted file mode 100644 index 09e03df01d6..00000000000 --- a/changelog/update-route-regex-validation +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: dev - -Add validation for path variables. diff --git a/changelog/update-speedup-phpunit-tests b/changelog/update-speedup-phpunit-tests deleted file mode 100644 index db651399352..00000000000 --- a/changelog/update-speedup-phpunit-tests +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: dev -Comment: These changes only affect PHPUnit tests. - - diff --git a/changelog/update-tracks-onboarding-events-props b/changelog/update-tracks-onboarding-events-props deleted file mode 100644 index a1b8d03dbba..00000000000 --- a/changelog/update-tracks-onboarding-events-props +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: update -Comment: These changes are only related to Tracks events props updates. - - diff --git a/changelog/update-tracks-onboarding-events-props-take2 b/changelog/update-tracks-onboarding-events-props-take2 deleted file mode 100644 index b83c62d7f76..00000000000 --- a/changelog/update-tracks-onboarding-events-props-take2 +++ /dev/null @@ -1,5 +0,0 @@ -Significance: patch -Type: update -Comment: It is just about improving Tracks events data consistency. - - diff --git a/package-lock.json b/package-lock.json index c02183691cd..4fe8e9f7d14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "woocommerce-payments", - "version": "7.8.1", + "version": "7.9.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "woocommerce-payments", - "version": "7.8.1", + "version": "7.9.0", "hasInstallScript": true, "license": "GPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index ae3c8b791f0..c0dde30c0b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "woocommerce-payments", - "version": "7.8.1", + "version": "7.9.0", "main": "webpack.config.js", "author": "Automattic", "license": "GPL-3.0-or-later", diff --git a/readme.txt b/readme.txt index 45f5ac455d7..b30eb957881 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: woocommerce payments, apple pay, credit card, google pay, payment, payment Requires at least: 6.0 Tested up to: 6.5 Requires PHP: 7.3 -Stable tag: 7.8.1 +Stable tag: 7.9.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -94,6 +94,39 @@ Please note that our support for the checkout block is still experimental and th == Changelog == += 7.9.0 - 2024-07-10 = +* Add - Add a separate transient to save UPE appearance styles for the Add Payment Method standalone page. Correct regression that prevented proper styles calculation in the shortcode checkout. +* Add - Add Pay for Order support in Express Checkout Elements. +* Add - Add support for configuring button radius when ECE is enabled +* Add - Add support for ECE elements on the Shortcode Cart and Checkout pages +* Add - Add support for the Express Checkout Element on product pages. +* Add - Add telemetry events from PRBs into ECE. +* Add - Ensure shoppers can still checkout, even when WooPay is slow or unavailable. +* Add - feat: tokenized cart PRBs on shortcode cart and checkout behind feature flag. +* Add - Support style settings for ECE buttons +* Fix - Clearly display available instant deposit amount on notice and button label on Payment Overview page +* Fix - Disable Stripe Link in ECE. +* Fix - Disable WooPay for suspended and rejected accounts. +* Fix - Display an invalid address error instead of generic one in the checkout form when Afterpay is selected as payment method +* Fix - Display payment error message in the Payment context with Blocks. +* Fix - fix: display refund amount w/ tokenized cart PRBs +* Fix - fix: pricing decimal formatting for tokenized cart +* Fix - fix: tokenized PRBs payment type +* Fix - Fixed an error when renewing subscriptions without a billing country +* Fix - Fix output for compatibility data. +* Fix - Fix transaction list and document list advanced filter styling issue preventing dates to be input on mobile screens. +* Fix - Fix WooPay Direct Checkout feature check. +* Fix - Fix WooPay OTP modal not rendering on the shortcode checkout if BNPL methods are available. +* Fix - Hide payment methods with domestic transactions restrictions (Klarna, Affirm, Afterpay) when conditions are not met. +* Fix - Make the search box, and typed search term visible clearly on the 'Payments > Transactions' page, when there are too many existing search tags. +* Fix - Properly wait for tokenized cart data updates before refreshing PRB data. +* Fix - Retrieve saved tokens only relevant for the specific payment gateway. +* Update - Update payment receipt settings to remove mention of the printed receipts. +* Dev - Add validation for path variables. +* Dev - Migrate Affirm and Afterpay payment method components to TypeScript. +* Dev - Prevent infinite loop in usePaymentFailHandler effect +* Dev - Refactor redirects logic in payments + = 7.8.1 - 2024-06-25 = * Fix - Fix "Dispute not loaded" error that was affecting responding to disputes. diff --git a/woocommerce-payments.php b/woocommerce-payments.php index 51e29ba399c..995ffea0b58 100644 --- a/woocommerce-payments.php +++ b/woocommerce-payments.php @@ -11,7 +11,7 @@ * WC tested up to: 8.9.3 * Requires at least: 6.0 * Requires PHP: 7.3 - * Version: 7.8.1 + * Version: 7.9.0 * Requires Plugins: woocommerce * * @package WooCommerce\Payments From d483a1d76468c5807830280cc147c730d773a1e5 Mon Sep 17 00:00:00 2001 From: Nagesh Pai <4162931+nagpai@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:09:01 +0530 Subject: [PATCH 02/10] Reporting: Restore functioning of 'remove' button on last tag on transactions report search box (#9072) Co-authored-by: Nagesh Pai --- ...x-9071-transaction-search-tag-close-button | 5 +++ client/transactions/list/style.scss | 37 ++++++++++++------- 2 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 changelog/fix-9071-transaction-search-tag-close-button diff --git a/changelog/fix-9071-transaction-search-tag-close-button b/changelog/fix-9071-transaction-search-tag-close-button new file mode 100644 index 00000000000..a193fc639bc --- /dev/null +++ b/changelog/fix-9071-transaction-search-tag-close-button @@ -0,0 +1,5 @@ +Significance: patch +Type: fix +Comment: Restore the 'remove tag' function on the last search tag appearing on the transactions report search box. + + diff --git a/client/transactions/list/style.scss b/client/transactions/list/style.scss index 3788096bc00..45d8494de81 100644 --- a/client/transactions/list/style.scss +++ b/client/transactions/list/style.scss @@ -125,6 +125,25 @@ $gap-small: 12px; &.woocommerce-select-control__control { min-height: 38px; height: auto; + button.woocommerce-select-control__clear { + background-color: #fff; + + &::before { + content: ''; + position: absolute; + left: -30px; + top: -2px; + bottom: 0; + width: 30px; + height: 100%; + background: linear-gradient( + to right, + rgba( 255, 255, 255, 0 ), + rgba( 255, 255, 255, 1 ) 90% + ); + pointer-events: none; + } + } } } } @@ -171,20 +190,12 @@ $gap-small: 12px; white-space: nowrap; scrollbar-width: none; margin-right: 25px; + } - &::after { - content: ''; - position: absolute; - top: 0; - right: 0; - width: 25px; - height: 100%; - background: linear-gradient( - to right, - rgba( 255, 255, 255, 0 ), - rgba( 255, 255, 255, 1 ) 90% - ); - } + .woocommerce-select-control.is-focused + .components-base-control + .components-base-control__field { + flex-basis: 45%; } @include breakpoint( '<960px' ) { From d7e82afdf1caa68a1d3865909ebf57579accccae Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Tue, 9 Jul 2024 22:50:48 -0400 Subject: [PATCH 03/10] Deprecate Giropay (#9055) Co-authored-by: Guilherme Pressutto --- changelog/9037-giropay-deprecation | 4 + includes/class-wc-payment-gateway-wcpay.php | 1 - includes/class-wc-payments.php | 2 + ...ss-giropay-deprecation-settings-update.php | 89 +++++++++++++++++++ ...s-wc-rest-payments-settings-controller.php | 5 +- 5 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 changelog/9037-giropay-deprecation create mode 100644 includes/migrations/class-giropay-deprecation-settings-update.php diff --git a/changelog/9037-giropay-deprecation b/changelog/9037-giropay-deprecation new file mode 100644 index 00000000000..bcf9e81ece3 --- /dev/null +++ b/changelog/9037-giropay-deprecation @@ -0,0 +1,4 @@ +Significance: minor +Type: update + +Deprecate Giropay. diff --git a/includes/class-wc-payment-gateway-wcpay.php b/includes/class-wc-payment-gateway-wcpay.php index 8b38ef31643..c5126c398e0 100644 --- a/includes/class-wc-payment-gateway-wcpay.php +++ b/includes/class-wc-payment-gateway-wcpay.php @@ -4029,7 +4029,6 @@ public function get_upe_available_payment_methods() { $available_methods[] = Becs_Payment_Method::PAYMENT_METHOD_STRIPE_ID; $available_methods[] = Bancontact_Payment_Method::PAYMENT_METHOD_STRIPE_ID; $available_methods[] = Eps_Payment_Method::PAYMENT_METHOD_STRIPE_ID; - $available_methods[] = Giropay_Payment_Method::PAYMENT_METHOD_STRIPE_ID; $available_methods[] = Ideal_Payment_Method::PAYMENT_METHOD_STRIPE_ID; $available_methods[] = Sofort_Payment_Method::PAYMENT_METHOD_STRIPE_ID; $available_methods[] = Sepa_Payment_Method::PAYMENT_METHOD_STRIPE_ID; diff --git a/includes/class-wc-payments.php b/includes/class-wc-payments.php index b48a257ae2f..4f3edb6ad91 100644 --- a/includes/class-wc-payments.php +++ b/includes/class-wc-payments.php @@ -634,6 +634,7 @@ function () { require_once __DIR__ . '/migrations/class-link-woopay-mutual-exclusion-handler.php'; require_once __DIR__ . '/migrations/class-gateway-settings-sync.php'; require_once __DIR__ . '/migrations/class-delete-active-woopay-webhook.php'; + require_once __DIR__ . '/migrations/class-giropay-deprecation-settings-update.php'; add_action( 'woocommerce_woocommerce_payments_updated', [ new Allowed_Payment_Request_Button_Types_Update( self::get_gateway() ), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Allowed_Payment_Request_Button_Sizes_Update( self::get_gateway() ), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Update_Service_Data_From_Server( self::get_account_service() ), 'maybe_migrate' ] ); @@ -641,6 +642,7 @@ function () { add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Link_WooPay_Mutual_Exclusion_Handler( self::get_gateway() ), 'maybe_migrate' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Gateway_Settings_Sync( self::get_gateway(), self::get_payment_gateway_map() ), 'maybe_sync' ] ); add_action( 'woocommerce_woocommerce_payments_updated', [ '\WCPay\Migrations\Delete_Active_WooPay_Webhook', 'maybe_delete' ] ); + add_action( 'woocommerce_woocommerce_payments_updated', [ new \WCPay\Migrations\Giropay_Deprecation_Settings_Update( self::get_gateway(), self::get_payment_gateway_map() ), 'maybe_migrate' ] ); include_once WCPAY_ABSPATH . '/includes/class-wc-payments-explicit-price-formatter.php'; WC_Payments_Explicit_Price_Formatter::init(); diff --git a/includes/migrations/class-giropay-deprecation-settings-update.php b/includes/migrations/class-giropay-deprecation-settings-update.php new file mode 100644 index 00000000000..b5b2568eb97 --- /dev/null +++ b/includes/migrations/class-giropay-deprecation-settings-update.php @@ -0,0 +1,89 @@ +main_gateway = $main_gateway; + $this->all_registered_gateways = $all_registered_gateways; + } + + /** + * Checks whether we should trigger the event. + */ + public function maybe_migrate() { + $previous_version = get_option( 'woocommerce_woocommerce_payments_version' ); + if ( version_compare( self::VERSION_SINCE, $previous_version, '>' ) ) { + $this->migrate(); + } + } + + /** + * Syncs gateway setting objects. + */ + private function migrate() { + $enabled_payment_methods = $this->main_gateway->get_option( 'upe_enabled_payment_method_ids', [] ); + + $filtered_payment_methods = array_filter( + $enabled_payment_methods, + function ( $method ) { + return 'giropay' !== $method; + } + ); + + foreach ( $this->all_registered_gateways as $gateway ) { + if ( 'giropay' === $gateway->get_stripe_id() ) { + if ( in_array( $gateway->get_stripe_id(), $enabled_payment_methods, true ) ) { + $gateway->disable(); + $gateway->update_option( 'upe_enabled_payment_method_ids', $filtered_payment_methods ); + } else { + $gateway->update_option( 'upe_enabled_payment_method_ids', $filtered_payment_methods ); + } + } else { + $gateway->update_option( 'upe_enabled_payment_method_ids', $filtered_payment_methods ); + } + } + } +} diff --git a/tests/unit/admin/test-class-wc-rest-payments-settings-controller.php b/tests/unit/admin/test-class-wc-rest-payments-settings-controller.php index 5bf31255461..84c06290b80 100644 --- a/tests/unit/admin/test-class-wc-rest-payments-settings-controller.php +++ b/tests/unit/admin/test-class-wc-rest-payments-settings-controller.php @@ -244,7 +244,6 @@ public function test_get_settings_returns_available_payment_method_ids() { Payment_Method::BECS, Payment_Method::BANCONTACT, Payment_Method::EPS, - Payment_Method::GIROPAY, Payment_Method::IDEAL, Payment_Method::SOFORT, Payment_Method::SEPA, @@ -376,11 +375,11 @@ public function test_update_settings_saves_enabled_payment_methods() { WC_Payments::get_gateway()->update_option( 'upe_enabled_payment_method_ids', [ Payment_Method::CARD ] ); $request = new WP_REST_Request(); - $request->set_param( 'enabled_payment_method_ids', [ Payment_Method::CARD, Payment_Method::GIROPAY ] ); + $request->set_param( 'enabled_payment_method_ids', [ Payment_Method::CARD, Payment_Method::IDEAL ] ); $this->controller->update_settings( $request ); - $this->assertEquals( [ Payment_Method::CARD, Payment_Method::GIROPAY ], WC_Payments::get_gateway()->get_option( 'upe_enabled_payment_method_ids' ) ); + $this->assertEquals( [ Payment_Method::CARD, Payment_Method::IDEAL ], WC_Payments::get_gateway()->get_option( 'upe_enabled_payment_method_ids' ) ); } public function test_update_settings_fails_if_user_cannot_manage_woocommerce() { From 4b83ca4f080a049e2cc633e4fb74b0ab3ac1e0e8 Mon Sep 17 00:00:00 2001 From: Jesse Pearson Date: Wed, 10 Jul 2024 10:34:06 -0300 Subject: [PATCH 04/10] Update changelog and readme, delete file in changelog folder. --- changelog.txt | 1 + changelog/9037-giropay-deprecation | 4 ---- readme.txt | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 changelog/9037-giropay-deprecation diff --git a/changelog.txt b/changelog.txt index f2ac74aa9f4..a14c75d5f1d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -28,6 +28,7 @@ * Fix - Properly wait for tokenized cart data updates before refreshing PRB data. * Fix - Retrieve saved tokens only relevant for the specific payment gateway. * Update - Update payment receipt settings to remove mention of the printed receipts. +* Update - Deprecate Giropay. * Dev - Add validation for path variables. * Dev - Migrate Affirm and Afterpay payment method components to TypeScript. * Dev - Prevent infinite loop in usePaymentFailHandler effect diff --git a/changelog/9037-giropay-deprecation b/changelog/9037-giropay-deprecation deleted file mode 100644 index bcf9e81ece3..00000000000 --- a/changelog/9037-giropay-deprecation +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: update - -Deprecate Giropay. diff --git a/readme.txt b/readme.txt index b30eb957881..a49ffd9ded5 100644 --- a/readme.txt +++ b/readme.txt @@ -122,6 +122,7 @@ Please note that our support for the checkout block is still experimental and th * Fix - Properly wait for tokenized cart data updates before refreshing PRB data. * Fix - Retrieve saved tokens only relevant for the specific payment gateway. * Update - Update payment receipt settings to remove mention of the printed receipts. +* Update - Deprecate Giropay. * Dev - Add validation for path variables. * Dev - Migrate Affirm and Afterpay payment method components to TypeScript. * Dev - Prevent infinite loop in usePaymentFailHandler effect From b0f72ecf7249452ddcdff5dd19bd42326934b78d Mon Sep 17 00:00:00 2001 From: botwoo Date: Wed, 10 Jul 2024 13:42:08 +0000 Subject: [PATCH 05/10] Amend changelog entries for release 7.9.0 --- changelog.txt | 2 +- readme.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index a14c75d5f1d..6814467549c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -27,8 +27,8 @@ * Fix - Make the search box, and typed search term visible clearly on the 'Payments > Transactions' page, when there are too many existing search tags. * Fix - Properly wait for tokenized cart data updates before refreshing PRB data. * Fix - Retrieve saved tokens only relevant for the specific payment gateway. -* Update - Update payment receipt settings to remove mention of the printed receipts. * Update - Deprecate Giropay. +* Update - Update payment receipt settings to remove mention of the printed receipts. * Dev - Add validation for path variables. * Dev - Migrate Affirm and Afterpay payment method components to TypeScript. * Dev - Prevent infinite loop in usePaymentFailHandler effect diff --git a/readme.txt b/readme.txt index a49ffd9ded5..c7a56bcc596 100644 --- a/readme.txt +++ b/readme.txt @@ -121,8 +121,8 @@ Please note that our support for the checkout block is still experimental and th * Fix - Make the search box, and typed search term visible clearly on the 'Payments > Transactions' page, when there are too many existing search tags. * Fix - Properly wait for tokenized cart data updates before refreshing PRB data. * Fix - Retrieve saved tokens only relevant for the specific payment gateway. -* Update - Update payment receipt settings to remove mention of the printed receipts. * Update - Deprecate Giropay. +* Update - Update payment receipt settings to remove mention of the printed receipts. * Dev - Add validation for path variables. * Dev - Migrate Affirm and Afterpay payment method components to TypeScript. * Dev - Prevent infinite loop in usePaymentFailHandler effect From cb9a48ee5238f8f005e9da7f000958fdebca17bd Mon Sep 17 00:00:00 2001 From: Rafael Zaleski Date: Wed, 10 Jul 2024 11:53:34 -0300 Subject: [PATCH 06/10] Register Independent ECE Payment Methods within the Blocks Implementation (#9047) --- ...9045-split-ece-pms-registration-for-blocks | 4 ++ client/checkout/blocks/index.js | 8 ++- .../blocks/apple-pay-preview.js | 7 --- .../blocks/components/apple-pay-preview.js | 7 +++ .../components/express-checkout-component.js | 53 ++++++++++++++++++- .../components/express-checkout-container.js | 11 ++-- .../blocks/components/google-pay-preview.js | 7 +++ client/express-checkout/blocks/index.js | 38 +++++++++---- 8 files changed, 112 insertions(+), 23 deletions(-) create mode 100644 changelog/add-9045-split-ece-pms-registration-for-blocks delete mode 100644 client/express-checkout/blocks/apple-pay-preview.js create mode 100644 client/express-checkout/blocks/components/apple-pay-preview.js create mode 100644 client/express-checkout/blocks/components/google-pay-preview.js diff --git a/changelog/add-9045-split-ece-pms-registration-for-blocks b/changelog/add-9045-split-ece-pms-registration-for-blocks new file mode 100644 index 00000000000..1d0cfd0c6fe --- /dev/null +++ b/changelog/add-9045-split-ece-pms-registration-for-blocks @@ -0,0 +1,4 @@ +Significance: minor +Type: add + +Add independent ECE instances in WC Blocks. diff --git a/client/checkout/blocks/index.js b/client/checkout/blocks/index.js index 28291b69d3e..e837734ac8c 100644 --- a/client/checkout/blocks/index.js +++ b/client/checkout/blocks/index.js @@ -19,7 +19,10 @@ import PaymentMethodLabel from './payment-method-label'; import request from '../utils/request'; import enqueueFraudScripts from 'fraud-scripts'; import paymentRequestPaymentMethod from '../../payment-request/blocks'; -import expressCheckoutElementPaymentMethod from '../../express-checkout/blocks'; +import { + expressCheckoutElementApplePay, + expressCheckoutElementGooglePay, +} from '../../express-checkout/blocks'; import tokenizedCartPaymentRequestPaymentMethod from '../../tokenized-payment-request/blocks'; import { @@ -161,7 +164,8 @@ if ( getUPEConfig( 'isTokenizedCartPrbEnabled' ) ) { tokenizedCartPaymentRequestPaymentMethod( api ) ); } else if ( getUPEConfig( 'isExpressCheckoutElementEnabled' ) ) { - registerExpressPaymentMethod( expressCheckoutElementPaymentMethod( api ) ); + registerExpressPaymentMethod( expressCheckoutElementApplePay( api ) ); + registerExpressPaymentMethod( expressCheckoutElementGooglePay( api ) ); } else { registerExpressPaymentMethod( paymentRequestPaymentMethod( api ) ); } diff --git a/client/express-checkout/blocks/apple-pay-preview.js b/client/express-checkout/blocks/apple-pay-preview.js deleted file mode 100644 index 9fc00562b1d..00000000000 --- a/client/express-checkout/blocks/apple-pay-preview.js +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-disable max-len */ -const applePayImage = - "data:image/svg+xml,%3Csvg width='264' height='48' viewBox='0 0 264 48' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='264' height='48' rx='3' fill='black'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M125.114 16.6407C125.682 15.93 126.067 14.9756 125.966 14C125.135 14.0415 124.121 14.549 123.533 15.2602C123.006 15.8693 122.539 16.8641 122.661 17.7983C123.594 17.8797 124.526 17.3317 125.114 16.6407Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M125.955 17.982C124.601 17.9011 123.448 18.7518 122.801 18.7518C122.154 18.7518 121.163 18.0224 120.092 18.0421C118.696 18.0629 117.402 18.8524 116.694 20.1079C115.238 22.6196 116.31 26.3453 117.726 28.3909C118.414 29.4028 119.242 30.5174 120.334 30.4769C121.366 30.4365 121.77 29.8087 123.024 29.8087C124.277 29.8087 124.641 30.4769 125.733 30.4567C126.865 30.4365 127.573 29.4443 128.261 28.4313C129.049 27.2779 129.373 26.1639 129.393 26.1027C129.373 26.0825 127.209 25.2515 127.189 22.7606C127.169 20.6751 128.888 19.6834 128.969 19.6217C127.998 18.1847 126.481 18.0224 125.955 17.982Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M136.131 23.1804H138.834C140.886 23.1804 142.053 22.0752 142.053 20.1592C142.053 18.2432 140.886 17.1478 138.845 17.1478H136.131V23.1804ZM139.466 15.1582C142.411 15.1582 144.461 17.1903 144.461 20.1483C144.461 23.1172 142.369 25.1596 139.392 25.1596H136.131V30.3498H133.775V15.1582H139.466Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152.198 26.224V25.3712L149.579 25.5397C148.106 25.6341 147.339 26.182 147.339 27.14C147.339 28.0664 148.138 28.6667 149.39 28.6667C150.988 28.6667 152.198 27.6449 152.198 26.224ZM145.046 27.2032C145.046 25.2551 146.529 24.1395 149.263 23.971L152.198 23.7922V22.9498C152.198 21.7181 151.388 21.0442 149.947 21.0442C148.758 21.0442 147.896 21.6548 147.717 22.5916H145.592C145.656 20.6232 147.507 19.1914 150.01 19.1914C152.703 19.1914 154.459 20.602 154.459 22.7917V30.351H152.282V28.5298H152.229C151.609 29.719 150.241 30.4666 148.758 30.4666C146.571 30.4666 145.046 29.1612 145.046 27.2032Z' fill='white'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M156.461 34.4145V32.5934C156.608 32.6141 156.965 32.6354 157.155 32.6354C158.196 32.6354 158.785 32.1932 159.142 31.0564L159.353 30.3824L155.366 19.3281H157.827L160.604 28.298H160.657L163.434 19.3281H165.832L161.698 30.9402C160.752 33.6038 159.668 34.4778 157.376 34.4778C157.197 34.4778 156.618 34.4565 156.461 34.4145Z' fill='white'/%3E%3C/svg%3E%0A"; - -const ApplePayPreview = () => ; - -export default ApplePayPreview; diff --git a/client/express-checkout/blocks/components/apple-pay-preview.js b/client/express-checkout/blocks/components/apple-pay-preview.js new file mode 100644 index 00000000000..247d5e2e6fe --- /dev/null +++ b/client/express-checkout/blocks/components/apple-pay-preview.js @@ -0,0 +1,7 @@ +/* eslint-disable max-len */ +const applePayImage = + "data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='-0.5 -0.5 344 51'%3E%3Crect width='343' height='50' rx='8' fill='black'%3E%3C/rect%3E%3Crect width='343' height='50' rx='8' stroke='black'%3E%3C/rect%3E%3Cpath d='M155.748 19.8275C154.411 19.8275 153.333 20.636 152.637 20.636C151.907 20.636 150.93 19.8724 149.773 19.8724C147.572 19.8724 145.337 21.7029 145.337 25.1282C145.337 27.2733 146.168 29.5306 147.19 31.0018C148.055 32.2259 148.83 33.2366 149.93 33.2366C151.02 33.2366 151.503 32.5179 152.862 32.5179C154.232 32.5179 154.546 33.2142 155.748 33.2142C156.95 33.2142 157.747 32.1248 158.499 31.0467C159.33 29.8001 159.69 28.5872 159.701 28.5311C159.634 28.5086 157.343 27.5765 157.343 24.9485C157.343 22.68 159.139 21.6693 159.241 21.5906C158.061 19.8724 156.253 19.8275 155.748 19.8275ZM155.13 18.3787C155.669 17.7161 156.051 16.8177 156.051 15.908C156.051 15.7845 156.04 15.6609 156.017 15.5599C155.141 15.5936 154.063 16.1439 153.423 16.8963C152.929 17.4691 152.457 18.3787 152.457 19.2884C152.457 19.4232 152.48 19.5692 152.491 19.6141C152.547 19.6253 152.637 19.6365 152.727 19.6365C153.524 19.6365 154.535 19.0975 155.13 18.3787ZM164.115 16.8289V33.0345H167.013V27.7225H170.528C173.807 27.7225 176.098 25.5213 176.098 22.3094C176.098 19.0413 173.886 16.8289 170.652 16.8289H164.115ZM167.013 19.2547H169.888C171.977 19.2547 173.156 20.3216 173.156 22.3094C173.156 24.241 171.943 25.3192 169.877 25.3192H167.013V19.2547ZM181.535 31.0467C180.3 31.0467 179.412 30.429 179.412 29.3958C179.412 28.3963 180.142 27.8348 181.703 27.7337L184.477 27.554V28.5311C184.477 29.9573 183.219 31.0467 181.535 31.0467ZM180.715 33.2366C182.321 33.2366 183.669 32.5403 184.354 31.3499H184.545V33.0345H187.229V24.6453C187.229 22.0399 185.454 20.5013 182.299 20.5013C179.379 20.5013 177.346 21.8826 177.121 24.0501H179.749C180.008 23.2191 180.884 22.7698 182.164 22.7698C183.669 22.7698 184.477 23.4437 184.477 24.6453V25.6785L181.31 25.8694C178.323 26.0491 176.65 27.3294 176.65 29.553C176.65 31.7991 178.345 33.2366 180.715 33.2366ZM190.329 37.493C193.081 37.493 194.395 36.4822 195.439 33.4276L199.875 20.7484H196.933L194.069 30.3392H193.878L191.003 20.7484H187.948L192.34 33.0906L192.194 33.6297C191.834 34.764 191.172 35.2132 189.992 35.2132C189.801 35.2132 189.386 35.202 189.229 35.1683V37.4481C189.408 37.4818 190.161 37.493 190.329 37.493Z' fill='white'%3E%3C/path%3E%3C/svg%3E"; + +const ApplePayPreview = () => ; + +export default ApplePayPreview; diff --git a/client/express-checkout/blocks/components/express-checkout-component.js b/client/express-checkout/blocks/components/express-checkout-component.js index 58ea5d96dfc..35404be68a0 100644 --- a/client/express-checkout/blocks/components/express-checkout-component.js +++ b/client/express-checkout/blocks/components/express-checkout-component.js @@ -2,11 +2,38 @@ * External dependencies */ import { ExpressCheckoutElement } from '@stripe/react-stripe-js'; +/** + * Internal dependencies + */ import { shippingAddressChangeHandler, shippingRateChangeHandler, } from '../../event-handlers'; import { useExpressCheckout } from '../hooks/use-express-checkout'; +import { PAYMENT_METHOD_NAME_EXPRESS_CHECKOUT_ELEMENT } from 'wcpay/checkout/constants'; + +const getPaymentMethodsOverride = ( enabledPaymentMethod ) => { + const allDisabled = { + amazonPay: 'never', + applePay: 'never', + googlePay: 'never', + link: 'never', + paypal: 'never', + }; + + const enabledParam = [ 'applePay', 'googlePay' ].includes( + enabledPaymentMethod + ) + ? 'always' + : 'auto'; + + return { + paymentMethods: { + ...allDisabled, + [ enabledPaymentMethod ]: enabledParam, + }, + }; +}; /** * ExpressCheckout express payment method component. @@ -22,6 +49,7 @@ const ExpressCheckoutComponent = ( { setExpressPaymentError, onClick, onClose, + expressPaymentMethod = '', } ) => { const { buttonOptions, @@ -45,12 +73,33 @@ const ExpressCheckoutComponent = ( { const onShippingRateChange = ( event ) => shippingRateChangeHandler( api, event, elements ); + const onElementsReady = ( event ) => { + const paymentMethodContainer = document.getElementById( + `express-payment-method-${ PAYMENT_METHOD_NAME_EXPRESS_CHECKOUT_ELEMENT }_${ expressPaymentMethod }` + ); + + const availablePaymentMethods = event.availablePaymentMethods || {}; + + if ( + paymentMethodContainer && + ! availablePaymentMethods[ expressPaymentMethod ] + ) { + paymentMethodContainer.style.display = 'none'; + } + + // Any actions that WooPayments needs to perform. + onReady( event ); + }; + return ( { - const { stripe, billing } = props; + const { api, billing } = props; + + const stripePromise = useMemo( () => { + return api.loadStripe(); + }, [ api ] ); const options = { mode: 'payment', @@ -22,7 +27,7 @@ const ExpressCheckoutContainer = ( props ) => { return (
- +
diff --git a/client/express-checkout/blocks/components/google-pay-preview.js b/client/express-checkout/blocks/components/google-pay-preview.js new file mode 100644 index 00000000000..fc110d67024 --- /dev/null +++ b/client/express-checkout/blocks/components/google-pay-preview.js @@ -0,0 +1,7 @@ +/* eslint-disable max-len */ +const googlePayImage = + "data:image/svg+xml,%3Csvg width='343' height='50' viewBox='0 0 343 50' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='343' height='50' rx='8' fill='black'/%3E%3Cpath d='M94.9511 24.6726V31.7486H92.6902V14.2749H98.6838C100.203 14.2749 101.498 14.7778 102.558 15.7837C103.641 16.7895 104.183 18.0176 104.183 19.4679C104.183 20.9533 103.641 22.1813 102.558 23.1755C101.51 24.1696 100.215 24.6609 98.6838 24.6609H94.9511V24.6726ZM94.9511 16.4269V22.5205H98.7309C99.6258 22.5205 100.379 22.2164 100.968 21.6199C101.569 21.0234 101.875 20.2983 101.875 19.4796C101.875 18.6726 101.569 17.9591 100.968 17.3626C100.379 16.7427 99.6375 16.4386 98.7309 16.4386H94.9511V16.4269Z' fill='white'/%3E%3Cpath d='M110.094 19.3977C111.766 19.3977 113.085 19.8421 114.05 20.731C115.016 21.6199 115.499 22.8363 115.499 24.3802V31.7486H113.344V30.0878H113.25C112.319 31.4562 111.071 32.1345 109.517 32.1345C108.186 32.1345 107.079 31.7486 106.185 30.9649C105.29 30.1813 104.842 29.2106 104.842 28.041C104.842 26.8012 105.313 25.8188 106.255 25.0936C107.197 24.3568 108.457 23.9942 110.023 23.9942C111.366 23.9942 112.472 24.2398 113.332 24.731V24.2164C113.332 23.4328 113.026 22.7778 112.402 22.2281C111.778 21.6784 111.048 21.4094 110.212 21.4094C108.952 21.4094 107.951 21.9357 107.221 23L105.231 21.7603C106.326 20.1813 107.951 19.3977 110.094 19.3977ZM107.174 28.0761C107.174 28.6609 107.421 29.1521 107.927 29.538C108.422 29.924 109.011 30.1228 109.682 30.1228C110.636 30.1228 111.483 29.772 112.225 29.0702C112.967 28.3685 113.344 27.5497 113.344 26.6024C112.637 26.0527 111.66 25.772 110.4 25.772C109.482 25.772 108.716 25.9942 108.104 26.4269C107.48 26.8831 107.174 27.4328 107.174 28.0761Z' fill='white'/%3E%3Cpath d='M127.792 19.7837L120.256 37.0001H117.924L120.727 30.9767L115.758 19.7837H118.219L121.798 28.3685H121.845L125.331 19.7837H127.792Z' fill='white'/%3E%3Cpath d='M85.9586 23.2456C85.9586 22.5134 85.8926 21.8128 85.7702 21.1392H76.2936V24.9988L81.7513 25C81.53 26.2842 80.8176 27.3789 79.726 28.1087V30.6128H82.9748C84.8717 28.869 85.9586 26.2912 85.9586 23.2456Z' fill='%234285F4'/%3E%3Cpath d='M79.7272 28.1088C78.8229 28.7146 77.6583 29.069 76.2959 29.069C73.6642 29.069 71.4317 27.3076 70.6321 24.9333H67.2809V27.5158C68.9412 30.7883 72.3536 33.0339 76.2959 33.0339C79.0207 33.0339 81.3098 32.1439 82.9759 30.6117L79.7272 28.1088Z' fill='%2334A853'/%3E%3Cpath d='M70.3165 23.0176C70.3165 22.3509 70.4284 21.7065 70.6321 21.1006V18.5182H67.2809C66.5944 19.8714 66.2082 21.3989 66.2082 23.0176C66.2082 24.6363 66.5956 26.1638 67.2809 27.517L70.6321 24.9346C70.4284 24.3287 70.3165 23.6843 70.3165 23.0176Z' fill='%23FABB05'/%3E%3Cpath d='M76.2959 16.9649C77.7831 16.9649 79.1149 17.4737 80.1664 18.4678L83.0454 15.6105C81.2968 13.993 79.0172 13 76.2959 13C72.3548 13 68.9412 15.2456 67.2809 18.5181L70.6321 21.1006C71.4317 18.7263 73.6642 16.9649 76.2959 16.9649Z' fill='%23E94235'/%3E%3Cline x1='140.792' y1='12' x2='140.792' y2='38' stroke='%235F6368' stroke-width='2'/%3E%3Crect x='151.292' y='11.962' width='41' height='26' stroke='white'/%3E%3Cpath d='M187.766 23.7321C187.733 22.9139 187.369 22.1408 186.752 21.5792C186.135 21.0176 185.315 20.7123 184.467 20.7289C183.454 20.6861 182.434 20.7289 181.421 20.6984C181.149 20.6984 181.054 20.7779 181.01 21.0409C180.661 23.255 180.288 25.4631 179.92 27.6772C179.832 28.2154 179.749 28.7537 179.661 29.3042C179.721 29.3178 179.783 29.328 179.844 29.3347C180.87 29.3347 181.896 29.3347 182.916 29.3347C183.738 29.3504 184.55 29.1576 185.271 28.7756C185.992 28.3935 186.597 27.8355 187.025 27.1573C187.657 26.1261 187.918 24.9216 187.766 23.7321ZM184.98 26.405C184.783 26.8111 184.465 27.1511 184.067 27.3811C183.669 27.6111 183.208 27.7206 182.745 27.6955H182.111C182.219 27.0289 182.314 26.3989 182.422 25.7689C182.593 24.723 182.776 23.6709 182.941 22.6189C182.941 22.4171 183.036 22.3314 183.251 22.3498C183.365 22.359 183.479 22.359 183.593 22.3498C183.815 22.3177 184.042 22.3315 184.258 22.3903C184.475 22.4491 184.676 22.5515 184.848 22.6908C185.02 22.8301 185.16 23.0031 185.258 23.1984C185.356 23.3937 185.41 23.6069 185.417 23.8239C185.573 24.7059 185.424 25.6131 184.993 26.405' fill='white'/%3E%3Cpath d='M178.268 21.1081C177.831 20.9036 177.358 20.7831 176.874 20.7534C175.855 20.6922 174.829 20.7534 173.803 20.7106C173.537 20.7106 173.474 20.8084 173.442 21.0286C173.084 23.255 172.718 25.4793 172.347 27.7016C172.258 28.2338 172.176 28.772 172.081 29.3469C172.714 29.3469 173.347 29.3469 173.981 29.3469C174.215 29.3469 174.297 29.2674 174.329 29.0472C174.449 28.2338 174.601 27.4203 174.721 26.6007C174.721 26.405 174.829 26.3193 175.038 26.3438C175.12 26.3561 175.203 26.3561 175.285 26.3438C175.507 26.3438 175.595 26.3988 175.633 26.6129C175.722 27.1145 175.83 27.6099 175.95 28.1053C175.998 28.4255 176.15 28.7226 176.385 28.9535C176.619 29.1844 176.924 29.3372 177.254 29.3898C177.767 29.4233 178.282 29.411 178.793 29.3531C178.829 29.3432 178.861 29.3245 178.887 29.2987C178.912 29.2729 178.93 29.241 178.939 29.2063C178.977 28.772 178.996 28.3377 179.021 27.8912H178.704C178.598 27.9031 178.491 27.8944 178.388 27.8656C178.285 27.8368 178.19 27.7886 178.107 27.7236C178.023 27.6587 177.955 27.5784 177.904 27.4875C177.853 27.3965 177.822 27.2968 177.812 27.194C177.717 26.8453 177.66 26.4906 177.546 26.1481C177.476 25.9279 177.546 25.83 177.736 25.7199C178.164 25.4948 178.532 25.1773 178.812 24.7922C179.092 24.4071 179.276 23.9648 179.35 23.4997C179.521 22.4232 179.16 21.5241 178.293 21.1265L178.268 21.1081ZM176.817 24.2826C176.745 24.4438 176.621 24.5784 176.464 24.6665C176.307 24.7546 176.124 24.7915 175.944 24.7719C175.64 24.7564 175.336 24.7564 175.032 24.7719C175.158 24.0073 175.266 23.3039 175.393 22.6005C175.408 22.5626 175.431 22.5285 175.462 22.501C175.493 22.4734 175.53 22.453 175.57 22.4415C175.827 22.4171 176.086 22.4171 176.343 22.4415C176.529 22.4659 176.7 22.5528 176.826 22.687C176.952 22.8213 177.026 22.9943 177.033 23.1755C177.084 23.5543 176.999 23.9388 176.792 24.2642' fill='white'/%3E%3Cpath d='M171.061 27.2062C170.625 25.1266 170.188 23.0532 169.757 20.9675C169.713 20.7779 169.637 20.7106 169.428 20.7106C168.953 20.7106 168.478 20.7106 168.003 20.7106C167.907 20.6989 167.811 20.7184 167.728 20.7661C167.645 20.8138 167.582 20.8868 167.547 20.9736C166.724 22.5088 165.894 24.0318 165.071 25.567C165.027 25.6588 164.976 25.7444 164.925 25.8361L163.216 29.0106C163.165 29.1023 163.127 29.2002 163.057 29.347C163.811 29.347 164.514 29.347 165.21 29.347C165.286 29.347 165.381 29.243 165.419 29.1635C165.66 28.7047 165.894 28.2399 166.116 27.7628C166.143 27.6883 166.195 27.6247 166.264 27.5825C166.333 27.5402 166.415 27.5219 166.496 27.5304C167.205 27.5304 167.921 27.5304 168.636 27.5304C168.851 27.5304 168.921 27.6038 168.953 27.7934C169.016 28.2277 169.086 28.6619 169.174 29.0901C169.174 29.1879 169.288 29.347 169.358 29.347C170.055 29.347 170.757 29.347 171.498 29.347C171.498 29.194 171.46 29.0778 171.435 28.9616C171.315 28.35 171.188 27.7934 171.061 27.2062ZM167.047 25.8973C167.427 25.1266 167.794 24.3927 168.161 23.6587H168.25C168.37 24.3927 168.497 25.1266 168.624 25.8973H167.047Z' fill='white'/%3E%3Cpath d='M161.101 27.6712C160.883 27.7345 160.653 27.7492 160.428 27.7139C160.203 27.6787 159.99 27.5946 159.804 27.4679C159.618 27.3412 159.464 27.1752 159.354 26.9826C159.244 26.79 159.181 26.5758 159.169 26.3561C159.021 25.4427 159.16 24.5072 159.568 23.671C159.728 23.2847 160.004 22.9537 160.361 22.7213C160.718 22.4888 161.139 22.3658 161.569 22.3682H161.835C162.304 22.4049 162.773 22.4844 163.273 22.5517C163.45 22.0502 163.64 21.5303 163.83 21.0043C163.694 20.8051 163.504 20.6456 163.281 20.5432C163.057 20.4408 162.809 20.3993 162.564 20.4232H157.65L157.599 20.6495C158.2 20.8013 158.79 20.9913 159.366 21.2183C158.824 21.5117 158.349 21.9093 157.973 22.3866C157.03 23.6171 156.604 25.1469 156.782 26.6681C156.804 27.2214 156.996 27.7558 157.335 28.2026C157.673 28.6495 158.142 28.9884 158.682 29.1758C159.322 29.4124 160.008 29.5146 160.692 29.4756C161.377 29.4365 162.045 29.2572 162.652 28.9495C162.722 28.9128 162.817 28.821 162.811 28.7599C162.754 28.2706 162.678 27.7874 162.614 27.3286C162.089 27.451 161.614 27.5855 161.126 27.6712' fill='white'/%3E%3Cpath d='M203.482 28.956C203.17 28.956 202.876 28.896 202.6 28.776C202.336 28.656 202.102 28.494 201.898 28.29C201.694 28.086 201.532 27.852 201.412 27.588C201.292 27.312 201.232 27.018 201.232 26.706C201.232 26.394 201.292 26.106 201.412 25.842C201.532 25.566 201.694 25.326 201.898 25.122C202.102 24.918 202.336 24.756 202.6 24.636C202.876 24.516 203.17 24.456 203.482 24.456C203.794 24.456 204.088 24.516 204.364 24.636C204.64 24.756 204.88 24.918 205.084 25.122C205.288 25.326 205.45 25.566 205.57 25.842C205.69 26.106 205.75 26.394 205.75 26.706C205.75 27.018 205.69 27.312 205.57 27.588C205.45 27.852 205.288 28.086 205.084 28.29C204.88 28.494 204.64 28.656 204.364 28.776C204.088 28.896 203.794 28.956 203.482 28.956ZM210.882 28.956C210.57 28.956 210.276 28.896 210 28.776C209.736 28.656 209.502 28.494 209.298 28.29C209.094 28.086 208.932 27.852 208.812 27.588C208.692 27.312 208.632 27.018 208.632 26.706C208.632 26.394 208.692 26.106 208.812 25.842C208.932 25.566 209.094 25.326 209.298 25.122C209.502 24.918 209.736 24.756 210 24.636C210.276 24.516 210.57 24.456 210.882 24.456C211.194 24.456 211.488 24.516 211.764 24.636C212.04 24.756 212.28 24.918 212.484 25.122C212.688 25.326 212.85 25.566 212.97 25.842C213.09 26.106 213.15 26.394 213.15 26.706C213.15 27.018 213.09 27.312 212.97 27.588C212.85 27.852 212.688 28.086 212.484 28.29C212.28 28.494 212.04 28.656 211.764 28.776C211.488 28.896 211.194 28.956 210.882 28.956ZM218.283 28.956C217.971 28.956 217.677 28.896 217.401 28.776C217.137 28.656 216.903 28.494 216.699 28.29C216.495 28.086 216.333 27.852 216.213 27.588C216.093 27.312 216.033 27.018 216.033 26.706C216.033 26.394 216.093 26.106 216.213 25.842C216.333 25.566 216.495 25.326 216.699 25.122C216.903 24.918 217.137 24.756 217.401 24.636C217.677 24.516 217.971 24.456 218.283 24.456C218.595 24.456 218.889 24.516 219.165 24.636C219.441 24.756 219.681 24.918 219.885 25.122C220.089 25.326 220.251 25.566 220.371 25.842C220.491 26.106 220.551 26.394 220.551 26.706C220.551 27.018 220.491 27.312 220.371 27.588C220.251 27.852 220.089 28.086 219.885 28.29C219.681 28.494 219.441 28.656 219.165 28.776C218.889 28.896 218.595 28.956 218.283 28.956ZM225.683 28.956C225.371 28.956 225.077 28.896 224.801 28.776C224.537 28.656 224.303 28.494 224.099 28.29C223.895 28.086 223.733 27.852 223.613 27.588C223.493 27.312 223.433 27.018 223.433 26.706C223.433 26.394 223.493 26.106 223.613 25.842C223.733 25.566 223.895 25.326 224.099 25.122C224.303 24.918 224.537 24.756 224.801 24.636C225.077 24.516 225.371 24.456 225.683 24.456C225.995 24.456 226.289 24.516 226.565 24.636C226.841 24.756 227.081 24.918 227.285 25.122C227.489 25.326 227.651 25.566 227.771 25.842C227.891 26.106 227.951 26.394 227.951 26.706C227.951 27.018 227.891 27.312 227.771 27.588C227.651 27.852 227.489 28.086 227.285 28.29C227.081 28.494 226.841 28.656 226.565 28.776C226.289 28.896 225.995 28.956 225.683 28.956ZM235.566 31.908L240.984 22.188L240.948 22.116H235.008L235.044 20.226H243.18V22.224L237.294 32.826L235.566 31.908ZM249.263 32.826C248.831 32.826 248.399 32.766 247.967 32.646C247.535 32.526 247.127 32.34 246.743 32.088C246.371 31.824 246.035 31.494 245.735 31.098C245.435 30.702 245.207 30.228 245.051 29.676L246.923 28.902C247.091 29.55 247.379 30.048 247.787 30.396C248.195 30.744 248.687 30.918 249.263 30.918C249.551 30.918 249.827 30.87 250.091 30.774C250.367 30.678 250.607 30.546 250.811 30.378C251.015 30.198 251.177 29.994 251.297 29.766C251.417 29.526 251.477 29.262 251.477 28.974C251.477 28.686 251.411 28.422 251.279 28.182C251.159 27.942 250.991 27.738 250.775 27.57C250.559 27.402 250.301 27.27 250.001 27.174C249.713 27.078 249.401 27.03 249.065 27.03H248.003V25.176H248.957C249.245 25.176 249.509 25.14 249.749 25.068C250.001 24.984 250.223 24.87 250.415 24.726C250.607 24.582 250.757 24.402 250.865 24.186C250.973 23.958 251.027 23.7 251.027 23.412C251.027 22.92 250.847 22.536 250.487 22.26C250.139 21.972 249.695 21.828 249.155 21.828C248.855 21.828 248.591 21.87 248.363 21.954C248.147 22.038 247.961 22.152 247.805 22.296C247.649 22.44 247.517 22.602 247.409 22.782C247.313 22.95 247.235 23.124 247.175 23.304L245.339 22.53C245.435 22.242 245.585 21.948 245.789 21.648C245.993 21.336 246.251 21.054 246.563 20.802C246.875 20.55 247.241 20.346 247.661 20.19C248.093 20.022 248.591 19.938 249.155 19.938C249.731 19.938 250.259 20.022 250.739 20.19C251.219 20.358 251.633 20.592 251.981 20.892C252.329 21.192 252.599 21.546 252.791 21.954C252.983 22.362 253.079 22.806 253.079 23.286C253.079 23.634 253.031 23.952 252.935 24.24C252.851 24.528 252.731 24.786 252.575 25.014C252.419 25.23 252.245 25.416 252.053 25.572C251.861 25.728 251.663 25.86 251.459 25.968V26.076C251.735 26.196 251.999 26.352 252.251 26.544C252.503 26.724 252.719 26.94 252.899 27.192C253.091 27.444 253.241 27.732 253.349 28.056C253.457 28.368 253.511 28.71 253.511 29.082C253.511 29.622 253.403 30.126 253.187 30.594C252.971 31.05 252.671 31.446 252.287 31.782C251.915 32.106 251.471 32.358 250.955 32.538C250.439 32.73 249.875 32.826 249.263 32.826ZM261.209 32.538V30.108H255.449V28.524L261.047 20.226H263.225V28.236H264.773V30.108H263.225V32.538H261.209ZM261.209 23.196H261.101L257.699 28.236H261.209V23.196ZM271.097 32.826C270.473 32.826 269.897 32.73 269.369 32.538C268.841 32.346 268.385 32.088 268.001 31.764C267.617 31.428 267.317 31.038 267.101 30.594C266.885 30.138 266.777 29.646 266.777 29.118C266.777 28.758 266.825 28.428 266.921 28.128C267.029 27.816 267.173 27.534 267.353 27.282C267.533 27.03 267.737 26.808 267.965 26.616C268.205 26.412 268.457 26.244 268.721 26.112V26.004C268.301 25.728 267.941 25.368 267.641 24.924C267.341 24.48 267.191 23.976 267.191 23.412C267.191 22.92 267.287 22.464 267.479 22.044C267.671 21.612 267.941 21.24 268.289 20.928C268.637 20.616 269.051 20.376 269.531 20.208C270.011 20.028 270.533 19.938 271.097 19.938C271.661 19.938 272.183 20.028 272.663 20.208C273.143 20.376 273.557 20.616 273.905 20.928C274.253 21.24 274.523 21.612 274.715 22.044C274.907 22.464 275.003 22.92 275.003 23.412C275.003 23.976 274.853 24.48 274.553 24.924C274.253 25.368 273.893 25.728 273.473 26.004V26.112C273.737 26.244 273.983 26.412 274.211 26.616C274.451 26.808 274.661 27.03 274.841 27.282C275.021 27.534 275.159 27.816 275.255 28.128C275.363 28.428 275.417 28.758 275.417 29.118C275.417 29.646 275.309 30.138 275.093 30.594C274.877 31.038 274.577 31.428 274.193 31.764C273.809 32.088 273.353 32.346 272.825 32.538C272.297 32.73 271.721 32.826 271.097 32.826ZM271.097 25.212C271.637 25.212 272.087 25.062 272.447 24.762C272.819 24.45 273.005 24.03 273.005 23.502C273.005 22.962 272.819 22.542 272.447 22.242C272.087 21.942 271.637 21.792 271.097 21.792C270.557 21.792 270.101 21.942 269.729 22.242C269.369 22.542 269.189 22.962 269.189 23.502C269.189 24.03 269.369 24.45 269.729 24.762C270.101 25.062 270.557 25.212 271.097 25.212ZM271.097 30.936C271.421 30.936 271.721 30.888 271.997 30.792C272.273 30.696 272.513 30.564 272.717 30.396C272.933 30.228 273.095 30.024 273.203 29.784C273.323 29.532 273.383 29.262 273.383 28.974C273.383 28.686 273.323 28.422 273.203 28.182C273.083 27.93 272.921 27.72 272.717 27.552C272.513 27.384 272.273 27.252 271.997 27.156C271.721 27.06 271.421 27.012 271.097 27.012C270.773 27.012 270.473 27.06 270.197 27.156C269.921 27.252 269.681 27.384 269.477 27.552C269.273 27.72 269.111 27.93 268.991 28.182C268.871 28.422 268.811 28.686 268.811 28.974C268.811 29.262 268.865 29.532 268.973 29.784C269.093 30.024 269.255 30.228 269.459 30.396C269.675 30.564 269.921 30.696 270.197 30.792C270.473 30.888 270.773 30.936 271.097 30.936Z' fill='white'/%3E%3C/svg%3E%0A"; + +const GooglePayPreview = () => ; + +export default GooglePayPreview; diff --git a/client/express-checkout/blocks/index.js b/client/express-checkout/blocks/index.js index 79e54d80a0b..30dc6853111 100644 --- a/client/express-checkout/blocks/index.js +++ b/client/express-checkout/blocks/index.js @@ -1,21 +1,41 @@ /** * Internal dependencies */ -import { PAYMENT_METHOD_NAME_EXPRESS_CHECKOUT_ELEMENT } from '../../checkout/constants'; +import { PAYMENT_METHOD_NAME_EXPRESS_CHECKOUT_ELEMENT } from 'wcpay/checkout/constants'; +import { getConfig } from 'wcpay/utils/checkout'; +import ApplePayPreview from './components/apple-pay-preview'; import ExpressCheckoutContainer from './components/express-checkout-container'; -import { getConfig } from '../../utils/checkout'; -import ApplePayPreview from './apple-pay-preview'; +import GooglePayPreview from './components/google-pay-preview'; -const expressCheckoutElementPaymentMethod = ( api ) => ( { - name: PAYMENT_METHOD_NAME_EXPRESS_CHECKOUT_ELEMENT, +const expressCheckoutElementApplePay = ( api ) => ( { + paymentMethodId: PAYMENT_METHOD_NAME_EXPRESS_CHECKOUT_ELEMENT, + name: PAYMENT_METHOD_NAME_EXPRESS_CHECKOUT_ELEMENT + '_applePay', + content: ( + + ), + edit: , + supports: { + features: getConfig( 'features' ), + }, + canMakePayment: () => { + if ( typeof wcpayExpressCheckoutParams === 'undefined' ) { + return false; + } + + return true; + }, +} ); + +const expressCheckoutElementGooglePay = ( api ) => ( { + paymentMethodId: PAYMENT_METHOD_NAME_EXPRESS_CHECKOUT_ELEMENT, + name: PAYMENT_METHOD_NAME_EXPRESS_CHECKOUT_ELEMENT + '_googlePay', content: ( ), - edit: , - paymentMethodId: PAYMENT_METHOD_NAME_EXPRESS_CHECKOUT_ELEMENT, + edit: , supports: { features: getConfig( 'features' ), }, @@ -28,4 +48,4 @@ const expressCheckoutElementPaymentMethod = ( api ) => ( { }, } ); -export default expressCheckoutElementPaymentMethod; +export { expressCheckoutElementApplePay, expressCheckoutElementGooglePay }; From a5d86abf23157b954e3535d19d99001a992db7b2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 11 Jul 2024 14:42:30 +0000 Subject: [PATCH 07/10] Update version and add changelog entries for release 7.9.1 --- changelog.txt | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- readme.txt | 5 ++++- woocommerce-payments.php | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/changelog.txt b/changelog.txt index 6814467549c..43ee2c48ddd 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,7 @@ *** WooPayments Changelog *** += 7.9.1 - 2024-07-11 = + = 7.9.0 - 2024-07-10 = * Add - Add a separate transient to save UPE appearance styles for the Add Payment Method standalone page. Correct regression that prevented proper styles calculation in the shortcode checkout. * Add - Add Pay for Order support in Express Checkout Elements. diff --git a/package-lock.json b/package-lock.json index 4fe8e9f7d14..ab57cd12e9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "woocommerce-payments", - "version": "7.9.0", + "version": "7.9.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "woocommerce-payments", - "version": "7.9.0", + "version": "7.9.1", "hasInstallScript": true, "license": "GPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index c0dde30c0b1..3d542ef2999 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "woocommerce-payments", - "version": "7.9.0", + "version": "7.9.1", "main": "webpack.config.js", "author": "Automattic", "license": "GPL-3.0-or-later", diff --git a/readme.txt b/readme.txt index c7a56bcc596..785a91e1c0f 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: woocommerce payments, apple pay, credit card, google pay, payment, payment Requires at least: 6.0 Tested up to: 6.5 Requires PHP: 7.3 -Stable tag: 7.9.0 +Stable tag: 7.9.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -94,6 +94,9 @@ Please note that our support for the checkout block is still experimental and th == Changelog == += 7.9.1 - 2024-07-11 = + + = 7.9.0 - 2024-07-10 = * Add - Add a separate transient to save UPE appearance styles for the Add Payment Method standalone page. Correct regression that prevented proper styles calculation in the shortcode checkout. * Add - Add Pay for Order support in Express Checkout Elements. diff --git a/woocommerce-payments.php b/woocommerce-payments.php index 995ffea0b58..e82179c5e8d 100644 --- a/woocommerce-payments.php +++ b/woocommerce-payments.php @@ -11,7 +11,7 @@ * WC tested up to: 8.9.3 * Requires at least: 6.0 * Requires PHP: 7.3 - * Version: 7.9.0 + * Version: 7.9.1 * Requires Plugins: woocommerce * * @package WooCommerce\Payments From 5ffc65b46842e85c76aec817a01119a669f846fc Mon Sep 17 00:00:00 2001 From: Jesse Pearson Date: Thu, 11 Jul 2024 12:35:49 -0300 Subject: [PATCH 08/10] Fix Documents API regex to allow documents with dashes in name to be viewed (#9086) --- changelog/fix-9083-documents-api-regex | 4 ++++ includes/wc-payment-api/class-wc-payments-api-client.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelog/fix-9083-documents-api-regex diff --git a/changelog/fix-9083-documents-api-regex b/changelog/fix-9083-documents-api-regex new file mode 100644 index 00000000000..79d7ad4daf8 --- /dev/null +++ b/changelog/fix-9083-documents-api-regex @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix Documents API regex to allow documents with dashes in name to be viewed. 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 d1a07e720ab..b0247f6f8af 100644 --- a/includes/wc-payment-api/class-wc-payments-api-client.php +++ b/includes/wc-payment-api/class-wc-payments-api-client.php @@ -1795,7 +1795,7 @@ public function get_documents_summary( array $filters = [] ) { * @throws API_Exception - If not connected or request failed. */ public function get_document( $document_id ) { - if ( ! preg_match( '/^\w+$/', $document_id ) ) { + if ( ! preg_match( '/^[\w-]+$/', $document_id ) ) { throw new API_Exception( __( 'Route param validation failed.', 'woocommerce-payments' ), 'wcpay_route_validation_failure', From baa57273c969865f23f1a430f6e13c245d382a02 Mon Sep 17 00:00:00 2001 From: botwoo Date: Thu, 11 Jul 2024 15:36:51 +0000 Subject: [PATCH 09/10] Amend changelog entries for release 7.9.1 --- changelog.txt | 1 + changelog/fix-9083-documents-api-regex | 4 ---- readme.txt | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 changelog/fix-9083-documents-api-regex diff --git a/changelog.txt b/changelog.txt index 43ee2c48ddd..c1109539ee7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ *** WooPayments Changelog *** = 7.9.1 - 2024-07-11 = +* Fix - Fix Documents API regex to allow documents with dashes in name to be viewed. = 7.9.0 - 2024-07-10 = * Add - Add a separate transient to save UPE appearance styles for the Add Payment Method standalone page. Correct regression that prevented proper styles calculation in the shortcode checkout. diff --git a/changelog/fix-9083-documents-api-regex b/changelog/fix-9083-documents-api-regex deleted file mode 100644 index 79d7ad4daf8..00000000000 --- a/changelog/fix-9083-documents-api-regex +++ /dev/null @@ -1,4 +0,0 @@ -Significance: patch -Type: fix - -Fix Documents API regex to allow documents with dashes in name to be viewed. diff --git a/readme.txt b/readme.txt index 785a91e1c0f..6491ffcdd61 100644 --- a/readme.txt +++ b/readme.txt @@ -95,6 +95,7 @@ Please note that our support for the checkout block is still experimental and th == Changelog == = 7.9.1 - 2024-07-11 = +* Fix - Fix Documents API regex to allow documents with dashes in name to be viewed. = 7.9.0 - 2024-07-10 = From ba3b7f796cac3a8d327e020e67f95319d0d4c0a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3fer=20Reykjal=C3=ADn?= <13835680+reykjalin@users.noreply.github.com> Date: Fri, 12 Jul 2024 00:03:09 -0400 Subject: [PATCH 10/10] Use ECE buttons during style preview in settings when ECE is enabled (#9028) Co-authored-by: Alfredo Sumaran --- ...dd-9007-use-ece-for-express-button-preview | 4 + client/data/settings/selectors.js | 11 +- .../components/express-checkout-preview.js | 107 ++++++++ .../express-checkout-settings/index.scss | 2 + .../payment-request-button-preview.js | 241 +++++++++--------- .../payment-request-button-preview.test.js | 41 ++- client/settings/wcpay-settings-context.js | 1 + 7 files changed, 277 insertions(+), 130 deletions(-) create mode 100644 changelog/add-9007-use-ece-for-express-button-preview create mode 100644 client/express-checkout/blocks/components/express-checkout-preview.js diff --git a/changelog/add-9007-use-ece-for-express-button-preview b/changelog/add-9007-use-ece-for-express-button-preview new file mode 100644 index 00000000000..f5168475392 --- /dev/null +++ b/changelog/add-9007-use-ece-for-express-button-preview @@ -0,0 +1,4 @@ +Significance: minor +Type: add + +Use Stripe's Express Checkout Element (ECE) for express checkout button previews in the settings when ECE is enabled. diff --git a/client/data/settings/selectors.js b/client/data/settings/selectors.js index 29a1f270433..5de61c53123 100644 --- a/client/data/settings/selectors.js +++ b/client/data/settings/selectors.js @@ -186,10 +186,13 @@ export const getPaymentRequestButtonTheme = ( state ) => { }; export const getPaymentRequestButtonBorderRadius = ( state ) => { - return ( - getSettings( state )?.payment_request_button_border_radius || - getDefaultBorderRadius() - ); + const radius = getSettings( state )?.payment_request_button_border_radius; + + // We can't use a || shorthand because 0 is a valid value. + if ( radius === 0 || radius === '0' || radius ) { + return radius; + } + return getDefaultBorderRadius(); }; export const getIsSavedCardsEnabled = ( state ) => { diff --git a/client/express-checkout/blocks/components/express-checkout-preview.js b/client/express-checkout/blocks/components/express-checkout-preview.js new file mode 100644 index 00000000000..33b9b3dcb0c --- /dev/null +++ b/client/express-checkout/blocks/components/express-checkout-preview.js @@ -0,0 +1,107 @@ +/** + * External dependencies + */ +import { useState } from 'react'; +import { Elements, ExpressCheckoutElement } from '@stripe/react-stripe-js'; +import { __ } from '@wordpress/i18n'; + +/** + * Internal dependencies + */ +import InlineNotice from 'components/inline-notice'; +import { getDefaultBorderRadius } from 'wcpay/utils/express-checkout'; + +export const ExpressCheckoutPreviewComponent = ( { + stripe, + buttonType, + theme, + height, + radius, +} ) => { + const [ canRenderButtons, setCanRenderButtons ] = useState( true ); + + const options = { + mode: 'payment', + amount: 1000, + currency: 'usd', + appearance: { + variables: { + borderRadius: `${ radius ?? getDefaultBorderRadius() }px`, + }, + }, + }; + + const mapThemeConfigToButtonTheme = ( paymentMethod, buttonTheme ) => { + switch ( buttonTheme ) { + case 'dark': + return 'black'; + case 'light': + return 'white'; + case 'light-outline': + if ( paymentMethod === 'googlePay' ) { + return 'white'; + } + + return 'white-outline'; + default: + return 'black'; + } + }; + + const type = buttonType === 'default' ? 'plain' : buttonType; + + const buttonOptions = { + buttonHeight: Math.min( Math.max( height, 40 ), 55 ), + buttonTheme: { + googlePay: mapThemeConfigToButtonTheme( 'googlePay', theme ), + applePay: mapThemeConfigToButtonTheme( 'applePay', theme ), + }, + buttonType: { + googlePay: type, + applePay: type, + }, + paymentMethods: { + link: 'never', + googlePay: 'always', + applePay: 'always', + }, + layout: { overflow: 'never' }, + }; + + const onReady = ( { availablePaymentMethods } ) => { + if ( availablePaymentMethods ) { + setCanRenderButtons( true ); + } else { + setCanRenderButtons( false ); + } + }; + + if ( canRenderButtons ) { + return ( +
+ + {} } + onReady={ onReady } + /> + +
+ ); + } + + return ( + + { __( + 'Failed to preview the Apple Pay or Google Pay button. ' + + 'Ensure your store uses HTTPS on a publicly available domain ' + + "and you're viewing this page in a Safari or Chrome browser. " + + 'Your device must be configured to use Apple Pay or Google Pay.', + 'woocommerce-payments' + ) } + + ); +}; diff --git a/client/settings/express-checkout-settings/index.scss b/client/settings/express-checkout-settings/index.scss index ce46dbae019..4bd2d6b9506 100644 --- a/client/settings/express-checkout-settings/index.scss +++ b/client/settings/express-checkout-settings/index.scss @@ -307,6 +307,8 @@ border-radius: 4px; display: flex; justify-content: center; + flex-direction: column; + gap: $gap-smaller; .woopay-express-button, .StripeElement { diff --git a/client/settings/express-checkout-settings/payment-request-button-preview.js b/client/settings/express-checkout-settings/payment-request-button-preview.js index 2d862f54598..dd6a0f3bcf8 100644 --- a/client/settings/express-checkout-settings/payment-request-button-preview.js +++ b/client/settings/express-checkout-settings/payment-request-button-preview.js @@ -3,8 +3,8 @@ /** * External dependencies */ -import { React, useState, useEffect } from 'react'; -import { __, sprintf } from '@wordpress/i18n'; +import { React, useState, useEffect, useContext } from 'react'; +import { __ } from '@wordpress/i18n'; import { PaymentRequestButtonElement, useStripe, @@ -13,7 +13,6 @@ import { /** * Internal dependencies */ -import { shouldUseGooglePayBrand } from 'utils/express-checkout'; import InlineNotice from 'components/inline-notice'; import { WoopayExpressCheckoutButton } from 'wcpay/checkout/woopay/express-button/woopay-express-checkout-button'; import { @@ -24,43 +23,8 @@ import { usePaymentRequestEnabledSettings, useWooPayEnabledSettings, } from '../../data'; - -const isPaymentRequestSettingsPage = () => - document.getElementById( 'wcpay-express-checkout-settings-container' ) - ?.dataset.methodId === 'payment_request'; - -/** - * stripePromise is used to pass into 's stripe props. - * The stripe prop in can't be change once passed in. - * Keeping this outside of so that - * re-rendering does not change it. - */ - -const BrowserHelpText = () => { - if ( ! isPaymentRequestSettingsPage() ) return null; - - let browser = 'Google Chrome'; - let paymentMethodName = 'Google Pay'; - - if ( shouldUseGooglePayBrand() ) { - browser = 'Safari'; - paymentMethodName = 'Apple Pay'; - } - - return ( -

- { sprintf( - __( - /* translators: %1: Payment method name %2: Browser name. */ - 'To preview the %1$s button, view this page in the %2$s browser.', - 'woocommerce-payments' - ), - paymentMethodName, - browser - ) } -

- ); -}; +import WCPaySettingsContext from '../wcpay-settings-context'; +import { ExpressCheckoutPreviewComponent } from 'wcpay/express-checkout/blocks/components/express-checkout-preview'; const buttonSizeToPxMap = { small: 40, @@ -68,6 +32,42 @@ const buttonSizeToPxMap = { large: 56, }; +const WooPayButtonPreview = ( { size, buttonType, theme, radius } ) => ( + +); + +const ButtonPreviewWrapper = ( { theme, children } ) => ( + <> +
+ { children } +
+ +); + +const PreviewRequirementsNotice = () => ( + + { __( + 'To preview the express checkout buttons, ' + + 'ensure your store uses HTTPS on a publicly available domain, ' + + "and you're viewing this page in a Safari or Chrome browser. " + + 'Your device must be configured to use Apple Pay or Google Pay.', + 'woocommerce-payments' + ) } + +); + const PaymentRequestButtonPreview = () => { const stripe = useStripe(); const [ paymentRequest, setPaymentRequest ] = useState(); @@ -79,11 +79,21 @@ const PaymentRequestButtonPreview = () => { const [ isWooPayEnabled ] = useWooPayEnabledSettings(); const [ isPaymentRequestEnabled ] = usePaymentRequestEnabledSettings(); + const { + featureFlags: { isStripeEceEnabled }, + } = useContext( WCPaySettingsContext ); + useEffect( () => { if ( ! stripe ) { return; } + // We don't need a payment request when using the ECE buttons. + if ( isStripeEceEnabled ) { + setIsLoading( false ); + return; + } + // Create a preview for payment button. The label and its total are placeholders. const stripePaymentRequest = stripe.paymentRequest( { country: 'US', @@ -103,7 +113,7 @@ const PaymentRequestButtonPreview = () => { } setIsLoading( false ); } ); - }, [ stripe, setPaymentRequest, setIsLoading ] ); + }, [ stripe, setPaymentRequest, setIsLoading, isStripeEceEnabled ] ); /** * If stripe is loading, then display nothing. @@ -111,80 +121,83 @@ const PaymentRequestButtonPreview = () => { * If stripe finished loading and payment request button loads, display the button. */ - return ( - <> - { ( isWooPayEnabled || - ( isPaymentRequestEnabled && paymentRequest ) ) && ( -
- { isWooPayEnabled && ( - - ) } - { isPaymentRequestEnabled && - ! isLoading && - paymentRequest && ( - { - e.preventDefault(); - } } - options={ { - paymentRequest: paymentRequest, - style: { - paymentRequestButton: { - type: buttonType, - theme: theme, - height: `${ - buttonSizeToPxMap[ size ] || - buttonSizeToPxMap.medium - }px`, - }, - }, - } } - /> - ) } -
- ) } - { ! isWooPayEnabled && ! isPaymentRequestEnabled && ( - - { __( - 'To preview the express checkout buttons, ' + - 'activate at least one express checkout.', - 'woocommerce-payments' - ) } - - ) } - { isPaymentRequestSettingsPage() && - isPaymentRequestEnabled && - ! isLoading && - ! paymentRequest && ( - - { __( - 'To preview the Apple Pay and Google Pay buttons, ' + - 'ensure your device is configured to accept Apple Pay or Google Pay, ' + - 'and view this page using the Safari or Chrome browsers.', - 'woocommerce-payments' - ) } - + // No need to check `isStripeEceEnabled` since that's not what controls whether the express checkout + // buttons are displayed or not, that's always controlled by `isPaymentRequestEnabled`. + if ( ! isWooPayEnabled && ! isPaymentRequestEnabled ) { + return ( + + { __( + 'To preview the express checkout buttons, ' + + 'activate at least one express checkout.', + 'woocommerce-payments' ) } - - - ); + + ); + } + + const woopayPreview = isWooPayEnabled ? ( + + ) : null; + + const isHttpsEnabled = window.location.protocol === 'https:'; + + const expressCheckoutButtonPreview = + isPaymentRequestEnabled && isStripeEceEnabled + ? ( isHttpsEnabled && ( + + ) ) || + : null; + + const prbButtonPreview = + isPaymentRequestEnabled && paymentRequest && ! isLoading + ? ( isHttpsEnabled && ( + { + e.preventDefault(); + } } + options={ { + paymentRequest: paymentRequest, + style: { + paymentRequestButton: { + type: buttonType, + theme: theme, + height: `${ + buttonSizeToPxMap[ size ] || + buttonSizeToPxMap.medium + }px`, + }, + }, + } } + /> + ) ) || + : null; + + if ( woopayPreview || expressCheckoutButtonPreview || prbButtonPreview ) { + return ( + + { woopayPreview } + { /* We never want to show both ECE and PRB previews at the same time. */ } + { expressCheckoutButtonPreview || prbButtonPreview } + + ); + } + + return ; }; export default PaymentRequestButtonPreview; diff --git a/client/settings/express-checkout-settings/test/payment-request-button-preview.test.js b/client/settings/express-checkout-settings/test/payment-request-button-preview.test.js index de745d6b8bb..9257891a009 100644 --- a/client/settings/express-checkout-settings/test/payment-request-button-preview.test.js +++ b/client/settings/express-checkout-settings/test/payment-request-button-preview.test.js @@ -55,7 +55,16 @@ const render = ( ui, options ) => describe( 'PaymentRequestButtonPreview', () => { const canMakePaymentMock = jest.fn(); + let location; + const mockHttpsLocation = new URL( 'https://example.com' ); + beforeEach( () => { + // We need the preview component to think we're rendering on a HTTPS enabled page + // so the buttons are rendered. + location = global.location; + delete global.location; + global.location = mockHttpsLocation; + shouldUseGooglePayBrand.mockReturnValue( true ); useStripe.mockReturnValue( { paymentRequest: () => ( { @@ -67,6 +76,7 @@ describe( 'PaymentRequestButtonPreview', () => { afterEach( () => { jest.clearAllMocks(); + window.location = location; } ); it( 'displays Google Chrome and Google Pay when page is in Safari', async () => { @@ -75,11 +85,13 @@ describe( 'PaymentRequestButtonPreview', () => { render( ); expect( - await screen.findByText( - 'To preview the Google Pay button, view this page in the Google Chrome browser.' - ) + await screen.findByText( 'Stripe button mock' ) ).toBeInTheDocument(); - expect( screen.queryByText( /Safari/ ) ).not.toBeInTheDocument(); + expect( + screen.queryByText( /Safari/, { + ignore: '.a11y-speak-region', + } ) + ).not.toBeInTheDocument(); } ); it( 'displays Safari Apple Pay when page is in Google Chrome', async () => { @@ -88,11 +100,13 @@ describe( 'PaymentRequestButtonPreview', () => { render( ); expect( - await screen.findByText( - 'To preview the Apple Pay button, view this page in the Safari browser.' - ) + await screen.findByText( 'Stripe button mock' ) ).toBeInTheDocument(); - expect( screen.queryByText( /Google Chrome/ ) ).not.toBeInTheDocument(); + expect( + screen.queryByText( /Chrome/, { + ignore: '.a11y-speak-region', + } ) + ).not.toBeInTheDocument(); } ); it( 'does not display anything if stripe is falsy', () => { @@ -111,7 +125,7 @@ describe( 'PaymentRequestButtonPreview', () => { expect( await screen.findByText( - /To preview the Apple Pay and Google Pay buttons, ensure your device is configured/, + /To preview the express checkout buttons, ensure your store uses/, { ignore: '.a11y-speak-region', } @@ -129,9 +143,12 @@ describe( 'PaymentRequestButtonPreview', () => { await screen.findByText( 'Stripe button mock' ) ).toBeInTheDocument(); expect( - screen.queryByText( /ensure your device is configured/, { - ignore: '.a11y-speak-region', - } ) + screen.queryByText( + /To preview the express checkout buttons, ensure your store uses/, + { + ignore: '.a11y-speak-region', + } + ) ).not.toBeInTheDocument(); } ); } ); diff --git a/client/settings/wcpay-settings-context.js b/client/settings/wcpay-settings-context.js index 531e806ff27..36d8d92b029 100644 --- a/client/settings/wcpay-settings-context.js +++ b/client/settings/wcpay-settings-context.js @@ -11,6 +11,7 @@ const WCPaySettingsContext = createContext( { isAuthAndCaptureEnabled: false, isDisputeIssuerEvidenceEnabled: false, woopay: false, + isStripeEceEnabled: false, }, } );