From 521c606e3df16d9a515e409580731210bca8450b Mon Sep 17 00:00:00 2001 From: julianajlk Date: Tue, 9 Apr 2024 09:19:17 -0400 Subject: [PATCH] fix: Reorder error type in handleRequestError from feedback --- src/payment/data/handleRequestError.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/payment/data/handleRequestError.js b/src/payment/data/handleRequestError.js index 9ef40024d..5a2a0a9bd 100644 --- a/src/payment/data/handleRequestError.js +++ b/src/payment/data/handleRequestError.js @@ -84,25 +84,25 @@ export default function handleRequestError(error) { ]); } - // For a Payment Intent to be confirmable, it must be in requires_payment_method or requires_confirmation - if (error.code === 'payment_intent_unexpected_state' && error.type === 'invalid_request_error') { - logInfo('Basket Changed Error', error.code); + // Country not DPM compatible + if (error.type === 'invalid_request_error' && ( + error.param === 'payment_method_data[billing_details][address][country]' || error.param === 'billing_details[address][state]' || error.param === 'billing_details[address][postal_code]' + )) { + logInfo('Dynamic Payment Method Country Error', error.param); handleApiErrors([ { - error_code: 'basket-changed-error-message', + error_code: 'dynamic-payment-methods-country-not-compatible', user_message: 'error', }, ]); } - // Country not DPM compatible - if (error.type === 'invalid_request_error' && ( - error.param === 'payment_method_data[billing_details][address][country]' || error.param === 'billing_details[address][state]' || error.param === 'billing_details[address][postal_code]' - )) { - logInfo('Dynamic Payment Method Country Error', error.param); + // For a Payment Intent to be confirmable, it must be in requires_payment_method or requires_confirmation + if (error.code === 'payment_intent_unexpected_state' && error.type === 'invalid_request_error') { + logInfo('Basket Changed Error', error.code); handleApiErrors([ { - error_code: 'dynamic-payment-methods-country-not-compatible', + error_code: 'basket-changed-error-message', user_message: 'error', }, ]);