Skip to content

Commit

Permalink
Checkout: Short-circuit card processor for failed cards (#79205)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirbrillig authored Jul 10, 2023
1 parent fc4d7e6 commit c75b859
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
makeSuccessResponse,
makeRedirectResponse,
makeErrorResponse,
PaymentProcessorResponseType,
} from '@automattic/composite-checkout';
import debugFactory from 'debug';
import { createEbanxToken } from 'calypso/lib/store-transactions';
Expand Down Expand Up @@ -294,6 +295,10 @@ export default async function multiPartnerCardProcessor(
address: dataForProcessor.contactDetails?.address1?.value,
}
);
if ( newCardResponse.type === PaymentProcessorResponseType.ERROR ) {
return newCardResponse;
}

const storedCard = newCardResponse.payload;
if ( ! isValidNewCardResponseData( storedCard ) ) {
throw new Error( 'New card was not saved' );
Expand Down

0 comments on commit c75b859

Please sign in to comment.