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 7b819f3afc4..885410fd8f6 100644 --- a/assets/js/base/context/providers/cart-checkout/checkout-processor.ts +++ b/assets/js/base/context/providers/cart-checkout/checkout-processor.ts @@ -106,6 +106,9 @@ const CheckoutProcessor = () => { }; }, [] ); + const { __internalSetPaymentFailed, __internalSetPaymentSuccess } = + useDispatch( PAYMENT_STORE_KEY ); + const paymentMethods = getPaymentMethods(); const expressPaymentMethods = getExpressPaymentMethods(); const currentBillingAddress = useRef( billingAddress ); @@ -256,6 +259,7 @@ const CheckoutProcessor = () => { if ( ! response.ok ) { throw response; } + __internalSetPaymentSuccess(); return response.json(); } ) .then( ( responseJson: CheckoutResponseSuccess ) => { @@ -263,6 +267,7 @@ const CheckoutProcessor = () => { setIsProcessingOrder( false ); } ) .catch( ( errorResponse: ApiResponse< CheckoutResponseError > ) => { + __internalSetPaymentFailed(); 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/selectors.ts b/assets/js/data/payment/selectors.ts index f3eb6edc285..00377b76161 100644 --- a/assets/js/data/payment/selectors.ts +++ b/assets/js/data/payment/selectors.ts @@ -47,7 +47,6 @@ export const isPaymentReady = ( state: PaymentState ) => export const isPaymentFinished = ( state: PaymentState ) => { return ( state.status === PAYMENT_STATUS.SUCCESS || - state.status === PAYMENT_STATUS.ERROR || state.status === PAYMENT_STATUS.FAILED ); };