Skip to content

Commit

Permalink
chore: run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperswitch-bot[bot] committed Dec 23, 2024
1 parent 5c13cc8 commit 9ac6dfa
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 82 deletions.
3 changes: 2 additions & 1 deletion crates/diesel_models/src/business_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ impl ProfileUpdateInternal {
.unwrap_or(source.is_click_to_pay_enabled),
authentication_product_ids: authentication_product_ids
.or(source.authentication_product_ids),
is_tokenize_before_payment_enabled: is_tokenize_before_payment_enabled.unwrap_or(source.is_tokenize_before_payment_enabled),
is_tokenize_before_payment_enabled: is_tokenize_before_payment_enabled
.unwrap_or(source.is_tokenize_before_payment_enabled),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct CardNetworkTokenResponse {
pub struct CardNetworkTokenResponsePayload {
pub card_brand: api_enums::CardNetwork,
pub card_fingerprint: Option<Secret<String>>,
pub card_reference: String,//
pub card_reference: String, //
pub correlation_id: String,
pub customer_id: String,
pub par: String,
Expand Down
135 changes: 83 additions & 52 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,15 @@ where
}
_ => (),
};
let customer_acceptance = payment_data.get_payment_attempt().customer_acceptance.clone();
let customer_acceptance = payment_data
.get_payment_attempt()
.customer_acceptance
.clone();
let customer_id = payment_data.get_payment_intent().customer_id.clone();
let payment_method_data = payment_data.get_payment_method_data();
let is_pre_tokenization_enabled = business_profile.is_network_tokenization_enabled && business_profile.is_tokenize_before_payment_enabled && customer_acceptance.is_some();
let is_pre_tokenization_enabled = business_profile.is_network_tokenization_enabled
&& business_profile.is_tokenize_before_payment_enabled
&& customer_acceptance.is_some();
payment_data = match connector_details {
ConnectorCallType::PreDetermined(connector) => {
#[cfg(all(feature = "dynamic_routing", feature = "v1"))]
Expand All @@ -464,32 +469,43 @@ where
.network_transaction_id_supported_connectors
.connector_list;
//filered connectors list with ntid_supported_connectors
let filtered_ntid_supported_connectors =
filter_ntid_supported_connectors([connector.clone()].to_vec(), ntid_supported_connectors);
let filtered_ntid_supported_connectors = filter_ntid_supported_connectors(
[connector.clone()].to_vec(),
ntid_supported_connectors,
);

//fetch connectors that support network tokenization flow
let network_tokenization_supported_connectors = &state
.conf
.network_tokenization_supported_connectors
.connector_list;
//filered connectors list with ntid_supported_connectors and network_tokenization_supported_connectors
let filtered_nt_supported_connectors = filter_network_tokenization_supported_connectors(
filtered_ntid_supported_connectors,
network_tokenization_supported_connectors,
);
let filtered_nt_supported_connectors =
filter_network_tokenization_supported_connectors(
filtered_ntid_supported_connectors,
network_tokenization_supported_connectors,
);

let is_nt_supported_connector_available = filtered_nt_supported_connectors.first().is_some();
let is_nt_supported_connector_available =
filtered_nt_supported_connectors.first().is_some();

if is_pre_tokenization_enabled && is_nt_supported_connector_available {
let pre_tokenization_response = tokenization::pre_payment_tokenization(state,customer_id, payment_method_data).await?;
let pre_tokenization_response = tokenization::pre_payment_tokenization(
state,
customer_id,
payment_method_data,
)
.await?;
let pm_data = payment_data.get_payment_method_data();
match pre_tokenization_response {
(Some(token_response),Some(_token_ref)) => {
(Some(token_response), Some(_token_ref)) => {
let token_data = domain::NetworkTokenData {
token_number: token_response.authentication_details.token,
token_exp_month: token_response.token_details.exp_month,
token_exp_year: token_response.token_details.exp_year,
token_cryptogram: Some(token_response.authentication_details.cryptogram),
token_cryptogram: Some(
token_response.authentication_details.cryptogram,
),
card_issuer: None,
card_network: None,
card_type: None,
Expand All @@ -504,21 +520,23 @@ where
card_data: card_data.clone(),
network_token_data: token_data.clone(),
};
payment_data.set_vault_operation(PaymentMethodDataAction::VaultData(vault_data.clone()))
},
_ => ()
}
payment_data.set_payment_method_data(Some(domain::PaymentMethodData::NetworkToken(token_data)));

}
_ => {
match pm_data {
Some(domain::PaymentMethodData::Card(card_data)) => {
payment_data.set_vault_operation(PaymentMethodDataAction::SaveCardData(card_data.clone()))
},
_ => ()
payment_data.set_vault_operation(
PaymentMethodDataAction::VaultData(vault_data.clone()),
)
}
_ => (),
}
payment_data.set_payment_method_data(Some(
domain::PaymentMethodData::NetworkToken(token_data),
));
}
_ => match pm_data {
Some(domain::PaymentMethodData::Card(card_data)) => payment_data
.set_vault_operation(PaymentMethodDataAction::SaveCardData(
card_data.clone(),
)),
_ => (),
},
}
}
let (router_data, mca) = call_connector_service(
Expand Down Expand Up @@ -605,41 +623,52 @@ where
convert_connector_data_to_routable_connectors(&connectors)
.map_err(|e| logger::error!(routable_connector_error=?e))
.unwrap_or_default();

let ntid_supported_connectors = &state
.conf
.network_transaction_id_supported_connectors
.connector_list;
//filered connectors list with ntid_supported_connectors
let filtered_ntid_supported_connectors =
filter_ntid_supported_connectors(connectors.clone(), ntid_supported_connectors);
let filtered_ntid_supported_connectors = filter_ntid_supported_connectors(
connectors.clone(),
ntid_supported_connectors,
);

//fetch connectors that support network tokenization flow
let network_tokenization_supported_connectors = &state
.conf
.network_tokenization_supported_connectors
.connector_list;
//filered connectors list with ntid_supported_connectors and network_tokenization_supported_connectors
let filtered_nt_supported_connectors = filter_network_tokenization_supported_connectors(
filtered_ntid_supported_connectors,
network_tokenization_supported_connectors,
);
let is_nt_supported_connector_available = filtered_nt_supported_connectors.first().is_some();
let filtered_nt_supported_connectors =
filter_network_tokenization_supported_connectors(
filtered_ntid_supported_connectors,
network_tokenization_supported_connectors,
);
let is_nt_supported_connector_available =
filtered_nt_supported_connectors.first().is_some();

let mut connectors = connectors.into_iter();

let connector_data = get_connector_data(&mut connectors)?;

if is_pre_tokenization_enabled && is_nt_supported_connector_available {
let pre_tokenization_response = tokenization::pre_payment_tokenization(state,customer_id, payment_method_data).await?;
let pre_tokenization_response = tokenization::pre_payment_tokenization(
state,
customer_id,
payment_method_data,
)
.await?;
let pm_data = payment_data.get_payment_method_data();
match pre_tokenization_response {
(Some(token_response),Some(_token_ref)) => {
(Some(token_response), Some(_token_ref)) => {
let token_data = domain::NetworkTokenData {
token_number: token_response.authentication_details.token,
token_exp_month: token_response.token_details.exp_month,
token_exp_year: token_response.token_details.exp_year,
token_cryptogram: Some(token_response.authentication_details.cryptogram),
token_cryptogram: Some(
token_response.authentication_details.cryptogram,
),
card_issuer: None,
card_network: None,
card_type: None,
Expand All @@ -654,22 +683,24 @@ where
card_data: card_data.clone(),
network_token_data: token_data.clone(),
};
payment_data.set_vault_operation(PaymentMethodDataAction::VaultData(vault_data.clone()))
},
_ => ()
payment_data.set_vault_operation(
PaymentMethodDataAction::VaultData(vault_data.clone()),
)
}
_ => (),
}
payment_data.set_payment_method_data(Some(domain::PaymentMethodData::NetworkToken(token_data)));

payment_data.set_payment_method_data(Some(
domain::PaymentMethodData::NetworkToken(token_data),
));
}
_ => {
match pm_data {
Some(domain::PaymentMethodData::Card(card_data)) => {
payment_data.set_vault_operation(PaymentMethodDataAction::SaveCardData(card_data.clone()))
},
_ => ()
}
}
}
_ => match pm_data {
Some(domain::PaymentMethodData::Card(card_data)) => payment_data
.set_vault_operation(PaymentMethodDataAction::SaveCardData(
card_data.clone(),
)),
_ => (),
},
}
}

let schedule_time = if should_add_task_to_process_tracker {
Expand Down Expand Up @@ -4531,10 +4562,10 @@ where
}

#[derive(Clone, serde::Serialize, Debug)]
pub enum PaymentMethodDataAction{
pub enum PaymentMethodDataAction {
SaveCardData(hyperswitch_domain_models::payment_method_data::Card),
SaveNetworkTokenData(hyperswitch_domain_models::payment_method_data::NetworkTokenData),
VaultData(VaultData)
VaultData(VaultData),
}

#[derive(Clone, serde::Serialize, Debug)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCaptureR
tax_data: None,
session_id: None,
service_details: None,
vault_operation:None
vault_operation: None,
};

let get_trackers_response = operations::GetTrackerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRe
tax_data: None,
session_id: None,
service_details: None,
vault_operation:None,
vault_operation: None,
};

let get_trackers_response = operations::GetTrackerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, payments::PaymentData<F>, api::Paymen
tax_data: None,
session_id: None,
service_details: None,
vault_operation: None,
vault_operation: None,
};

let get_trackers_response = operations::GetTrackerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsPostSess
tax_data: None,
session_id: None,
service_details: None,
vault_operation: None,
vault_operation: None,
};
let get_trackers_response = operations::GetTrackerResponse {
operation: Box::new(self),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ async fn get_tracker_for_sync<
tax_data: None,
session_id: None,
service_details: None,
vault_operation:None,
vault_operation: None,
};

let get_trackers_response = operations::GetTrackerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
tax_data: None,
session_id: None,
service_details: None,
vault_operation: None,
vault_operation: None,
};

let get_trackers_response = operations::GetTrackerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl<F: Send + Clone + Sync>
tax_data: None,
session_id: None,
service_details: None,
vault_operation: None,
vault_operation: None,
};

let get_trackers_response = operations::GetTrackerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl<F: Send + Clone + Sync>
tax_data: Some(tax_data),
session_id: request.session_id.clone(),
service_details: None,
vault_operation: None,
vault_operation: None,
};
let get_trackers_response = operations::GetTrackerResponse {
operation: Box::new(self),
Expand Down
Loading

0 comments on commit 9ac6dfa

Please sign in to comment.