Skip to content

Commit

Permalink
add email in authn flow
Browse files Browse the repository at this point in the history
  • Loading branch information
sai-harsha-vardhan committed Feb 20, 2024
1 parent 1dff069 commit 7f2b486
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/router/src/connector/threedsecureio/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ impl TryFrom<&ThreedsecureioRouterData<&types::ConnectorAuthenticationRouterData
DeviceChannel::BRW => None,
},
cardholder_name: card_details.card_holder_name,
email: request.email.clone(),
})
}
}
Expand Down Expand Up @@ -580,7 +581,7 @@ pub struct ThreedsecureioAuthenticationRequest {
pub bill_addr_line1: String,
pub bill_addr_post_code: String,
pub bill_addr_state: String,
// pub email: Email,
pub email: Option<common_utils::pii::Email>,
pub three_dsrequestor_authentication_ind: String,
pub cardholder_name: Option<Secret<String>>,
pub device_channel: String,
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/core/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub async fn perform_authentication(
authentication_data: (types::AuthenticationData, storage::Authentication),
return_url: Option<String>,
sdk_information: Option<payments::SDKInformation>,
email: Option<common_utils::pii::Email>,
) -> CustomResult<core_types::api::authentication::AuthenticationResponse, ApiErrorResponse> {
let router_data = transformers::construct_authentication_router_data(
authentication_connector.clone(),
Expand All @@ -52,6 +53,7 @@ pub async fn perform_authentication(
authentication_data.clone(),
return_url,
sdk_information,
email,
)?;
let response =
utils::do_auth_connector_call(state, authentication_connector.clone(), router_data).await?;
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/core/authentication/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub fn construct_authentication_router_data(
authentication_data: (super::types::AuthenticationData, storage::Authentication),
return_url: Option<String>,
sdk_information: Option<api_models::payments::SDKInformation>,
email: Option<common_utils::pii::Email>,
) -> RouterResult<types::ConnectorAuthenticationRouterData> {
let router_request = types::ConnectorAuthenticationRequestData {
payment_method_data,
Expand All @@ -50,6 +51,7 @@ pub fn construct_authentication_router_data(
authentication_data,
return_url,
sdk_information,
email,
};
construct_router_data(
authentication_connector,
Expand Down
18 changes: 18 additions & 0 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3082,6 +3082,23 @@ pub async fn payment_external_authentication(
&[storage_enums::IntentStatus::RequiresCustomerAction],
"authenticate",
)?;
let optional_customer = match &payment_intent.customer_id {
Some(customer_id) => Some(
state
.store
.find_customer_by_customer_id_merchant_id(
&customer_id,
&merchant_account.merchant_id,
&key_store,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable_lazy(|| {
"error while finding customer with customer_id {customer_id}"
})?,
),
None => None,
};
let profile_id = payment_intent
.profile_id
.as_ref()
Expand Down Expand Up @@ -3198,6 +3215,7 @@ pub async fn payment_external_authentication(
(authentication_data, authentication),
return_url,
req.sdk_information,
optional_customer.and_then(|customer| customer.email.map(common_utils::pii::Email::from)),
)
.await?;
Ok(services::ApplicationResponse::Json(
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ pub struct ConnectorAuthenticationRequestData {
),
pub return_url: Option<String>,
pub sdk_information: Option<api_models::payments::SDKInformation>,
pub email: Option<Email>,
}

#[derive(Clone, Debug)]
Expand Down

0 comments on commit 7f2b486

Please sign in to comment.