Skip to content

Commit 588ce40

Browse files
fix(connector): 5xx error for Volt Payment Sync (#6846)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent 7556372 commit 588ce40

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

crates/hyperswitch_connectors/src/connectors/volt/transformers.rs

+23-16
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,27 @@ impl TryFrom<&ConnectorAuthType> for VoltAuthType {
235235
}
236236
}
237237

238-
impl From<VoltPaymentStatus> for enums::AttemptStatus {
239-
fn from(item: VoltPaymentStatus) -> Self {
240-
match item {
241-
VoltPaymentStatus::Received | VoltPaymentStatus::Settled => Self::Charged,
242-
VoltPaymentStatus::Completed | VoltPaymentStatus::DelayedAtBank => Self::Pending,
243-
VoltPaymentStatus::NewPayment
244-
| VoltPaymentStatus::BankRedirect
245-
| VoltPaymentStatus::AwaitingCheckoutAuthorisation => Self::AuthenticationPending,
246-
VoltPaymentStatus::RefusedByBank
247-
| VoltPaymentStatus::RefusedByRisk
248-
| VoltPaymentStatus::NotReceived
249-
| VoltPaymentStatus::ErrorAtBank
250-
| VoltPaymentStatus::CancelledByUser
251-
| VoltPaymentStatus::AbandonedByUser
252-
| VoltPaymentStatus::Failed => Self::Failure,
238+
fn get_attempt_status(
239+
(item, current_status): (VoltPaymentStatus, enums::AttemptStatus),
240+
) -> enums::AttemptStatus {
241+
match item {
242+
VoltPaymentStatus::Received | VoltPaymentStatus::Settled => enums::AttemptStatus::Charged,
243+
VoltPaymentStatus::Completed | VoltPaymentStatus::DelayedAtBank => {
244+
enums::AttemptStatus::Pending
253245
}
246+
VoltPaymentStatus::NewPayment
247+
| VoltPaymentStatus::BankRedirect
248+
| VoltPaymentStatus::AwaitingCheckoutAuthorisation => {
249+
enums::AttemptStatus::AuthenticationPending
250+
}
251+
VoltPaymentStatus::RefusedByBank
252+
| VoltPaymentStatus::RefusedByRisk
253+
| VoltPaymentStatus::NotReceived
254+
| VoltPaymentStatus::ErrorAtBank
255+
| VoltPaymentStatus::CancelledByUser
256+
| VoltPaymentStatus::AbandonedByUser
257+
| VoltPaymentStatus::Failed => enums::AttemptStatus::Failure,
258+
VoltPaymentStatus::Unknown => current_status,
254259
}
255260
}
256261

@@ -309,6 +314,7 @@ pub enum VoltPaymentStatus {
309314
AbandonedByUser,
310315
Failed,
311316
Settled,
317+
Unknown,
312318
}
313319

314320
#[derive(Debug, Serialize, Deserialize)]
@@ -335,7 +341,8 @@ impl<F, T> TryFrom<ResponseRouterData<F, VoltPaymentsResponseData, T, PaymentsRe
335341
) -> Result<Self, Self::Error> {
336342
match item.response {
337343
VoltPaymentsResponseData::PsyncResponse(payment_response) => {
338-
let status = enums::AttemptStatus::from(payment_response.status.clone());
344+
let status =
345+
get_attempt_status((payment_response.status.clone(), item.data.status));
339346
Ok(Self {
340347
status,
341348
response: if is_payment_failure(status) {

0 commit comments

Comments
 (0)