Skip to content

Commit

Permalink
fix(connector): [Worldpay] use 4 digit expiry year
Browse files Browse the repository at this point in the history
  • Loading branch information
kashif-m committed Nov 12, 2024
1 parent 20a3a1c commit 56fa3b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use super::{requests::*, response::*};
use crate::{
types::ResponseRouterData,
utils::{
self, AddressData, ForeignTryFrom, PaymentsAuthorizeRequestData,
self, AddressData, CardData, ForeignTryFrom, PaymentsAuthorizeRequestData,
PaymentsSetupMandateRequestData, RouterData as RouterDataTrait,
},
};
Expand Down Expand Up @@ -77,8 +77,8 @@ fn fetch_payment_instrument(
PaymentMethodData::Card(card) => Ok(PaymentInstrument::Card(CardPayment {
payment_type: PaymentType::Plain,
expiry_date: ExpiryDate {
month: utils::CardData::get_expiry_month_as_i8(&card)?,
year: utils::CardData::get_expiry_year_as_i32(&card)?,
month: card.get_expiry_month_as_i8()?,
year: card.get_expiry_year_as_4_digit_i32()?,
},
card_number: card.card_number,
cvc: card.card_cvc,
Expand Down
9 changes: 9 additions & 0 deletions crates/hyperswitch_connectors/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ pub trait CardData {
fn get_expiry_date_as_mmyy(&self) -> Result<Secret<String>, errors::ConnectorError>;
fn get_expiry_month_as_i8(&self) -> Result<Secret<i8>, Error>;
fn get_expiry_year_as_i32(&self) -> Result<Secret<i32>, Error>;
fn get_expiry_year_as_4_digit_i32(&self) -> Result<Secret<i32>, Error>;
}

impl CardData for Card {
Expand Down Expand Up @@ -922,6 +923,14 @@ impl CardData for Card {
.change_context(errors::ConnectorError::ResponseDeserializationFailed)
.map(Secret::new)
}
fn get_expiry_year_as_4_digit_i32(&self) -> Result<Secret<i32>, Error> {
self.get_expiry_year_4_digit()
.peek()
.clone()
.parse::<i32>()
.change_context(errors::ConnectorError::ResponseDeserializationFailed)
.map(Secret::new)
}
}

#[track_caller]
Expand Down

0 comments on commit 56fa3b8

Please sign in to comment.