From b1a8d91bbc6a9b02600958ff4c422282e0865b5f Mon Sep 17 00:00:00 2001 From: DEEPANSHU BANSAL Date: Fri, 1 Dec 2023 16:23:12 +0530 Subject: [PATCH 1/2] feat(connector): [BOA/CYBERSOURCE] Fix Status Mapping for Terminal State of Payments --- .../router/src/connector/bankofamerica/transformers.rs | 10 ++++++++-- .../router/src/connector/cybersource/transformers.rs | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/router/src/connector/bankofamerica/transformers.rs b/crates/router/src/connector/bankofamerica/transformers.rs index a6fa8652b27d..7456895c8a49 100644 --- a/crates/router/src/connector/bankofamerica/transformers.rs +++ b/crates/router/src/connector/bankofamerica/transformers.rs @@ -277,11 +277,18 @@ impl ForeignFrom<(BankofamericaPaymentStatus, bool)> for enums::AttemptStatus { | BankofamericaPaymentStatus::AuthorizedPendingReview => { if auto_capture { // Because BankOfAmerica will return Payment Status as Authorized even in AutoCapture Payment - Self::Pending + Self::Charged } else { Self::Authorized } } + BankofamericaPaymentStatus::Pending => { + if auto_capture { + Self::Charged + } else { + Self::Pending + } + } BankofamericaPaymentStatus::Succeeded | BankofamericaPaymentStatus::Transmitted => { Self::Charged } @@ -291,7 +298,6 @@ impl ForeignFrom<(BankofamericaPaymentStatus, bool)> for enums::AttemptStatus { BankofamericaPaymentStatus::Failed | BankofamericaPaymentStatus::Declined => { Self::Failure } - BankofamericaPaymentStatus::Pending => Self::Pending, } } } diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs index 9233a95d7dd7..7ea890b37d13 100644 --- a/crates/router/src/connector/cybersource/transformers.rs +++ b/crates/router/src/connector/cybersource/transformers.rs @@ -405,8 +405,9 @@ pub struct ApplicationInformation { fn get_payment_status(is_capture: bool, status: enums::AttemptStatus) -> enums::AttemptStatus { let is_authorized = matches!(status, enums::AttemptStatus::Authorized); - if is_capture && is_authorized { - return enums::AttemptStatus::Pending; + let is_pending = matches!(status, enums::AttemptStatus::Pending); + if is_capture && (is_authorized || is_pending) { + return enums::AttemptStatus::Charged; } status } From 95b3b4f6d03fa5a1561362a90a82b80c2845aecc Mon Sep 17 00:00:00 2001 From: DEEPANSHU BANSAL Date: Sun, 17 Dec 2023 12:36:57 +0530 Subject: [PATCH 2/2] Revert "feat(connector): [BOA/CYBERSOURCE] Fix Status Mapping for Terminal State of Payments" This reverts commit b1a8d91bbc6a9b02600958ff4c422282e0865b5f. --- .../router/src/connector/bankofamerica/transformers.rs | 10 ++-------- .../router/src/connector/cybersource/transformers.rs | 5 ++--- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/crates/router/src/connector/bankofamerica/transformers.rs b/crates/router/src/connector/bankofamerica/transformers.rs index 7456895c8a49..a6fa8652b27d 100644 --- a/crates/router/src/connector/bankofamerica/transformers.rs +++ b/crates/router/src/connector/bankofamerica/transformers.rs @@ -277,18 +277,11 @@ impl ForeignFrom<(BankofamericaPaymentStatus, bool)> for enums::AttemptStatus { | BankofamericaPaymentStatus::AuthorizedPendingReview => { if auto_capture { // Because BankOfAmerica will return Payment Status as Authorized even in AutoCapture Payment - Self::Charged + Self::Pending } else { Self::Authorized } } - BankofamericaPaymentStatus::Pending => { - if auto_capture { - Self::Charged - } else { - Self::Pending - } - } BankofamericaPaymentStatus::Succeeded | BankofamericaPaymentStatus::Transmitted => { Self::Charged } @@ -298,6 +291,7 @@ impl ForeignFrom<(BankofamericaPaymentStatus, bool)> for enums::AttemptStatus { BankofamericaPaymentStatus::Failed | BankofamericaPaymentStatus::Declined => { Self::Failure } + BankofamericaPaymentStatus::Pending => Self::Pending, } } } diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs index 7ea890b37d13..9233a95d7dd7 100644 --- a/crates/router/src/connector/cybersource/transformers.rs +++ b/crates/router/src/connector/cybersource/transformers.rs @@ -405,9 +405,8 @@ pub struct ApplicationInformation { fn get_payment_status(is_capture: bool, status: enums::AttemptStatus) -> enums::AttemptStatus { let is_authorized = matches!(status, enums::AttemptStatus::Authorized); - let is_pending = matches!(status, enums::AttemptStatus::Pending); - if is_capture && (is_authorized || is_pending) { - return enums::AttemptStatus::Charged; + if is_capture && is_authorized { + return enums::AttemptStatus::Pending; } status }