From 588ce408b4b04bdd89f2594239e7efc9e0f66114 Mon Sep 17 00:00:00 2001 From: Swangi Kumari <85639103+swangi-kumari@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:54:05 +0530 Subject: [PATCH] fix(connector): 5xx error for Volt Payment Sync (#6846) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- .../src/connectors/volt/transformers.rs | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/crates/hyperswitch_connectors/src/connectors/volt/transformers.rs b/crates/hyperswitch_connectors/src/connectors/volt/transformers.rs index 61cf91c87cb8..a0d349eaa984 100644 --- a/crates/hyperswitch_connectors/src/connectors/volt/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/volt/transformers.rs @@ -235,22 +235,27 @@ impl TryFrom<&ConnectorAuthType> for VoltAuthType { } } -impl From for enums::AttemptStatus { - fn from(item: VoltPaymentStatus) -> Self { - match item { - VoltPaymentStatus::Received | VoltPaymentStatus::Settled => Self::Charged, - VoltPaymentStatus::Completed | VoltPaymentStatus::DelayedAtBank => Self::Pending, - VoltPaymentStatus::NewPayment - | VoltPaymentStatus::BankRedirect - | VoltPaymentStatus::AwaitingCheckoutAuthorisation => Self::AuthenticationPending, - VoltPaymentStatus::RefusedByBank - | VoltPaymentStatus::RefusedByRisk - | VoltPaymentStatus::NotReceived - | VoltPaymentStatus::ErrorAtBank - | VoltPaymentStatus::CancelledByUser - | VoltPaymentStatus::AbandonedByUser - | VoltPaymentStatus::Failed => Self::Failure, +fn get_attempt_status( + (item, current_status): (VoltPaymentStatus, enums::AttemptStatus), +) -> enums::AttemptStatus { + match item { + VoltPaymentStatus::Received | VoltPaymentStatus::Settled => enums::AttemptStatus::Charged, + VoltPaymentStatus::Completed | VoltPaymentStatus::DelayedAtBank => { + enums::AttemptStatus::Pending } + VoltPaymentStatus::NewPayment + | VoltPaymentStatus::BankRedirect + | VoltPaymentStatus::AwaitingCheckoutAuthorisation => { + enums::AttemptStatus::AuthenticationPending + } + VoltPaymentStatus::RefusedByBank + | VoltPaymentStatus::RefusedByRisk + | VoltPaymentStatus::NotReceived + | VoltPaymentStatus::ErrorAtBank + | VoltPaymentStatus::CancelledByUser + | VoltPaymentStatus::AbandonedByUser + | VoltPaymentStatus::Failed => enums::AttemptStatus::Failure, + VoltPaymentStatus::Unknown => current_status, } } @@ -309,6 +314,7 @@ pub enum VoltPaymentStatus { AbandonedByUser, Failed, Settled, + Unknown, } #[derive(Debug, Serialize, Deserialize)] @@ -335,7 +341,8 @@ impl TryFrom Result { match item.response { VoltPaymentsResponseData::PsyncResponse(payment_response) => { - let status = enums::AttemptStatus::from(payment_response.status.clone()); + let status = + get_attempt_status((payment_response.status.clone(), item.data.status)); Ok(Self { status, response: if is_payment_failure(status) {