Skip to content

Commit

Permalink
refactor: [Adyen] merge main into adyen_bug_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
swangi-kumari committed Jun 13, 2023
1 parent a88a0e1 commit 21cf13d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 68 deletions.
115 changes: 55 additions & 60 deletions crates/router/src/connector/adyen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,65 +847,60 @@ fn get_browser_info(
if item.auth_type == storage_enums::AuthenticationType::ThreeDs
|| item.payment_method == storage_enums::PaymentMethod::BankRedirect
{
item.request
.browser_info
.as_ref()
.map(|info| {
Ok(AdyenBrowserInfo {
accept_header: info
.accept_header
.clone()
.get_required_value("accept_header")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "accept_header",
})?,
language: info
.language
.clone()
.get_required_value("language")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "language",
})?,
screen_height: info
.screen_height
.get_required_value("screen_height")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "screen_height",
})?,
screen_width: info
.screen_width
.get_required_value("screen_width")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "screen_width",
})?,
color_depth: info
.color_depth
.get_required_value("color_depth")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "color_depth",
})?,
user_agent: info
.user_agent
.clone()
.get_required_value("user_agent")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "user_agent",
})?,
time_zone_offset: info
.time_zone
.get_required_value("time_zone_offset")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "time_zone_offset",
})?,
java_enabled: info
.java_enabled
.get_required_value("java_enabled")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "java_enabled",
})?,
})
})
.transpose()
let info = item.request.get_browser_info()?;
Ok(Some(AdyenBrowserInfo {
accept_header: info
.accept_header
.clone()
.get_required_value("accept_header")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "accept_header",
})?,
language: info
.language
.clone()
.get_required_value("language")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "language",
})?,
screen_height: info
.screen_height
.get_required_value("screen_height")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "screen_height",
})?,
screen_width: info
.screen_width
.get_required_value("screen_width")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "screen_width",
})?,
color_depth: info
.color_depth
.get_required_value("color_depth")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "color_depth",
})?,
user_agent: info
.user_agent
.clone()
.get_required_value("user_agent")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "user_agent",
})?,
time_zone_offset: info
.time_zone
.get_required_value("time_zone_offset")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "time_zone_offset",
})?,
java_enabled: info
.java_enabled
.get_required_value("java_enabled")
.change_context(errors::ConnectorError::MissingRequiredField {
field_name: "java_enabled",
})?,
}))
} else {
Ok(None)
}
Expand Down Expand Up @@ -1061,7 +1056,7 @@ impl<'a> TryFrom<&api::Card> for AdyenPaymentMethod<'a> {
payment_type: PaymentType::Scheme,
number: card.card_number.clone(),
expiry_month: card.card_exp_month.clone(),
expiry_year: card.get_year_in_4_digits(),
expiry_year: card.get_expiry_year_4_digit(),
cvc: Some(card.card_cvc.clone()),
brand: None,
network_payment_reference: None,
Expand Down
8 changes: 0 additions & 8 deletions crates/router/src/connector/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ pub trait CardData {
&self,
delimiter: String,
) -> Secret<String>;
fn get_year_in_4_digits(&self) -> Secret<String>;
fn get_expiry_date_as_yyyymm(&self, delimiter: &str) -> Secret<String>;
fn get_expiry_year_4_digit(&self) -> Secret<String>;
}
Expand All @@ -455,13 +454,6 @@ impl CardData for api::Card {
year.peek()
))
}
fn get_year_in_4_digits(&self) -> Secret<String> {
let mut x = self.card_exp_year.peek().clone();
if x.len() == 2 {
x = format!("20{}", x);
}
Secret::new(x)
}
fn get_expiry_date_as_yyyymm(&self, delimiter: &str) -> Secret<String> {
let year = self.get_expiry_year_4_digit();
Secret::new(format!(
Expand Down

0 comments on commit 21cf13d

Please sign in to comment.