Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Remove FINISHED as a status
Browse files Browse the repository at this point in the history
  • Loading branch information
alexflorisca committed Jan 20, 2023
1 parent a41249f commit 38d66ed
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const CheckoutProcessor = () => {
};
}, [] );

const { __internalSetPaymentFailed, __internalSetPaymentSuccess } =
const { __internalSetPaymentError, __internalSetPaymentSuccess } =
useDispatch( PAYMENT_STORE_KEY );

const paymentMethods = getPaymentMethods();
Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion assets/js/data/payment/action-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 0 additions & 4 deletions assets/js/data/payment/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
} );
Expand Down
1 change: 0 additions & 1 deletion assets/js/data/payment/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
7 changes: 0 additions & 7 deletions assets/js/data/payment/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 10 additions & 3 deletions assets/js/data/payment/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion assets/js/data/payment/test/set-default-payment-method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ describe( 'setDefaultPaymentMethod', () => {
__internalSetActivePaymentMethod:
setActivePaymentMethodMock,
__internalSetPaymentError: () => void 0,
__internalSetPaymentFailed: () => void 0,
__internalSetPaymentSuccess: () => void 0,
__internalSetPaymentIdle: () => void 0,
__internalSetPaymentStarted: () => void 0,
Expand Down

0 comments on commit 38d66ed

Please sign in to comment.