diff --git a/assets/js/base/context/providers/cart-checkout/checkout-processor.ts b/assets/js/base/context/providers/cart-checkout/checkout-processor.ts index 885410fd8f6..49029b4415d 100644 --- a/assets/js/base/context/providers/cart-checkout/checkout-processor.ts +++ b/assets/js/base/context/providers/cart-checkout/checkout-processor.ts @@ -106,7 +106,7 @@ const CheckoutProcessor = () => { }; }, [] ); - const { __internalSetPaymentFailed, __internalSetPaymentSuccess } = + const { __internalSetPaymentError, __internalSetPaymentSuccess } = useDispatch( PAYMENT_STORE_KEY ); const paymentMethods = getPaymentMethods(); @@ -267,7 +267,7 @@ const CheckoutProcessor = () => { setIsProcessingOrder( false ); } ) .catch( ( errorResponse: ApiResponse< CheckoutResponseError > ) => { - __internalSetPaymentFailed(); + __internalSetPaymentError(); processCheckoutResponseHeaders( errorResponse?.headers ); try { // This attempts to parse a JSON error response where the status code was 4xx/5xx. diff --git a/assets/js/data/payment/action-types.ts b/assets/js/data/payment/action-types.ts index e61ef232c83..7e567ee79e4 100644 --- a/assets/js/data/payment/action-types.ts +++ b/assets/js/data/payment/action-types.ts @@ -3,7 +3,6 @@ export enum ACTION_TYPES { SET_PAYMENT_IDLE = 'SET_PAYMENT_IDLE', SET_PAYMENT_STARTED = 'SET_PAYMENT_STARTED', SET_PAYMENT_PROCESSING = 'SET_PAYMENT_PROCESSING', - SET_PAYMENT_FAILED = 'SET_PAYMENT_FAILED', SET_PAYMENT_ERROR = 'SET_PAYMENT_ERROR', SET_PAYMENT_SUCCESS = 'SET_PAYMENT_SUCCESS', SET_PAYMENT_READY = 'SET_PAYMENT_READY', diff --git a/assets/js/data/payment/actions.ts b/assets/js/data/payment/actions.ts index cdd11884b19..a1a43bbbe59 100644 --- a/assets/js/data/payment/actions.ts +++ b/assets/js/data/payment/actions.ts @@ -29,10 +29,6 @@ export const __internalSetPaymentProcessing = () => ( { type: ACTION_TYPES.SET_PAYMENT_PROCESSING, } ); -export const __internalSetPaymentFailed = () => ( { - type: ACTION_TYPES.SET_PAYMENT_FAILED, -} ); - export const __internalSetPaymentError = () => ( { type: ACTION_TYPES.SET_PAYMENT_ERROR, } ); diff --git a/assets/js/data/payment/constants.ts b/assets/js/data/payment/constants.ts index 8f93c8ac0df..f1bf2ba7190 100644 --- a/assets/js/data/payment/constants.ts +++ b/assets/js/data/payment/constants.ts @@ -6,7 +6,6 @@ export enum STATUS { STARTED = 'started', PROCESSING = 'processing', ERROR = 'has_error', - FAILED = 'failed', SUCCESS = 'success', READY = 'ready', // Indicates observers have finished processing and payment is ready to be processed. } diff --git a/assets/js/data/payment/reducers.ts b/assets/js/data/payment/reducers.ts index 8a3adcc5325..7fc92dfd089 100644 --- a/assets/js/data/payment/reducers.ts +++ b/assets/js/data/payment/reducers.ts @@ -45,13 +45,6 @@ const reducer: Reducer< PaymentState > = ( }; break; - case ACTION_TYPES.SET_PAYMENT_FAILED: - newState = { - ...state, - status: STATUS.FAILED, - }; - break; - case ACTION_TYPES.SET_PAYMENT_ERROR: newState = { ...state, diff --git a/assets/js/data/payment/selectors.ts b/assets/js/data/payment/selectors.ts index 00377b76161..66ff2558d0e 100644 --- a/assets/js/data/payment/selectors.ts +++ b/assets/js/data/payment/selectors.ts @@ -13,7 +13,7 @@ import { STATUS as PAYMENT_STATUS } from './constants'; export const isPaymentPristine = ( state: PaymentState ) => { deprecated( 'isPaymentPristine', { - since: '9.3.0', + since: '9.5.0', alternative: 'isPaymentIdle', plugin: 'WooCommerce Blocks', link: 'https://github.com/woocommerce/woocommerce-blocks/pull/8110', @@ -38,8 +38,15 @@ export const isPaymentSuccess = ( state: PaymentState ) => export const hasPaymentError = ( state: PaymentState ) => state.status === PAYMENT_STATUS.ERROR; -export const isPaymentFailed = ( state: PaymentState ) => - state.status === PAYMENT_STATUS.FAILED; +export const isPaymentFailed = ( state: PaymentState ) => { + deprecated( 'isPaymentFailed', { + since: '9.5.0', + alternative: 'hasPaymentError', + plugin: 'WooCommerce Blocks', + link: 'https://github.com/woocommerce/woocommerce-blocks/pull/8110', + } ); + return hasPaymentError( state ); +}; export const isPaymentReady = ( state: PaymentState ) => state.status === PAYMENT_STATUS.READY; diff --git a/assets/js/data/payment/test/set-default-payment-method.ts b/assets/js/data/payment/test/set-default-payment-method.ts index e54cd8777f2..3771966fa5a 100644 --- a/assets/js/data/payment/test/set-default-payment-method.ts +++ b/assets/js/data/payment/test/set-default-payment-method.ts @@ -126,7 +126,6 @@ describe( 'setDefaultPaymentMethod', () => { __internalSetActivePaymentMethod: setActivePaymentMethodMock, __internalSetPaymentError: () => void 0, - __internalSetPaymentFailed: () => void 0, __internalSetPaymentSuccess: () => void 0, __internalSetPaymentIdle: () => void 0, __internalSetPaymentStarted: () => void 0,