Skip to content

Commit

Permalink
Refactor: Customer email and browser Information (#7034)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmeyWale authored Jan 21, 2025
1 parent d6b0660 commit d35a922
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
21 changes: 21 additions & 0 deletions crates/hyperswitch_domain_models/src/router_request_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,27 @@ pub struct BrowserInformation {
pub device_model: Option<String>,
}

#[cfg(feature = "v2")]
impl From<common_utils::types::BrowserInformation> for BrowserInformation {
fn from(value: common_utils::types::BrowserInformation) -> Self {
Self {
color_depth: value.color_depth,
java_enabled: value.java_enabled,
java_script_enabled: value.java_script_enabled,
language: value.language,
screen_height: value.screen_height,
screen_width: value.screen_width,
time_zone: value.time_zone,
ip_address: value.ip_address,
accept_header: value.accept_header,
user_agent: value.user_agent,
os_type: value.os_type,
os_version: value.os_version,
device_model: value.device_model,
}
}
}

#[derive(Debug, Clone, Default, Serialize)]
pub enum ResponseId {
ConnectorTransactionId(String),
Expand Down
15 changes: 13 additions & 2 deletions crates/router/src/core/payments/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,17 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
.map(|id| id.get_string_repr().to_owned())
.unwrap_or(payment_data.payment_attempt.id.get_string_repr().to_owned());

let email = customer
.as_ref()
.and_then(|customer| customer.email.clone())
.map(pii::Email::from);

let browser_info = payment_data
.payment_attempt
.browser_info
.clone()
.map(types::BrowserInformation::from);

// TODO: few fields are repeated in both routerdata and request
let request = types::PaymentsAuthorizeData {
payment_method_data: payment_data
Expand All @@ -262,8 +273,8 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
minor_amount: payment_data.payment_attempt.amount_details.get_net_amount(),
order_tax_amount: None,
currency: payment_data.payment_intent.amount_details.currency,
browser_info: None,
email: None,
browser_info,
email,
customer_name: None,
payment_experience: None,
order_details: None,
Expand Down

0 comments on commit d35a922

Please sign in to comment.