diff --git a/client/my-sites/checkout/src/lib/existing-card-processor.ts b/client/my-sites/checkout/src/lib/existing-card-processor.ts index 152ef746d51cd..2478d33676da1 100644 --- a/client/my-sites/checkout/src/lib/existing-card-processor.ts +++ b/client/my-sites/checkout/src/lib/existing-card-processor.ts @@ -119,13 +119,14 @@ export default async function existingCardProcessor( } return stripeResponse; } ) - .then( ( stripeResponse ) => { - if ( stripeResponse?.redirect_url && ! doesTransactionResponseRequire3DS( stripeResponse ) ) { - debug( 'transaction requires redirect' ); - return makeRedirectResponse( stripeResponse.redirect_url ); + .then( ( response ) => { + if ( ! response || ! ( 'redirect_url' in response ) || ! response.redirect_url ) { + return makeSuccessResponse( response ); } - debug( 'transaction was successful' ); - return makeSuccessResponse( stripeResponse ); + if ( ! doesTransactionResponseRequire3DS( response ) ) { + return makeRedirectResponse( response.redirect_url ); + } + return makeSuccessResponse( response ); } ) .catch( ( error: Error ) => { debug( 'transaction failed' ); diff --git a/client/my-sites/checkout/src/lib/generic-redirect-processor.ts b/client/my-sites/checkout/src/lib/generic-redirect-processor.ts index 934cbbf04e6b0..1b82c38a1810c 100644 --- a/client/my-sites/checkout/src/lib/generic-redirect-processor.ts +++ b/client/my-sites/checkout/src/lib/generic-redirect-processor.ts @@ -76,10 +76,10 @@ export default async function genericRedirectProcessor( return submitWpcomTransaction( formattedTransactionData, transactionOptions ) .then( ( response?: WPCOMTransactionEndpointResponse ) => { - if ( ! response?.redirect_url ) { - throw new Error( 'Error during transaction' ); + if ( ! response || ! ( 'redirect_url' in response ) || ! response.redirect_url ) { + throw new Error( 'Error during transaction: no redirect URL' ); } - return makeRedirectResponse( response?.redirect_url ); + return makeRedirectResponse( response.redirect_url ); } ) .catch( ( error ) => makeErrorResponse( error.message ) ); } diff --git a/client/my-sites/checkout/src/lib/multi-partner-card-processor.ts b/client/my-sites/checkout/src/lib/multi-partner-card-processor.ts index 984f042115229..0a471a76ffb05 100644 --- a/client/my-sites/checkout/src/lib/multi-partner-card-processor.ts +++ b/client/my-sites/checkout/src/lib/multi-partner-card-processor.ts @@ -159,11 +159,14 @@ async function stripeCardProcessor( } return stripeResponse; } ) - .then( ( stripeResponse ) => { - if ( stripeResponse.redirect_url && ! doesTransactionResponseRequire3DS( stripeResponse ) ) { - return makeRedirectResponse( stripeResponse.redirect_url ); + .then( ( response ) => { + if ( ! response || ! ( 'redirect_url' in response ) || ! response.redirect_url ) { + return makeSuccessResponse( response ); } - return makeSuccessResponse( stripeResponse ); + if ( ! doesTransactionResponseRequire3DS( response ) ) { + return makeRedirectResponse( response.redirect_url ); + } + return makeSuccessResponse( response ); } ) .catch( ( error: Error ) => { debug( 'transaction failed' ); diff --git a/client/my-sites/checkout/src/lib/pix-processor.ts b/client/my-sites/checkout/src/lib/pix-processor.ts index 3669f6c4a352e..0e1da0c69f9b2 100644 --- a/client/my-sites/checkout/src/lib/pix-processor.ts +++ b/client/my-sites/checkout/src/lib/pix-processor.ts @@ -109,7 +109,7 @@ export async function pixProcessor( return submitWpcomTransaction( formattedTransactionData, options ) .then( async ( response?: WPCOMTransactionEndpointResponse ) => { - if ( ! response?.redirect_url ) { + if ( ! response || ! ( 'redirect_url' in response ) || ! response.redirect_url ) { // eslint-disable-next-line no-console console.error( 'Transaction response was missing required redirect url' ); throw new Error( genericErrorMessage ); diff --git a/client/my-sites/checkout/src/lib/we-chat-processor.ts b/client/my-sites/checkout/src/lib/we-chat-processor.ts index 9c6239676b086..4e85504b426a0 100644 --- a/client/my-sites/checkout/src/lib/we-chat-processor.ts +++ b/client/my-sites/checkout/src/lib/we-chat-processor.ts @@ -95,7 +95,7 @@ export default async function weChatProcessor( return submitWpcomTransaction( formattedTransactionData, options ) .then( async ( response?: WPCOMTransactionEndpointResponse ) => { - if ( ! response?.redirect_url ) { + if ( ! response || ! ( 'redirect_url' in response ) || ! response.redirect_url ) { // eslint-disable-next-line no-console console.error( 'Transaction response was missing required redirect url' ); throw new Error( genericErrorMessage );