Skip to content

Commit

Permalink
fix(connector): 5xx error for Volt Payment Sync (#6846)
Browse files Browse the repository at this point in the history
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
swangi-kumari and hyperswitch-bot[bot] authored Dec 17, 2024
1 parent 7556372 commit 588ce40
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions crates/hyperswitch_connectors/src/connectors/volt/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,22 +235,27 @@ impl TryFrom<&ConnectorAuthType> for VoltAuthType {
}
}

impl From<VoltPaymentStatus> 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,
}
}

Expand Down Expand Up @@ -309,6 +314,7 @@ pub enum VoltPaymentStatus {
AbandonedByUser,
Failed,
Settled,
Unknown,
}

#[derive(Debug, Serialize, Deserialize)]
Expand All @@ -335,7 +341,8 @@ impl<F, T> TryFrom<ResponseRouterData<F, VoltPaymentsResponseData, T, PaymentsRe
) -> Result<Self, Self::Error> {
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) {
Expand Down

0 comments on commit 588ce40

Please sign in to comment.