From 952e4314cee6c902931af89e6c7408ce1174fb50 Mon Sep 17 00:00:00 2001 From: Leonardo Lopes de Albuquerque Date: Mon, 23 Dec 2024 17:48:24 -0300 Subject: [PATCH 1/3] Prevent WooPay opt-in checks from running when WooPayments is not available (#9943) --- changelog/fix-9942-no-cost-subscription | 4 ++++ client/checkout/blocks/index.js | 3 ++- .../save-user/checkout-page-save-user.js | 20 ++++++++++++------- 3 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 changelog/fix-9942-no-cost-subscription diff --git a/changelog/fix-9942-no-cost-subscription b/changelog/fix-9942-no-cost-subscription new file mode 100644 index 00000000000..dc40262f302 --- /dev/null +++ b/changelog/fix-9942-no-cost-subscription @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Zero dollar subscriptions with zero dollar renewals checkout error diff --git a/client/checkout/blocks/index.js b/client/checkout/blocks/index.js index 3f98863d707..da139e3a27c 100644 --- a/client/checkout/blocks/index.js +++ b/client/checkout/blocks/index.js @@ -98,12 +98,13 @@ Object.entries( enabledPaymentMethodsConfig ) savedTokenComponent: , canMakePayment: ( cartData ) => { const billingCountry = cartData.billingAddress.country; + const needsPayment = cartData.cart.cartNeedsPayment; const isRestrictedInAnyCountry = !! upeConfig.countries.length; const isAvailableInTheCountry = ! isRestrictedInAnyCountry || upeConfig.countries.includes( billingCountry ); // We used to check if stripe was loaded with `getStripeForUPE`, but we can't guarantee it will be loaded synchronously. - return isAvailableInTheCountry; + return needsPayment && isAvailableInTheCountry; }, paymentMethodId: upeMethods[ upeName ], // see .wc-block-checkout__payment-method styles in blocks/style.scss diff --git a/client/components/woopay/save-user/checkout-page-save-user.js b/client/components/woopay/save-user/checkout-page-save-user.js index 45295c5c170..89c753cae7a 100644 --- a/client/components/woopay/save-user/checkout-page-save-user.js +++ b/client/components/woopay/save-user/checkout-page-save-user.js @@ -54,6 +54,13 @@ const CheckoutPageSaveUser = ( { isBlocksCheckout } ) => { const { isWCPayChosen, isNewPaymentTokenChosen } = useSelectedPaymentMethod( isBlocksCheckout ); + + // In classic checkout the saved tokens are under WCPay, so we need to check if new token is selected or not, + // under WCPay. For blocks checkout considering isWCPayChosen is enough. + const isWCPayWithNewTokenChosen = isBlocksCheckout + ? isWCPayChosen + : isWCPayChosen && isNewPaymentTokenChosen; + const viewportWidth = window.document.documentElement.clientWidth; const viewportHeight = window.document.documentElement.clientHeight; @@ -193,7 +200,11 @@ const CheckoutPageSaveUser = ( { isBlocksCheckout } ) => { return; } - if ( isSaveDetailsChecked && ! isPhoneValid ) { + if ( + isSaveDetailsChecked && + ! isPhoneValid && + isWCPayWithNewTokenChosen + ) { setValidationErrors( { [ errorId ]: { message: __( @@ -212,14 +223,9 @@ const CheckoutPageSaveUser = ( { isBlocksCheckout } ) => { isSaveDetailsChecked, sendExtensionData, setValidationErrors, + isWCPayWithNewTokenChosen, ] ); - // In classic checkout the saved tokens are under WCPay, so we need to check if new token is selected or not, - // under WCPay. For blocks checkout considering isWCPayChosen is enough. - const isWCPayWithNewTokenChosen = isBlocksCheckout - ? isWCPayChosen - : isWCPayChosen && isNewPaymentTokenChosen; - const updatePhoneNumber = useCallback( () => { if ( isPhoneNumberTouched.current ) { return; From 504a42cc9b69b0d4207e04feee4c7652dc8c0bec Mon Sep 17 00:00:00 2001 From: Eric Jinks <3147296+Jinksi@users.noreply.github.com> Date: Tue, 24 Dec 2024 15:27:51 +1000 Subject: [PATCH 2/3] Remove unused useEffect import to fix GH linter warning (#10035) --- changelog/dev-10034-linter-warning-useeffect-unused-import | 5 +++++ .../modal/progressive-onboarding-eligibility/index.tsx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelog/dev-10034-linter-warning-useeffect-unused-import diff --git a/changelog/dev-10034-linter-warning-useeffect-unused-import b/changelog/dev-10034-linter-warning-useeffect-unused-import new file mode 100644 index 00000000000..4d2131a41b7 --- /dev/null +++ b/changelog/dev-10034-linter-warning-useeffect-unused-import @@ -0,0 +1,5 @@ +Significance: patch +Type: dev +Comment: Not user-facing: removed an unused `useEffect` import causing linter warnings + + diff --git a/client/overview/modal/progressive-onboarding-eligibility/index.tsx b/client/overview/modal/progressive-onboarding-eligibility/index.tsx index 6f6be89a707..21a6e5a22fa 100644 --- a/client/overview/modal/progressive-onboarding-eligibility/index.tsx +++ b/client/overview/modal/progressive-onboarding-eligibility/index.tsx @@ -1,7 +1,7 @@ /** * External dependencies */ -import React, { useEffect, useState } from 'react'; +import React, { useState } from 'react'; import { __, sprintf } from '@wordpress/i18n'; import { addQueryArgs } from '@wordpress/url'; import { Button, Modal } from '@wordpress/components'; From 21d5cf8341a6545f59b2d0fc7079c333855a776e Mon Sep 17 00:00:00 2001 From: Nagesh Pai <4162931+nagpai@users.noreply.github.com> Date: Tue, 24 Dec 2024 11:06:26 +0530 Subject: [PATCH 3/3] Add TS type assertion for payout CSV export code for type safety and prevent TypeScript errors (#10030) Co-authored-by: Nagesh Pai --- .../dev-10029-export-deposit-type-assert | 5 +++ client/deposits/list/index.tsx | 35 ++++++++++--------- 2 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 changelog/dev-10029-export-deposit-type-assert diff --git a/changelog/dev-10029-export-deposit-type-assert b/changelog/dev-10029-export-deposit-type-assert new file mode 100644 index 00000000000..684727000a7 --- /dev/null +++ b/changelog/dev-10029-export-deposit-type-assert @@ -0,0 +1,5 @@ +Significance: patch +Type: dev +Comment: Add type assertion for payouts CSV export response to ensure type safety and fix TypeScript linting error + + diff --git a/client/deposits/list/index.tsx b/client/deposits/list/index.tsx index dc3e20ac02a..52194cb184f 100644 --- a/client/deposits/list/index.tsx +++ b/client/deposits/list/index.tsx @@ -260,22 +260,25 @@ export const DepositsList = (): JSX.Element => { window.confirm( confirmMessage ) ) { try { - const { exported_deposits: exportedDeposits } = await apiFetch( - { - path: getDepositsCSV( { - userEmail, - locale, - dateAfter, - dateBefore, - dateBetween, - match, - statusIs, - statusIsNot, - storeCurrencyIs, - } ), - method: 'POST', - } - ); + const { + exported_deposits: exportedDeposits, + } = await apiFetch< { + /** The total number of payouts that will be exported in the CSV */ + exported_deposits: number; + } >( { + path: getDepositsCSV( { + userEmail, + locale, + dateAfter, + dateBefore, + dateBetween, + match, + statusIs, + statusIsNot, + storeCurrencyIs, + } ), + method: 'POST', + } ); createNotice( 'success',