Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(router): Deprecate Implicit Customer Update in Payments (#10982)
Anurag Thakur770b15ddea8b
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 79512e2a35..0b15cd8a42 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -7280,19 +7280,19 @@ pub struct PaymentsResponse {/// This field will be deprecated soon. Please refer to `customer.email` object#[schema(max_length = 255, value_type = Option<String>, example = "[email protected]", deprecated)]#[smithy(value_type = "Option<String>")]- pub email: crypto::OptionalEncryptableEmail,+ pub email: Option<Email>,/// description: The customer's name/// This field will be deprecated soon. Please refer to `customer.name` object#[schema(value_type = Option<String>, max_length = 255, example = "John Test", deprecated)]#[smithy(value_type = "Option<String>")]- pub name: crypto::OptionalEncryptableName,+ pub name: Option<Secret<String>>,/// The customer's phone number/// This field will be deprecated soon. Please refer to `customer.phone` object#[schema(value_type = Option<String>, max_length = 255, example = "9123456789", deprecated)]#[smithy(value_type = "Option<String>")]- pub phone: crypto::OptionalEncryptablePhone,+ pub phone: Option<Secret<String>>,/// The URL to redirect after the completion of the operation#[schema(example = "https://hyperswitch.io")]@@ -9011,9 +9011,9 @@ pub struct VerifyResponse {// pub status: enums::VerifyStatus,pub client_secret: Option<Secret<String>>,pub customer_id: Option<id_type::CustomerId>,- pub email: crypto::OptionalEncryptableEmail,- pub name: crypto::OptionalEncryptableName,- pub phone: crypto::OptionalEncryptablePhone,+ pub email: Option<Email>,+ pub name: Option<Secret<String>>,+ pub phone: Option<Secret<String>>,pub mandate_id: Option<String>,#[auth_based]pub payment_method: Option<api_enums::PaymentMethod>,diff --git a/crates/common_utils/src/id_type/merchant.rs b/crates/common_utils/src/id_type/merchant.rsindex 8b5e1c97b5..f91e5b0a89 100644--- a/crates/common_utils/src/id_type/merchant.rs+++ b/crates/common_utils/src/id_type/merchant.rs@@ -110,6 +110,11 @@ impl MerchantId {format!("{}_requires_cvv", self.get_string_repr())}+ /// get_implicit_customer_update_key+ pub fn get_implicit_customer_update_key(&self) -> String {+ format!("{}_implicit_customer_update", self.get_string_repr())+ }+/// get_pm_filters_cgraph_keypub fn get_pm_filters_cgraph_key(&self) -> String {format!("pm_filters_cgraph_{}", self.get_string_repr())diff --git a/crates/hyperswitch_domain_models/src/customer.rs b/crates/hyperswitch_domain_models/src/customer.rsindex 438d0c7514..ef0c092101 100644--- a/crates/hyperswitch_domain_models/src/customer.rs+++ b/crates/hyperswitch_domain_models/src/customer.rs@@ -17,7 +17,7 @@ use diesel_models::{customers as storage_types, customers::CustomerUpdateInternal, query::customers as query,};use error_stack::ResultExt;-use masking::{ExposeOptionInterface, PeekInterface, Secret, SwitchStrategy};+use masking::{ExposeInterface, PeekInterface, Secret, SwitchStrategy};use router_env::{instrument, tracing};use rustc_hash::FxHashMap;use time::PrimitiveDateTime;@@ -748,12 +748,11 @@ where#[instrument]pub async fn update_connector_customer_in_customers(connector_label: &str,- customer: Option<&Customer>,+ connector_customer_map: Option<&pii::SecretSerdeValue>,connector_customer_id: Option<String>,) -> Option<CustomerUpdate> {- let mut connector_customer_map = customer- .and_then(|customer| customer.connector_customer.clone().expose_option())- .and_then(|connector_customer| connector_customer.as_object().cloned())+ let mut connector_customer_map = connector_customer_map+ .and_then(|connector_customer| connector_customer.clone().expose().as_object().cloned()).unwrap_or_default();let updated_connector_customer_map = connector_customer_id.map(|connector_customer_id| {diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rsindex 7754f1194a..c54ed1a8e7 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs@@ -162,6 +162,22 @@ pub struct CustomerData {pub tax_registration_id: Option<Secret<String>>,}+impl CustomerData {+ pub fn fill_missing_fields(&mut self, other: &Self) {+ self.name = self.name.clone().or_else(|| other.name.clone());+ self.email = self.email.clone().or_else(|| other.email.clone());+ self.phone = self.phone.clone().or_else(|| other.phone.clone());+ self.phone_country_code = self+ .phone_country_code+ .clone()+ .or_else(|| other.phone_country_code.clone());+ self.tax_registration_id = self+ .tax_registration_id+ .clone()+ .or_else(|| other.tax_registration_id.clone());+ }+}+#[cfg(feature = "v2")]#[derive(Debug, Clone, Serialize)]pub struct PaymentIntentUpdateFields {diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rsindex 28323ddb9d..cb0e758e5c 100644--- a/crates/hyperswitch_domain_models/src/router_request_types.rs+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs@@ -1516,6 +1516,27 @@ pub struct CustomerDetails {pub tax_registration_id: Option<Secret<String, masking::WithType>>,}+impl CustomerDetails {+ pub fn get_customer_data(&self) -> Option<payments::payment_intent::CustomerData> {+ if self.name.is_some()+ || self.email.is_some()+ || self.phone.is_some()+ || self.phone_country_code.is_some()+ || self.tax_registration_id.is_some()+ {+ Some(payments::payment_intent::CustomerData {+ name: self.name.clone(),+ email: self.email.clone(),+ phone: self.phone.clone(),+ phone_country_code: self.phone_country_code.clone(),+ tax_registration_id: self.tax_registration_id.clone(),+ })+ } else {+ None+ }+ }+}+#[derive(Debug, Clone)]pub struct VerifyWebhookSourceRequestData {pub webhook_headers: actix_web::http::header::HeaderMap,diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rsindex ff8bbf6fe5..80b707ef28 100644--- a/crates/router/src/compatibility/stripe/payment_intents/types.rs+++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs@@ -3,7 +3,6 @@ use std::str::FromStr;use api_models::payments;use common_types::payments as common_payments_types;use common_utils::{- crypto::Encryptable,date_time,ext_traits::StringExt,id_type,@@ -553,9 +552,9 @@ impl From<payments::PaymentsResponse> for StripePaymentIntentResponse {payment_token: resp.payment_token,shipping: resp.shipping,billing: resp.billing,- email: resp.email.map(|inner| inner.into()),- name: resp.name.map(Encryptable::into_inner),- phone: resp.phone.map(Encryptable::into_inner),+ email: resp.email,+ name: resp.name,+ phone: resp.phone,authentication_type: resp.authentication_type,statement_descriptor_name: resp.statement_descriptor_name,statement_descriptor_suffix: resp.statement_descriptor_suffix,diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rsindex a052ad3671..23c94087f8 100644--- a/crates/router/src/consts.rs+++ b/crates/router/src/consts.rs@@ -363,6 +363,8 @@ pub const CREQ_CHALLENGE_REQUEST_KEY: &str = "creq";pub mod superposition {/// CVV requirement configuration keypub const REQUIRES_CVV: &str = "requires_cvv";+ /// implicit customer update configuration key+ pub const IMPLICIT_CUSTOMER_UPDATE: &str = "implicit_customer_update";}#[cfg(test)]diff --git a/crates/router/src/core/fraud_check.rs b/crates/router/src/core/fraud_check.rsindex 76d5b4cf21..1ea0e47834 100644--- a/crates/router/src/core/fraud_check.rs+++ b/crates/router/src/core/fraud_check.rs@@ -54,7 +54,6 @@ pub async fn call_frm_service<D: Clone, F, Req, OperationData>(payment_data: &OperationData,frm_data: &mut FrmData,platform: &domain::Platform,- customer: &Option<domain::Customer>,) -> RouterResult<oss_types::RouterData<F, Req, frm_types::FraudCheckResponseData>>whereF: Send + Clone,@@ -78,7 +77,6 @@ pub async fn call_frm_service<D: Clone, F, Req, OperationData>(payment_data: &OperationData,frm_data: &mut FrmData,platform: &domain::Platform,- customer: &Option<domain::Customer>,) -> RouterResult<oss_types::RouterData<F, Req, frm_types::FraudCheckResponseData>>whereF: Send + Clone,@@ -112,7 +110,6 @@ wherestate,&frm_data.connector_details.connector_name,platform.get_processor(),- customer,&merchant_connector_account,None,None,@@ -392,7 +389,6 @@ pub async fn make_frm_data_and_fraud_check_operation<F, D>(frm_routing_algorithm: FrmRoutingAlgorithm,profile_id: common_utils::id_type::ProfileId,frm_configs: FrmConfigsObject,- _customer: &Option<domain::Customer>,) -> RouterResult<FrmInfo<F, D>>whereF: Send + Clone,@@ -415,7 +411,6 @@ pub async fn make_frm_data_and_fraud_check_operation<F, D>(frm_routing_algorithm: FrmRoutingAlgorithm,profile_id: common_utils::id_type::ProfileId,frm_configs: FrmConfigsObject,- _customer: &Option<domain::Customer>,) -> RouterResult<FrmInfo<F, D>>whereF: Send + Clone,@@ -497,7 +492,6 @@ pub async fn pre_payment_frm_core<F, Req, D>(payment_data: &mut D,frm_info: &mut FrmInfo<F, D>,frm_configs: FrmConfigsObject,- customer: &Option<domain::Customer>,should_continue_transaction: &mut bool,should_continue_capture: &mut bool,operation: &BoxedOperation<'_, F, Req, D>,@@ -521,14 +515,13 @@ wherelet frm_router_data = fraud_check_operation.to_domain()?- .pre_payment_frm(state, payment_data, frm_data, platform, customer)+ .pre_payment_frm(state, payment_data, frm_data, platform).await?;let _router_data = call_frm_service::<F, frm_api::Transaction, _, D>(state,payment_data,frm_data,platform,- customer,).await?;let frm_data_updated = fraud_check_operation@@ -581,7 +574,6 @@ pub async fn post_payment_frm_core<F, D>(payment_data: &mut D,frm_info: &mut FrmInfo<F, D>,frm_configs: FrmConfigsObject,- customer: &Option<domain::Customer>,should_continue_capture: &mut bool,) -> RouterResult<Option<FrmData>>where@@ -599,14 +591,7 @@ whereif payment_data.get_payment_attempt().status == AttemptStatus::Authorized {let frm_router_data_opt = fraud_check_operation.to_domain()?- .post_payment_frm(- state,- req_state.clone(),- payment_data,- frm_data,- platform,- customer,- )+ .post_payment_frm(state, req_state.clone(), payment_data, frm_data, platform).await?;if let Some(frm_router_data) = frm_router_data_opt {let mut frm_data = fraud_check_operation@@ -638,7 +623,6 @@ wherefrm_configs,&mut frm_suggestion,payment_data,- customer,should_continue_capture,).await?;@@ -671,7 +655,6 @@ pub async fn call_frm_before_connector_call<F, Req, D>(payment_data: &mut D,state: &SessionState,frm_info: &mut Option<FrmInfo<F, D>>,- customer: &Option<domain::Customer>,should_continue_transaction: &mut bool,should_continue_capture: &mut bool,) -> RouterResult<Option<FrmConfigsObject>>@@ -697,7 +680,6 @@ wherefrm_routing_algorithm_val,profile_id,frm_configs.clone(),- customer,)).await?;@@ -708,7 +690,6 @@ wherepayment_data,&mut updated_frm_info,frm_configs,- customer,should_continue_transaction,should_continue_capture,operation,diff --git a/crates/router/src/core/fraud_check/flows/checkout_flow.rs b/crates/router/src/core/fraud_check/flows/checkout_flow.rsindex 988b23bb8b..30e3e134d8 100644--- a/crates/router/src/core/fraud_check/flows/checkout_flow.rs+++ b/crates/router/src/core/fraud_check/flows/checkout_flow.rs@@ -1,6 +1,7 @@use async_trait::async_trait;-use common_utils::{ext_traits::ValueExt, pii::Email};+use common_utils::ext_traits::ValueExt;use error_stack::ResultExt;+use hyperswitch_domain_models::payments::payment_intent;use masking::ExposeInterface;use super::{ConstructFlowSpecificData, FeatureFrm};@@ -46,7 +47,6 @@ impl ConstructFlowSpecificData<frm_api::Checkout, FraudCheckCheckoutData, FraudCstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,_merchant_recipient_data: Option<MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -66,7 +66,22 @@ impl ConstructFlowSpecificData<frm_api::Checkout, FraudCheckCheckoutData, FraudC})?;let browser_info: Option<BrowserInformation> = self.payment_attempt.get_browser_info().ok();- let customer_id = customer.to_owned().map(|customer| customer.customer_id);+ let customer_id = self.payment_intent.customer_id.clone();++ let customer_details = self+ .payment_intent+ .customer_details+ .clone()+ .map(|customer_details_encrypted| {+ customer_details_encrypted+ .into_inner()+ .expose()+ .parse_value::<payment_intent::CustomerData>("CustomerData")+ })+ .transpose()+ .change_context(errors::StorageError::DeserializationFailed)+ .attach_printable("Failed to parse customer data from payment intent")+ .change_context(errors::ApiErrorResponse::InternalServerError)?;let router_data = RouterData {flow: std::marker::PhantomData,@@ -113,17 +128,9 @@ impl ConstructFlowSpecificData<frm_api::Checkout, FraudCheckCheckoutData, FraudC}).transpose().unwrap_or_default(),- email: customer- .clone()- .and_then(|customer_data| {- customer_data- .map(|email| Email::try_from(email.into_inner().expose()))- })- .transpose()- .change_context(errors::ApiErrorResponse::InvalidDataValue {- field_name: "customer.customer_data.email",- })?,+ email: customer_details+ .as_ref()+ .and_then(|customer_data| customer_data.email.clone()),gateway: self.payment_attempt.connector.clone(),}, // self.order_detailsresponse: Ok(FraudCheckResponseData::TransactionResponse {diff --git a/crates/router/src/core/fraud_check/flows/record_return.rs b/crates/router/src/core/fraud_check/flows/record_return.rsindex c0a46822bd..8606af945b 100644--- a/crates/router/src/core/fraud_check/flows/record_return.rs+++ b/crates/router/src/core/fraud_check/flows/record_return.rs@@ -47,7 +47,6 @@ impl ConstructFlowSpecificData<RecordReturn, FraudCheckRecordReturnData, FraudChstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,_merchant_recipient_data: Option<MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -64,7 +63,7 @@ impl ConstructFlowSpecificData<RecordReturn, FraudCheckRecordReturnData, FraudChid: "ConnectorAuthType".to_string(),})?;- let customer_id = customer.to_owned().map(|customer| customer.customer_id);+ let customer_id = self.payment_intent.customer_id.clone();let currency = self.payment_attempt.clone().currency;let router_data = RouterData {flow: std::marker::PhantomData,diff --git a/crates/router/src/core/fraud_check/flows/sale_flow.rs b/crates/router/src/core/fraud_check/flows/sale_flow.rsindex 14673b0995..291f285e44 100644--- a/crates/router/src/core/fraud_check/flows/sale_flow.rs+++ b/crates/router/src/core/fraud_check/flows/sale_flow.rs@@ -1,6 +1,7 @@use async_trait::async_trait;-use common_utils::{ext_traits::ValueExt, pii::Email};+use common_utils::ext_traits::ValueExt;use error_stack::ResultExt;+use hyperswitch_domain_models::payments::payment_intent;use masking::ExposeInterface;use crate::{@@ -44,7 +45,6 @@ impl ConstructFlowSpecificData<frm_api::Sale, FraudCheckSaleData, FraudCheckRespstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,_merchant_recipient_data: Option<MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -60,7 +60,22 @@ impl ConstructFlowSpecificData<frm_api::Sale, FraudCheckSaleData, FraudCheckRespid: "ConnectorAuthType".to_string(),})?;- let customer_id = customer.to_owned().map(|customer| customer.customer_id);+ let customer_id = self.payment_intent.customer_id.clone();++ let customer_details = self+ .payment_intent+ .customer_details+ .clone()+ .map(|customer_details_encrypted| {+ customer_details_encrypted+ .into_inner()+ .expose()+ .parse_value::<payment_intent::CustomerData>("CustomerData")+ })+ .transpose()+ .change_context(errors::StorageError::DeserializationFailed)+ .attach_printable("Failed to parse customer data from payment intent")+ .change_context(errors::ApiErrorResponse::InternalServerError)?;let router_data = RouterData {flow: std::marker::PhantomData,@@ -92,17 +107,9 @@ impl ConstructFlowSpecificData<frm_api::Sale, FraudCheckSaleData, FraudCheckResp.get_amount_as_i64(),order_details: self.order_details.clone(),currency: self.payment_attempt.currency,- email: customer- .clone()- .and_then(|customer_data| {- customer_data- .map(|email| Email::try_from(email.into_inner().expose()))- })- .transpose()- .change_context(errors::ApiErrorResponse::InvalidDataValue {- field_name: "customer.customer_data.email",- })?,+ email: customer_details+ .as_ref()+ .and_then(|customer_data| customer_data.email.clone()),},response: Ok(FraudCheckResponseData::TransactionResponse {resource_id: ResponseId::ConnectorTransactionId("".to_string()),diff --git a/crates/router/src/core/fraud_check/flows/transaction_flow.rs b/crates/router/src/core/fraud_check/flows/transaction_flow.rsindex 8a42921d0f..f3a91175f5 100644--- a/crates/router/src/core/fraud_check/flows/transaction_flow.rs+++ b/crates/router/src/core/fraud_check/flows/transaction_flow.rs@@ -51,7 +51,6 @@ implstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,_merchant_recipient_data: Option<MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -69,7 +68,7 @@ implid: "ConnectorAuthType".to_string(),})?;- let customer_id = customer.to_owned().map(|customer| customer.customer_id);+ let customer_id = self.payment_intent.customer_id.clone();let payment_method = self.payment_attempt.payment_method;let currency = self.payment_attempt.currency;diff --git a/crates/router/src/core/fraud_check/operation.rs b/crates/router/src/core/fraud_check/operation.rsindex 8561e08856..484eedfd3e 100644--- a/crates/router/src/core/fraud_check/operation.rs+++ b/crates/router/src/core/fraud_check/operation.rs@@ -52,7 +52,6 @@ pub trait Domain<F, D>: Send + Sync {payment_data: &mut D,frm_data: &mut FrmData,platform: &domain::Platform,- customer: &Option<domain::Customer>,) -> RouterResult<Option<FrmRouterData>>whereF: Send + Clone;@@ -63,7 +62,6 @@ pub trait Domain<F, D>: Send + Sync {payment_data: &mut D,frm_data: &mut FrmData,platform: &domain::Platform,- customer: &Option<domain::Customer>,) -> RouterResult<FrmRouterData>whereF: Send + Clone;@@ -80,7 +78,6 @@ pub trait Domain<F, D>: Send + Sync {_frm_configs: FrmConfigsObject,_frm_suggestion: &mut Option<FrmSuggestion>,_payment_data: &mut D,- _customer: &Option<domain::Customer>,_should_continue_capture: &mut bool,) -> RouterResult<Option<FrmData>>wherediff --git a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs b/crates/router/src/core/fraud_check/operation/fraud_check_post.rsindex 7d8511308f..ad8e51774a 100644--- a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs+++ b/crates/router/src/core/fraud_check/operation/fraud_check_post.rs@@ -180,7 +180,6 @@ wherepayment_data: &mut D,frm_data: &mut FrmData,platform: &domain::Platform,- customer: &Option<domain::Customer>,) -> RouterResult<Option<FrmRouterData>> {if frm_data.fraud_check.last_step != FraudCheckLastStep::Processing {logger::debug!("post_flow::Sale Skipped");@@ -191,7 +190,6 @@ wherepayment_data,&mut frm_data.to_owned(),platform,- customer,).await?;frm_data.fraud_check.last_step = FraudCheckLastStep::CheckoutOrSale;@@ -221,7 +219,6 @@ where_frm_configs: FrmConfigsObject,_frm_suggestion: &mut Option<FrmSuggestion>,_payment_data: &mut D,- _customer: &Option<domain::Customer>,_should_continue_capture: &mut bool,) -> RouterResult<Option<FrmData>> {todo!()@@ -238,7 +235,6 @@ where_frm_configs: FrmConfigsObject,frm_suggestion: &mut Option<FrmSuggestion>,payment_data: &mut D,- customer: &Option<domain::Customer>,_should_continue_capture: &mut bool,) -> RouterResult<Option<FrmData>> {if matches!(frm_data.fraud_check.frm_status, FraudCheckStatus::Fraud)@@ -287,7 +283,6 @@ wherepayment_data,&mut frm_data.to_owned(),platform,- customer,).await?;frm_data.fraud_check.last_step = FraudCheckLastStep::TransactionOrRecordRefund;@@ -350,14 +345,12 @@ wherepayment_data: &mut D,frm_data: &mut FrmData,platform: &domain::Platform,- customer: &Option<domain::Customer>,) -> RouterResult<FrmRouterData> {let router_data = frm_core::call_frm_service::<F, frm_api::Sale, _, D>(state,payment_data,&mut frm_data.to_owned(),platform,- customer,).await?;Ok(FrmRouterData {diff --git a/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs b/crates/router/src/core/fraud_check/operation/fraud_check_pre.rsindex cd31400685..50d001c937 100644--- a/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs+++ b/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs@@ -168,7 +168,6 @@ where_payment_data: &mut D,_frm_data: &mut FrmData,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,) -> RouterResult<Option<FrmRouterData>> {todo!()}@@ -182,14 +181,12 @@ wherepayment_data: &mut D,frm_data: &mut FrmData,platform: &domain::Platform,- customer: &Option<domain::Customer>,) -> RouterResult<Option<FrmRouterData>> {let router_data = frm_core::call_frm_service::<F, frm_api::Transaction, _, D>(state,payment_data,&mut frm_data.to_owned(),platform,- customer,).await?;frm_data.fraud_check.last_step = FraudCheckLastStep::TransactionOrRecordRefund;@@ -218,14 +215,12 @@ wherepayment_data: &mut D,frm_data: &mut FrmData,platform: &domain::Platform,- customer: &Option<domain::Customer>,) -> RouterResult<FrmRouterData> {let router_data = frm_core::call_frm_service::<F, frm_api::Checkout, _, D>(state,payment_data,&mut frm_data.to_owned(),platform,- customer,).await?;frm_data.fraud_check.last_step = FraudCheckLastStep::CheckoutOrSale;diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex df45c7f544..b5d5937828 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -539,7 +539,6 @@ pub async fn retrieve_payment_method_with_token(payment_intent: &PaymentIntent,payment_attempt: &PaymentAttempt,card_token_data: Option<&domain::CardToken>,- customer: &Option<domain::Customer>,storage_scheme: common_enums::enums::MerchantStorageScheme,mandate_id: Option<api_models::payments::MandateIds>,payment_method_info: Option<domain::PaymentMethod>,@@ -674,7 +673,6 @@ pub async fn retrieve_payment_method_with_token(platform.get_processor(),auth_token,payment_intent,- customer,).await?.map(@@ -693,12 +691,11 @@ pub async fn retrieve_payment_method_with_token(payment_method_id: None,},storage::PaymentTokenData::BankDebit(bank_debit) => {- let customer =- customer- .as_ref()- .ok_or(errors::ApiErrorResponse::MissingRequiredField {- field_name: "customer",- })?;+ let customer_id = payment_intent.customer_id.as_ref().ok_or(+ errors::ApiErrorResponse::MissingRequiredField {+ field_name: "customer",+ },+ )?;let locker_id = bank_debit.locker_id.as_ref().ok_or(errors::ApiErrorResponse::MissingRequiredField {@@ -709,7 +706,7 @@ pub async fn retrieve_payment_method_with_token(let bank_debit_detail = cards::get_bank_debit_from_hs_locker(state,platform.get_provider(),- &customer.customer_id,+ customer_id,locker_id,).await?;diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex b9bca39022..39f2945b49 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -273,7 +273,6 @@ whereconnector_data.connector_data.clone(),&operation,&mut payment_data,- &customer,call_connector_action.clone(),None, // schedule_time is not used in PreDetermined ConnectorCallTypeheader_payload.clone(),@@ -305,7 +304,6 @@ whereplatform.get_processor(),&operation,&mut payment_data,- &customer,profile,req.should_return_raw_response(),&connector_data.connector_data,@@ -372,7 +370,6 @@ whereconnector_data.connector_data.clone(),&operation,&mut payment_data,- &customer,call_connector_action.clone(),None, // schedule_time is not used in Retryable ConnectorCallTypeheader_payload.clone(),@@ -404,7 +401,6 @@ whereplatform.get_processor(),&operation,&mut payment_data,- &customer,profile,req.should_return_raw_response(),&connector_data.connector_data,@@ -611,7 +607,7 @@ pub async fn payments_operation_core<'a, F, Req, Op, FData, D>(auth_flow: services::AuthFlow,eligible_connectors: Option<Vec<enums::RoutableConnectors>>,header_payload: HeaderPayload,-) -> RouterResult<(D, Req, Option<domain::Customer>, Option<u16>, Option<u128>)>+) -> RouterResult<(D, Req, Option<u16>, Option<u128>)>whereF: Send + Clone + Sync + Debug + 'static,Req: Authenticate + Clone,@@ -674,31 +670,23 @@ where&payment_data.get_payment_intent().clone(),)?;- operation- .to_domain()?- .populate_raw_customer_details(- state,- &mut payment_data,- customer_details.as_ref(),- platform.get_processor(),- )- .await- .to_not_found_response(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Failed while populating raw customer details")?;-let (operation, customer) = operation.to_domain()?// get_customer_details.get_or_create_customer_details(state,&mut payment_data,- customer_details,+ customer_details, // TODO: Remove this field after implicit customer update is removedplatform.get_provider(),).await.to_not_found_response(errors::ApiErrorResponse::CustomerNotFound).attach_printable("Failed while fetching/creating customer")?;+ let connector_customer_map = customer+ .as_ref()+ .and_then(|customer| customer.connector_customer.as_ref());+let authentication_type =call_decision_manager(state, platform, &business_profile, &payment_data).await?;@@ -751,7 +739,6 @@ where&mut payment_data,&validate_result,platform,- &customer,&business_profile,).await?;@@ -774,7 +761,6 @@ where&mut payment_data,state,&mut frm_info,- &customer,&mut should_continue_transaction,&mut should_continue_capture,))@@ -912,7 +898,6 @@ whereconnector.connector_data.clone(),&operation,&mut payment_data,- &customer,&validate_result,&business_profile,false,@@ -927,7 +912,7 @@ whereconnector.connector_data.clone(),&operation,&mut payment_data,- &customer,+ connector_customer_map,call_connector_action.clone(),shadow_ucs_call_connector_action.clone(),&validate_result,@@ -957,7 +942,6 @@ whereplatform.get_processor(),&operation,&mut payment_data,- &customer,&business_profile,<Req as Authenticate>::should_return_raw_response(&req),&connector.connector_data,@@ -1013,7 +997,6 @@ wherecomplete_postprocessing_steps_if_required(state,platform.get_processor(),- &customer,&mca,&connector.connector_data,&mut payment_data,@@ -1072,7 +1055,6 @@ whereconnector_data.clone(),&operation,&mut payment_data,- &customer,&validate_result,&business_profile,false,@@ -1087,7 +1069,7 @@ whereconnector_data.clone(),&operation,&mut payment_data,- &customer,+ connector_customer_map,call_connector_action.clone(),shadow_ucs_call_connector_action,&validate_result,@@ -1117,7 +1099,6 @@ whereplatform.get_processor(),&operation,&mut payment_data,- &customer,&business_profile,<Req as Authenticate>::should_return_raw_response(&req),&connector_data,@@ -1207,7 +1188,6 @@ wherecomplete_postprocessing_steps_if_required(state,platform.get_processor(),- &customer,&mca,&connector_data,&mut payment_data,@@ -1247,7 +1227,6 @@ whereconnectors,&operation,payment_data,- &customer,session_surcharge_details,&business_profile,header_payload.clone(),@@ -1272,7 +1251,6 @@ wherefield_name: "frm_configs",}).attach_printable("Frm configs label not found")?,- &customer,&mut should_continue_capture,)).await?;@@ -1285,7 +1263,6 @@ wherereq_state,platform.get_processor(),payment_data.clone(),- customer.clone(),#[cfg(feature = "frm")]frm_info.and_then(|info| info.suggested_action),#[cfg(not(feature = "frm"))]@@ -1319,7 +1296,6 @@ wherereq_state,platform.get_processor(),payment_data.clone(),- customer.clone(),None,header_payload.clone(),)@@ -1327,7 +1303,6 @@ where}let cloned_payment_data = payment_data.clone();- let cloned_customer = customer.clone();#[cfg(feature = "v1")]operation@@ -1345,7 +1320,6 @@ whereplatform.get_initiator(),business_profile,cloned_payment_data,- cloned_customer,state,operation,)@@ -1356,7 +1330,6 @@ whereOk((payment_data,req,- customer,connector_http_status_code,external_latency,))@@ -1378,7 +1351,7 @@ pub async fn proxy_for_payments_operation_core<F, Req, Op, FData, D>(auth_flow: services::AuthFlow,header_payload: HeaderPayload,return_raw_connector_response: Option<bool>,-) -> RouterResult<(D, Req, Option<domain::Customer>, Option<u16>, Option<u128>)>+) -> RouterResult<(D, Req, Option<u16>, Option<u128>)>whereF: Send + Clone + Sync,Req: Authenticate + Clone,@@ -1487,19 +1460,7 @@ whereNone};- operation- .to_domain()?- .populate_raw_customer_details(- state,- &mut payment_data,- customer_details.as_ref(),- platform.get_processor(),- )- .await- .to_not_found_response(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Failed while populating raw customer details")?;-- let (operation, customer) = operation+ let (operation, _customer) = operation.to_domain()?.get_or_create_customer_details(state,@@ -1517,7 +1478,6 @@ whereconnector.clone(),&operation,&mut payment_data,- &customer,call_connector_action.clone(),&validate_result,schedule_time,@@ -1562,7 +1522,6 @@ wherecomplete_postprocessing_steps_if_required(state,platform.get_processor(),- &None,&mca,&connector,&mut payment_data,@@ -1579,7 +1538,6 @@ whereplatform.get_initiator(),business_profile,cloned_payment_data,- None,state,operation,)@@ -1590,7 +1548,6 @@ whereOk((payment_data,req,- None,connector_http_status_code,external_latency,))@@ -1873,7 +1830,6 @@ wherereq_state,platform.get_processor(),payment_data,- customer.clone(),None,header_payload,)@@ -1949,7 +1905,6 @@ wherereq_state,platform.get_processor(),payment_data,- customer.clone(),None,header_payload,)@@ -2291,7 +2246,7 @@ where.flat_map(|c| c.foreign_try_into()).collect()});- let (payment_data, _req, customer, connector_http_status_code, external_latency) =+ let (payment_data, _req, connector_http_status_code, external_latency) =payments_operation_core::<_, _, _, _, _>(&state,req_state,@@ -2309,7 +2264,6 @@ whereRes::generate_response(payment_data,- customer,auth_flow,&state.base_url,operation,@@ -2353,7 +2307,7 @@ where// To perform router related operation for PaymentResponsePaymentResponse: Operation<F, FData, Data = D>,{- let (payment_data, _req, customer, connector_http_status_code, external_latency) =+ let (payment_data, _req, connector_http_status_code, external_latency) =proxy_for_payments_operation_core::<_, _, _, _, _>(&state,req_state,@@ -2370,7 +2324,6 @@ whereRes::generate_response(payment_data,- customer,auth_flow,&state.base_url,operation,@@ -2660,7 +2613,6 @@ pub async fn record_attempt_core(platform.get_processor(),record_payment_data,None,- None,header_payload.clone(),).await?;@@ -4201,7 +4153,7 @@ pub async fn call_connector_service<F, RouterDReq, ApiRequest, D>(connector: api::ConnectorData,operation: &BoxedOperation<'_, F, ApiRequest, D>,payment_data: &mut D,- customer: &Option<domain::Customer>,+ connector_customer_map: Option<&pii::SecretSerdeValue>,call_connector_action: CallConnectorAction,validate_result: &operations::ValidateResult,schedule_time: Option<time::PrimitiveDateTime>,@@ -4289,7 +4241,7 @@ wherelet updated_customer = call_create_connector_customer_if_required(state,- customer,+ connector_customer_map,processor,&merchant_connector_account,payment_data,@@ -4412,7 +4364,6 @@ pub async fn complete_connector_service<F, RouterDReq, ApiRequest, D>(processor: &domain::Processor,operation: &BoxedOperation<'_, F, ApiRequest, D>,payment_data: &mut D,- customer: &Option<domain::Customer>,business_profile: &domain::Profile,return_raw_connector_response: Option<bool>,connector: &api::ConnectorData,@@ -4447,7 +4398,6 @@ wherereq_state,processor,payment_data.clone(),- customer.clone(),frm_suggestion,header_payload.clone(),)@@ -4489,7 +4439,6 @@ pub async fn call_connector_service_prerequisites<F, RouterDReq, ApiRequest, D>(connector: api::ConnectorData,operation: &BoxedOperation<'_, F, ApiRequest, D>,payment_data: &mut D,- customer: &Option<domain::Customer>,validate_result: &operations::ValidateResult,business_profile: &domain::Profile,should_retry_with_pan: bool,@@ -4595,7 +4544,6 @@ wherepayment_data,validate_result,platform,- customer,business_profile,should_retry_with_pan,)@@ -4623,7 +4571,6 @@ wherestate,connector.connector.id(),platform.get_processor(),- customer,&merchant_connector_account,merchant_recipient_data,None,@@ -4649,7 +4596,7 @@ pub async fn decide_unified_connector_service_call<'a, F, RouterDReq, ApiRequestconnector: api::ConnectorData,operation: &'a BoxedOperation<'a, F, ApiRequest, D>,payment_data: &'a mut D,- customer: &Option<domain::Customer>,+ connector_customer_map: Option<&pii::SecretSerdeValue>,call_connector_action: CallConnectorAction,shadow_ucs_call_connector_action: Option<CallConnectorAction>,validate_result: &'a operations::ValidateResult,@@ -4720,7 +4667,7 @@ whereconnector,operation,payment_data,- customer,+ connector_customer_map,call_connector_action,validate_result,schedule_time,@@ -4764,7 +4711,6 @@ pub async fn call_connector_service<F, RouterDReq, ApiRequest, D>(connector: api::ConnectorData,operation: &BoxedOperation<'_, F, ApiRequest, D>,payment_data: &mut D,- customer: &Option<domain::Customer>,call_connector_action: CallConnectorAction,schedule_time: Option<time::PrimitiveDateTime>,header_payload: HeaderPayload,@@ -4874,7 +4820,6 @@ pub async fn complete_connector_service<F, RouterDReq, ApiRequest, D>(processor: &domain::Processor,operation: &BoxedOperation<'_, F, ApiRequest, D>,payment_data: &mut D,- customer: &Option<domain::Customer>,business_profile: &domain::Profile,return_raw_connector_response: Option<bool>,connector: &api::ConnectorData,@@ -4909,7 +4854,6 @@ wherereq_state,processor,payment_data.clone(),- customer.clone(),frm_suggestion,header_payload.clone(),)@@ -5295,7 +5239,6 @@ wherereq_state,platform.get_processor(),payment_data.clone(),- None, // customer is not used in internal flowsNone, // frm_suggestion is not used in internal flowsheader_payload.clone(),)@@ -5334,7 +5277,6 @@ pub async fn decide_unified_connector_service_call<F, RouterDReq, ApiRequest, D>connector: api::ConnectorData,operation: &BoxedOperation<'_, F, ApiRequest, D>,payment_data: &mut D,- customer: &Option<domain::Customer>,call_connector_action: CallConnectorAction,schedule_time: Option<time::PrimitiveDateTime>,header_payload: HeaderPayload,@@ -5403,7 +5345,6 @@ whereconnector,operation,payment_data,- customer,call_connector_action,schedule_time,header_payload,@@ -5468,7 +5409,6 @@ wherereq_state,processor,payment_data.clone(),- customer.clone(),frm_suggestion,header_payload.clone(),)@@ -5514,7 +5454,6 @@ pub async fn proxy_for_call_connector_service<F, RouterDReq, ApiRequest, D>(connector: api::ConnectorData,operation: &BoxedOperation<'_, F, ApiRequest, D>,payment_data: &mut D,- customer: &Option<domain::Customer>,call_connector_action: CallConnectorAction,validate_result: &operations::ValidateResult,schedule_time: Option<time::PrimitiveDateTime>,@@ -5565,7 +5504,6 @@ wherestate,connector.connector.id(),platform.get_processor(),- customer,&merchant_connector_account,merchant_recipient_data,Some(header_payload.clone()),@@ -5673,7 +5611,6 @@ wherereq_state,platform.get_processor(),payment_data.clone(),- customer.clone(),frm_suggestion,header_payload.clone(),)@@ -5813,7 +5750,6 @@ whereplatform.get_processor(),payment_data.clone(),None,- None,header_payload.clone(),).await?;@@ -5937,7 +5873,6 @@ whereplatform.get_processor(),payment_data.clone(),None,- None,header_payload.clone(),).await?;@@ -6577,7 +6512,6 @@ pub async fn call_multiple_connectors_service<F, Op, Req, D>(connectors: api::SessionConnectorDatas,_operation: &Op,mut payment_data: D,- customer: &Option<domain::Customer>,session_surcharge_details: Option<api::SessionSurchargeDetails>,business_profile: &domain::Profile,header_payload: HeaderPayload,@@ -6630,7 +6564,6 @@ wherestate,connector_id,processor,- customer,&merchant_connector_account,None,Some(header_payload.clone()),@@ -6948,7 +6881,7 @@ pub fn validate_customer_details_for_click_to_pay(#[cfg(feature = "v1")]pub async fn call_create_connector_customer_if_required<F, Req, D>(state: &SessionState,- customer: &Option<domain::Customer>,+ connector_customer_map: Option<&pii::SecretSerdeValue>,processor: &domain::Processor,merchant_connector_account: &helpers::MerchantConnectorAccountType,payment_data: &mut D,@@ -7011,7 +6944,7 @@ wherelet (should_call_connector, existing_connector_customer_id) =customers::should_call_connector_create_customer(&connector,- customer,+ connector_customer_map,payment_data.get_payment_attempt(),&label,);@@ -7023,7 +6956,6 @@ wherestate,connector.connector.id(),processor,- customer,merchant_connector_account,None,None,@@ -7040,7 +6972,7 @@ wherelet customer_update = customers::update_connector_customer_in_customers(&label,- customer.as_ref(),+ connector_customer_map,connector_customer_id.clone(),).await;@@ -7221,7 +7153,6 @@ whereasync fn complete_postprocessing_steps_if_required<F, Q, RouterDReq, D>(state: &SessionState,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_conn_account: &helpers::MerchantConnectorAccountType,connector: &api::ConnectorData,payment_data: &mut D,@@ -7243,7 +7174,6 @@ wherestate,connector.connector.id(),processor,- customer,merchant_conn_account,None,header_payload,@@ -7733,7 +7663,6 @@ pub async fn get_connector_tokenization_action_when_confirm_true<F, Req, D>(payment_data: &mut D,validate_result: &operations::ValidateResult,platform: &domain::Platform,- customer: &Option<domain::Customer>,business_profile: &domain::Profile,should_retry_with_pan: bool,) -> RouterResult<(D, TokenizationAction)>@@ -7801,7 +7730,6 @@ wherepayment_data,validate_result.storage_scheme,platform,- customer,business_profile,should_retry_with_pan,)@@ -7820,7 +7748,6 @@ wherepayment_data,validate_result.storage_scheme,platform,- customer,business_profile,should_retry_with_pan,)@@ -7873,7 +7800,6 @@ pub async fn tokenize_in_router_when_confirm_false_or_external_authentication<F,payment_data: &mut D,validate_result: &operations::ValidateResult,platform: &domain::Platform,- customer: &Option<domain::Customer>,business_profile: &domain::Profile,) -> RouterResult<D>where@@ -7893,7 +7819,6 @@ wherepayment_data,validate_result.storage_scheme,platform,- customer,business_profile,false,)diff --git a/crates/router/src/core/payments/customers.rs b/crates/router/src/core/payments/customers.rsindex 5905327891..47c33dab01 100644--- a/crates/router/src/core/payments/customers.rs+++ b/crates/router/src/core/payments/customers.rs@@ -1,7 +1,10 @@pub use hyperswitch_domain_models::customer::update_connector_customer_in_customers;use hyperswitch_interfaces::api::{gateway, ConnectorSpecifications};+use masking::PeekInterface;use router_env::{instrument, tracing};+#[cfg(feature = "v2")]+use crate::types::domain;use crate::{core::{errors::{ConnectorErrorExt, RouterResult},@@ -10,7 +13,7 @@ use crate::{logger,routes::{metrics, SessionState},services,- types::{self, api, domain},+ types::{self, api},};#[instrument(skip_all)]@@ -79,17 +82,19 @@ pub async fn create_connector_customer<F: Clone, T: Clone>(#[cfg(feature = "v1")]pub fn should_call_connector_create_customer<'a>(connector: &api::ConnectorData,- customer: &'a Option<domain::Customer>,+ connector_customer_map: Option<&'a common_utils::pii::SecretSerdeValue>,payment_attempt: &hyperswitch_domain_models::payments::payment_attempt::PaymentAttempt,connector_label: &str,) -> (bool, Option<&'a str>) {// Check if create customer is required for the connector+let connector_needs_customer = connector.connector.should_call_connector_customer(payment_attempt);- let connector_customer_details = customer- .as_ref()- .and_then(|customer| customer.get_connector_customer_id(connector_label));+ let connector_customer_details = connector_customer_map+ .and_then(|connector_customer_map| connector_customer_map.peek().get(connector_label))+ .and_then(|connector_customer| connector_customer.as_str());+if connector_needs_customer {let should_call_connector = connector_customer_details.is_none();(should_call_connector, connector_customer_details)diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rsindex 84587176cf..0bbb4c234c 100644--- a/crates/router/src/core/payments/flows.rs+++ b/crates/router/src/core/payments/flows.rs@@ -49,7 +49,6 @@ pub trait ConstructFlowSpecificData<F, Req, Res> {state: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<domain_payments::HeaderPayload>,diff --git a/crates/router/src/core/payments/flows/approve_flow.rs b/crates/router/src/core/payments/flows/approve_flow.rsindex 21a037c129..d314e32a78 100644--- a/crates/router/src/core/payments/flows/approve_flow.rs+++ b/crates/router/src/core/payments/flows/approve_flow.rs@@ -38,7 +38,6 @@ implstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -53,7 +52,6 @@ implself.clone(),connector_id,processor,- customer,merchant_connector_account,merchant_recipient_data,header_payload,diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rsindex 83aebe2c9c..7f1887c236 100644--- a/crates/router/src/core/payments/flows/authorize_flow.rs+++ b/crates/router/src/core/payments/flows/authorize_flow.rs@@ -148,7 +148,6 @@ implstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<domain_payments::HeaderPayload>,@@ -169,7 +168,6 @@ implself.clone(),connector_id,processor,- customer,merchant_connector_account,merchant_recipient_data,header_payload,diff --git a/crates/router/src/core/payments/flows/cancel_flow.rs b/crates/router/src/core/payments/flows/cancel_flow.rsindex 47124149c1..ae911c4a59 100644--- a/crates/router/src/core/payments/flows/cancel_flow.rs+++ b/crates/router/src/core/payments/flows/cancel_flow.rs@@ -21,7 +21,6 @@ impl ConstructFlowSpecificData<api::Void, types::PaymentsCancelData, types::Paymstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -36,7 +35,6 @@ impl ConstructFlowSpecificData<api::Void, types::PaymentsCancelData, types::Paymself.clone(),connector_id,processor,- customer,merchant_connector_account,merchant_recipient_data,header_payload,diff --git a/crates/router/src/core/payments/flows/cancel_post_capture_flow.rs b/crates/router/src/core/payments/flows/cancel_post_capture_flow.rsindex a76da0de20..b9bb25f416 100644--- a/crates/router/src/core/payments/flows/cancel_post_capture_flow.rs+++ b/crates/router/src/core/payments/flows/cancel_post_capture_flow.rs@@ -39,7 +39,6 @@ implstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -54,7 +53,6 @@ implself.clone(),connector_id,processor,- customer,merchant_connector_account,merchant_recipient_data,header_payload,diff --git a/crates/router/src/core/payments/flows/capture_flow.rs b/crates/router/src/core/payments/flows/capture_flow.rsindex a95211e242..0e5910433c 100644--- a/crates/router/src/core/payments/flows/capture_flow.rs+++ b/crates/router/src/core/payments/flows/capture_flow.rs@@ -23,7 +23,6 @@ implstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -38,7 +37,6 @@ implself.clone(),connector_id,processor,- customer,merchant_connector_account,merchant_recipient_data,header_payload,diff --git a/crates/router/src/core/payments/flows/complete_authorize_flow.rs b/crates/router/src/core/payments/flows/complete_authorize_flow.rsindex 7d481e76e7..de9b4722db 100644--- a/crates/router/src/core/payments/flows/complete_authorize_flow.rs+++ b/crates/router/src/core/payments/flows/complete_authorize_flow.rs@@ -51,7 +51,6 @@ implstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -72,7 +71,6 @@ implself.clone(),connector_id,processor,- customer,merchant_connector_account,merchant_recipient_data,header_payload,diff --git a/crates/router/src/core/payments/flows/extend_authorization_flow.rs b/crates/router/src/core/payments/flows/extend_authorization_flow.rsindex fae375e87e..6a8ee66632 100644--- a/crates/router/src/core/payments/flows/extend_authorization_flow.rs+++ b/crates/router/src/core/payments/flows/extend_authorization_flow.rs@@ -39,7 +39,6 @@ implstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -54,7 +53,6 @@ implself.clone(),connector_id,processor,- customer,merchant_connector_account,merchant_recipient_data,header_payload,diff --git a/crates/router/src/core/payments/flows/incremental_authorization_flow.rs b/crates/router/src/core/payments/flows/incremental_authorization_flow.rsindex 53af99b54a..fc6b3915e7 100644--- a/crates/router/src/core/payments/flows/incremental_authorization_flow.rs+++ b/crates/router/src/core/payments/flows/incremental_authorization_flow.rs@@ -26,7 +26,6 @@ implstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -41,7 +40,6 @@ implself.clone(),connector_id,processor,- customer,merchant_connector_account,merchant_recipient_data,header_payload,diff --git a/crates/router/src/core/payments/flows/post_session_tokens_flow.rs b/crates/router/src/core/payments/flows/post_session_tokens_flow.rsindex afff0d84ba..c879e22ac7 100644--- a/crates/router/src/core/payments/flows/post_session_tokens_flow.rs+++ b/crates/router/src/core/payments/flows/post_session_tokens_flow.rs@@ -25,7 +25,6 @@ implstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -40,7 +39,6 @@ implself.clone(),connector_id,processor,- customer,merchant_connector_account,merchant_recipient_data,header_payload,diff --git a/crates/router/src/core/payments/flows/psync_flow.rs b/crates/router/src/core/payments/flows/psync_flow.rsindex 62f2f771d4..a997a6b37f 100644--- a/crates/router/src/core/payments/flows/psync_flow.rs+++ b/crates/router/src/core/payments/flows/psync_flow.rs@@ -27,7 +27,6 @@ impl ConstructFlowSpecificData<api::PSync, types::PaymentsSyncData, types::Paymestate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<domain_payments::HeaderPayload>,@@ -44,7 +43,6 @@ impl ConstructFlowSpecificData<api::PSync, types::PaymentsSyncData, types::Paymeself.clone(),connector_id,processor,- customer,merchant_connector_account,merchant_recipient_data,header_payload,diff --git a/crates/router/src/core/payments/flows/reject_flow.rs b/crates/router/src/core/payments/flows/reject_flow.rsindex 89ba68ddd0..9cf3ad88e3 100644--- a/crates/router/src/core/payments/flows/reject_flow.rs+++ b/crates/router/src/core/payments/flows/reject_flow.rs@@ -21,7 +21,6 @@ impl ConstructFlowSpecificData<api::Reject, types::PaymentsRejectData, types::Pastate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -36,7 +35,6 @@ impl ConstructFlowSpecificData<api::Reject, types::PaymentsRejectData, types::Paself.clone(),connector_id,processor,- customer,merchant_connector_account,merchant_recipient_data,header_payload,diff --git a/crates/router/src/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rsindex 4a7e309e5f..5458042d38 100644--- a/crates/router/src/core/payments/flows/session_flow.rs+++ b/crates/router/src/core/payments/flows/session_flow.rs@@ -75,7 +75,6 @@ implstate: &routes::SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -90,7 +89,6 @@ implself.clone(),connector_id,processor,- customer,merchant_connector_account,merchant_recipient_data,header_payload,diff --git a/crates/router/src/core/payments/flows/session_update_flow.rs b/crates/router/src/core/payments/flows/session_update_flow.rsindex d60c4baa03..b9ef952718 100644--- a/crates/router/src/core/payments/flows/session_update_flow.rs+++ b/crates/router/src/core/payments/flows/session_update_flow.rs@@ -25,7 +25,6 @@ implstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,_merchant_recipient_data: Option<types::MerchantRecipientData>,_header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -41,7 +40,6 @@ implself.clone(),connector_id,processor,- customer,merchant_connector_account,),)diff --git a/crates/router/src/core/payments/flows/setup_mandate_flow.rs b/crates/router/src/core/payments/flows/setup_mandate_flow.rsindex e5036dc3ef..3ccc6f6358 100644--- a/crates/router/src/core/payments/flows/setup_mandate_flow.rs+++ b/crates/router/src/core/payments/flows/setup_mandate_flow.rs@@ -43,7 +43,6 @@ implstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<domain_payments::HeaderPayload>,@@ -58,7 +57,6 @@ implself.clone(),connector_id,processor,- customer,merchant_connector_account,merchant_recipient_data,header_payload,diff --git a/crates/router/src/core/payments/flows/update_metadata_flow.rs b/crates/router/src/core/payments/flows/update_metadata_flow.rsindex 597c3ebaab..c66efdbfb5 100644--- a/crates/router/src/core/payments/flows/update_metadata_flow.rs+++ b/crates/router/src/core/payments/flows/update_metadata_flow.rs@@ -25,7 +25,6 @@ implstate: &SessionState,connector_id: &str,processor: &domain::Processor,- customer: &Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -38,7 +37,6 @@ implself.clone(),connector_id,processor,- customer,merchant_connector_account,merchant_recipient_data,header_payload,diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex a87c8e02ca..f251728089 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -83,7 +83,7 @@ use crate::{connector,consts::{self, BASE64_ENGINE},core::{- authentication,+ authentication, configs,errors::{self, CustomResult, RouterResult, StorageErrorExt},mandate::helpers::MandateGenericData,payment_methods::{@@ -1784,6 +1784,48 @@ pub async fn populate_raw_customer_details<F: Clone>(Ok(())}+#[cfg(feature = "v1")]+#[instrument(skip_all)]+pub async fn merge_request_and_intent_customer_data(+ state: &SessionState,+ payment_intent_customer_details: Option<Encryptable<pii::SecretSerdeValue>>,+ request_customer_details: &CustomerDetails,+ processor: &domain::Processor,+) -> CustomResult<Option<Encryptable<pii::SecretSerdeValue>>, errors::StorageError> {+ let key_store = processor.get_key_store();+ let key_manager_state = state.into();++ let merged_customer_details =+ // If the request has any customer data, merge it with intent customer data, else return the intent customer data unmodified+ // TODO: Optimization: This call is redundant if intent and request customer data is exactly the same+ if let Some(mut request_customer_data) = request_customer_details.get_customer_data() {+ if let Some(customer_details_encrypted) = &payment_intent_customer_details {+ let decrypted_data = customer_details_encrypted+ .clone()+ .into_inner()+ .expose()+ .parse_value::<CustomerData>("CustomerData")+ .change_context(errors::StorageError::DeserializationFailed)+ .attach_printable("Failed to parse customer data from payment intent")?;++ // Customer details in request take priority, so only fill missing fields from payment intent+ request_customer_data.fill_missing_fields(&decrypted_data);+ }++ // Encrypt and update customer details in payment intent+ Some(+ create_encrypted_data(&key_manager_state, key_store, request_customer_data)+ .await+ .change_context(errors::StorageError::EncryptionError)+ .attach_printable("Unable to encrypt customer details")?,+ )+ } else {+ payment_intent_customer_details+ };++ Ok(merged_customer_details)+}+#[cfg(feature = "v2")]#[instrument(skip_all)]#[allow(clippy::type_complexity)]@@ -1859,12 +1901,29 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(.attach_printable("Failed while encrypting Customer while Update")?;Some(match customer_data {Some(c) => {+ let implicit_customer_update = configs::get_config_bool(+ state,+ consts::superposition::IMPLICIT_CUSTOMER_UPDATE,+ &provider+ .get_account()+ .get_id()+ .get_implicit_customer_update_key(), // database+ Some(external_services::superposition::ConfigContext::new().with(+ "merchant_id",+ provider.get_account().get_id().get_string_repr(),+ )), // context+ false, // Implicit Customer update is disabled by default+ )+ .await+ .attach_printable("Failed to fetch implicit_customer_update config")?;+// Update the customer data if new data is passed in the request- if request_customer_details.email.is_some()- | request_customer_details.name.is_some()- | request_customer_details.phone.is_some()- | request_customer_details.phone_country_code.is_some()- | request_customer_details.tax_registration_id.is_some()+ if implicit_customer_update+ && (request_customer_details.email.is_some()+ | request_customer_details.name.is_some()+ | request_customer_details.phone.is_some()+ | request_customer_details.phone_country_code.is_some()+ | request_customer_details.tax_registration_id.is_some()){let customer_update = Update {name: encryptable_customer.name,@@ -1936,25 +1995,54 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R, D>(}})}- None => match &payment_data.payment_intent.customer_id {- None => None,- Some(customer_id) => db- .find_customer_optional_by_customer_id_merchant_id(- customer_id,- merchant_id,- key_store,- storage_scheme,- )- .await?- .map(Ok),- },+ None => None,};+Ok((operation,match optional_customer {Some(customer) => {let customer = customer?;+ let customer_record_data = CustomerData {+ name: customer.name.clone().map(|val| val.into_inner()),+ email: customer.email.clone().map(|val| val.clone().into()),+ phone: customer.phone.clone().map(|val| val.into_inner()),+ phone_country_code: customer.phone_country_code.clone(),+ tax_registration_id: customer+ .tax_registration_id+ .clone()+ .map(|val| val.into_inner()),+ };++ // Merge with existing payment intent customer details if present+ let final_customer_data = match &payment_data.payment_intent.customer_details {+ Some(encrypted_details) => {+ let mut intent_customer_data = encrypted_details+ .clone()+ .into_inner()+ .expose()+ .parse_value::<CustomerData>("CustomerData")+ .change_context(errors::StorageError::DeserializationFailed)+ .attach_printable(+ "Failed to parse customer data from payment intent",+ )?;++ // Intent customer data takes priority, so only fill missing fields from customer record+ intent_customer_data.fill_missing_fields(&customer_record_data);+ intent_customer_data+ }+ None => customer_record_data,+ };++ // Encrypt and store the final customer data+ payment_data.payment_intent.customer_details = Some(+ create_encrypted_data(key_manager_state, key_store, final_customer_data)+ .await+ .change_context(errors::StorageError::EncryptionError)+ .attach_printable("Unable to encrypt customer details")?,+ );+payment_data.payment_intent.customer_id = Some(customer.customer_id.clone());payment_data.email = payment_data.email.clone().or_else(|| {customer@@ -3004,7 +3092,6 @@ pub async fn make_pm_data<'a, F: Clone, R, D>(state: &'a SessionState,payment_data: &mut PaymentData<F>,platform: &domain::Platform,- customer: &Option<domain::Customer>,storage_scheme: common_enums::enums::MerchantStorageScheme,business_profile: &domain::Profile,should_retry_with_pan: bool,@@ -3078,7 +3165,6 @@ pub async fn make_pm_data<'a, F: Clone, R, D>(&payment_data.payment_intent,&payment_data.payment_attempt,card_token_data.as_ref(),- customer,storage_scheme,mandate_id,payment_data.payment_method_info.clone(),@@ -7636,7 +7722,6 @@ pub async fn get_payment_method_details_from_payment_token(platform.get_processor(),&auth_token,payment_intent,- &None,).await}diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rsindex 474b70c422..c6069a3ac7 100644--- a/crates/router/src/core/payments/operations.rs+++ b/crates/router/src/core/payments/operations.rs@@ -258,16 +258,6 @@ pub trait GetTracker<F: Clone, D, R>: Send {#[async_trait]pub trait Domain<F: Clone, R, D>: Send + Sync {- #[cfg(feature = "v1")]- /// This will populate raw customer details in payment intent (processor context)- async fn populate_raw_customer_details<'a>(- &'a self,- state: &SessionState,- payment_data: &mut D,- request: Option<&CustomerDetails>,- processor: &domain::Processor,- ) -> CustomResult<(), errors::StorageError>;-#[cfg(feature = "v1")]/// This will fetch customer details, (this operation is flow specific)async fn get_or_create_customer_details<'a>(@@ -318,7 +308,6 @@ pub trait Domain<F: Clone, R, D>: Send + Sync {payment_data: &mut D,storage_scheme: enums::MerchantStorageScheme,platform: &domain::Platform,- customer: &Option<domain::Customer>,business_profile: &domain::Profile,should_retry_with_pan: bool,) -> RouterResult<(@@ -513,7 +502,6 @@ pub trait UpdateTracker<F, D, Req>: Send {req_state: ReqState,processor: &domain::Processor,payment_data: D,- customer: Option<domain::Customer>,frm_suggestion: Option<FrmSuggestion>,header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(BoxedOperation<'b, F, Req, D>, D)>@@ -600,17 +588,6 @@ wherefor<'a> &'a Op: Operation<F, api::PaymentsRetrieveRequest, Data = D>,D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send,{- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- _state: &SessionState,- _payment_data: &mut D,- _request: Option<&CustomerDetails>,- _processor: &domain::Processor,- ) -> CustomResult<(), errors::StorageError> {- Ok(())- }-#[instrument(skip_all)]#[cfg(feature = "v1")]async fn get_or_create_customer_details<'a>(@@ -668,7 +645,6 @@ where_payment_data: &mut D,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(@@ -698,17 +674,6 @@ wherefor<'a> &'a Op: Operation<F, api::PaymentsCaptureRequest, Data = D>,D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send,{- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- _state: &SessionState,- _payment_data: &mut D,- _request: Option<&CustomerDetails>,- _processor: &domain::Processor,- ) -> CustomResult<(), errors::StorageError> {- Ok(())- }-#[instrument(skip_all)]#[cfg(feature = "v1")]async fn get_or_create_customer_details<'a>(@@ -773,7 +738,6 @@ where_payment_data: &mut D,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(@@ -813,17 +777,6 @@ wherefor<'a> &'a Op: Operation<F, api::PaymentsCancelRequest, Data = D>,D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send,{- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- _state: &SessionState,- _payment_data: &mut D,- _request: Option<&CustomerDetails>,- _processor: &domain::Processor,- ) -> CustomResult<(), errors::StorageError> {- Ok(())- }-#[instrument(skip_all)]#[cfg(feature = "v1")]async fn get_or_create_customer_details<'a>(@@ -888,7 +841,6 @@ where_payment_data: &mut D,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(@@ -927,17 +879,6 @@ impl<D, F: Clone + Send, Op: Send + Sync + Operation<F, api::PaymentsRejectRequewherefor<'a> &'a Op: Operation<F, api::PaymentsRejectRequest, Data = D>,{- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- _state: &SessionState,- _payment_data: &mut D,- _request: Option<&CustomerDetails>,- _processor: &domain::Processor,- ) -> CustomResult<(), errors::StorageError> {- Ok(())- }-#[cfg(feature = "v1")]#[instrument(skip_all)]async fn get_or_create_customer_details<'a>(@@ -981,7 +922,6 @@ where_payment_data: &mut D,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(diff --git a/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs b/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rsindex ff23901874..5c60f18017 100644--- a/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs+++ b/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs@@ -338,7 +338,6 @@ impl<F: Clone + Send + Sync> Domain<F, ExternalVaultProxyPaymentsRequest, Paymen_payment_data: &mut PaymentConfirmData<F>,_storage_scheme: storage_enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(@@ -481,7 +480,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, ExternalVaultProxy_req_state: ReqState,processor: &domain::Processor,mut payment_data: PaymentConfirmData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<api_models::enums::FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(BoxedConfirmOperation<'b, F>, PaymentConfirmData<F>)>diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rsindex b39e58b99a..385991c4a0 100644--- a/crates/router/src/core/payments/operations/payment_approve.rs+++ b/crates/router/src/core/payments/operations/payment_approve.rs@@ -227,7 +227,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsCaptureRequereq_state: ReqState,processor: &domain::Processor,mut payment_data: PaymentData<F>,- _customer: Option<domain::Customer>,frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(PaymentApproveOperation<'b, F>, PaymentData<F>)>diff --git a/crates/router/src/core/payments/operations/payment_attempt_list.rs b/crates/router/src/core/payments/operations/payment_attempt_list.rsindex 665a81f343..e1844b5cb6 100644--- a/crates/router/src/core/payments/operations/payment_attempt_list.rs+++ b/crates/router/src/core/payments/operations/payment_attempt_list.rs@@ -125,7 +125,6 @@ impl<F: Clone + Sync>_req_state: ReqState,_processor: &domain::Processor,payment_data: payments::PaymentAttemptListData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(@@ -186,7 +185,6 @@ impl<F: Clone + Send + Sync>_payment_data: &mut payments::PaymentAttemptListData<F>,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(diff --git a/crates/router/src/core/payments/operations/payment_attempt_record.rs b/crates/router/src/core/payments/operations/payment_attempt_record.rsindex ed5fff1199..72cc660067 100644--- a/crates/router/src/core/payments/operations/payment_attempt_record.rs+++ b/crates/router/src/core/payments/operations/payment_attempt_record.rs@@ -246,7 +246,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentAttemptRecordData<F>, PaymentsAtte_req_state: ReqState,processor: &domain::Processor,mut payment_data: PaymentAttemptRecordData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(@@ -342,7 +341,6 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsAttemptRecordRequest, PaymentAtte_payment_data: &mut PaymentAttemptRecordData<F>,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rsindex c7881f1d4b..78ff394843 100644--- a/crates/router/src/core/payments/operations/payment_cancel.rs+++ b/crates/router/src/core/payments/operations/payment_cancel.rs@@ -239,7 +239,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsCancelRequesreq_state: ReqState,processor: &domain::Processor,mut payment_data: PaymentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(PaymentCancelOperation<'b, F>, PaymentData<F>)>diff --git a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rsindex 5c3f2d1d04..15a82aead4 100644--- a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs+++ b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs@@ -215,17 +215,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelPoimpl<F: Clone + Send + Sync> Domain<F, api::PaymentsCancelPostCaptureRequest, PaymentData<F>>for PaymentCancelPostCapture{- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- _state: &SessionState,- _payment_data: &mut PaymentData<F>,- _request: Option<&payments::CustomerDetails>,- _processor: &domain::Processor,- ) -> errors::CustomResult<(), errors::StorageError> {- Ok(())- }-#[instrument(skip_all)]async fn get_or_create_customer_details<'a>(&'a self,@@ -250,7 +239,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsCancelPostCaptureRequest, Pa_payment_data: &mut PaymentData<F>,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(@@ -293,7 +281,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsCancelPostCa_req_state: ReqState,_processor: &domain::Processor,payment_data: PaymentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(PaymentCancelPostCaptureOperation<'b, F>, PaymentData<F>)>diff --git a/crates/router/src/core/payments/operations/payment_cancel_v2.rs b/crates/router/src/core/payments/operations/payment_cancel_v2.rsindex 0254429b1c..dbfc7da691 100644--- a/crates/router/src/core/payments/operations/payment_cancel_v2.rs+++ b/crates/router/src/core/payments/operations/payment_cancel_v2.rs@@ -202,7 +202,6 @@ impl<F: Clone + Send + Sync>req_state: ReqState,processor: &domain::Processor,mut payment_data: hyperswitch_domain_models::payments::PaymentCancelData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(@@ -261,7 +260,6 @@ impl<F: Send + Clone + Sync>_payment_data: &mut hyperswitch_domain_models::payments::PaymentCancelData<F>,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rsindex 71a631f25b..149c160eaa 100644--- a/crates/router/src/core/payments/operations/payment_capture.rs+++ b/crates/router/src/core/payments/operations/payment_capture.rs@@ -295,7 +295,6 @@ impl<F: Clone + Sync> UpdateTracker<F, payments::PaymentData<F>, api::PaymentsCareq_state: ReqState,processor: &domain::Processor,mut payment_data: payments::PaymentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(PaymentCaptureOperation<'b, F>, payments::PaymentData<F>)>diff --git a/crates/router/src/core/payments/operations/payment_capture_v2.rs b/crates/router/src/core/payments/operations/payment_capture_v2.rsindex b23fa4c291..c2393108ad 100644--- a/crates/router/src/core/payments/operations/payment_capture_v2.rs+++ b/crates/router/src/core/payments/operations/payment_capture_v2.rs@@ -240,7 +240,6 @@ impl<F: Clone + Send> Domain<F, PaymentsCaptureRequest, PaymentCaptureData<F>> f_payment_data: &mut PaymentCaptureData<F>,_storage_scheme: storage_enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(@@ -297,7 +296,6 @@ impl<F: Clone> UpdateTracker<F, PaymentCaptureData<F>, PaymentsCaptureRequest> f_req_state: ReqState,processor: &domain::Processor,mut payment_data: PaymentCaptureData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(BoxedConfirmOperation<'b, F>, PaymentCaptureData<F>)>diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rsindex 030940fc12..3c8a50dbf2 100644--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs@@ -388,17 +388,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>#[async_trait]impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for CompleteAuthorize {- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- state: &SessionState,- payment_data: &mut PaymentData<F>,- request: Option<&CustomerDetails>,- processor: &domain::Processor,- ) -> CustomResult<(), errors::StorageError> {- helpers::populate_raw_customer_details(state, payment_data, request, processor).await- }-#[instrument(skip_all)]async fn get_or_create_customer_details<'a>(&'a self,@@ -454,7 +443,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forpayment_data: &mut PaymentData<F>,storage_scheme: storage_enums::MerchantStorageScheme,platform: &domain::Platform,- customer: &Option<domain::Customer>,business_profile: &domain::Profile,should_retry_with_pan: bool,) -> RouterResult<(@@ -467,7 +455,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forstate,payment_data,platform,- customer,storage_scheme,business_profile,should_retry_with_pan,@@ -519,7 +506,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> forreq_state: ReqState,processor: &domain::Processor,mut payment_data: PaymentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(CompleteAuthorizeOperation<'b, F>, PaymentData<F>)>diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex 7f9eb37ced..90f421fc5c 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -151,6 +151,16 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>let customer_details = helpers::get_customer_details_from_request(request);+ payment_intent.customer_details = helpers::merge_request_and_intent_customer_data(+ state,+ payment_intent.customer_details,+ &customer_details,+ platform.get_processor(),+ )+ .await+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Unable to store customer data in payment intent")?;+// Stage 2let attempt_id = payment_intent.active_attempt.get_id();let profile_id = payment_intent@@ -880,17 +890,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>#[async_trait]impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for PaymentConfirm {- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- state: &SessionState,- payment_data: &mut PaymentData<F>,- request: Option<&CustomerDetails>,- processor: &domain::Processor,- ) -> CustomResult<(), errors::StorageError> {- helpers::populate_raw_customer_details(state, payment_data, request, processor).await- }-#[instrument(skip_all)]async fn get_or_create_customer_details<'a>(&'a self,@@ -985,7 +984,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forpayment_data: &mut PaymentData<F>,storage_scheme: storage_enums::MerchantStorageScheme,platform: &domain::Platform,- customer: &Option<domain::Customer>,business_profile: &domain::Profile,should_retry_with_pan: bool,) -> RouterResult<(@@ -998,7 +996,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forstate,payment_data,platform,- customer,storage_scheme,business_profile,should_retry_with_pan,@@ -1914,7 +1911,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> forreq_state: ReqState,processor: &domain::Processor,mut payment_data: PaymentData<F>,- customer: Option<domain::Customer>,frm_suggestion: Option<FrmSuggestion>,header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(@@ -2047,7 +2043,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for.clone(),);- let customer_id = customer.clone().map(|c| c.customer_id);+ let customer_id = payment_data.payment_intent.customer_id.clone();let return_url = payment_data.payment_intent.return_url.take();let setup_future_usage = payment_data.payment_intent.setup_future_usage;let business_label = payment_data.payment_intent.business_label.clone();diff --git a/crates/router/src/core/payments/operations/payment_confirm_intent.rs b/crates/router/src/core/payments/operations/payment_confirm_intent.rsindex 00cb47e776..cf4bb8f36b 100644--- a/crates/router/src/core/payments/operations/payment_confirm_intent.rs+++ b/crates/router/src/core/payments/operations/payment_confirm_intent.rs@@ -499,7 +499,6 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsConfirmIntentRequest, PaymentConfpayment_data: &mut PaymentConfirmData<F>,storage_scheme: storage_enums::MerchantStorageScheme,_platform: &domain::Platform,- customer: &Option<domain::Customer>,business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(@@ -753,7 +752,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, PaymentsConfirmInt_req_state: ReqState,processor: &domain::Processor,mut payment_data: PaymentConfirmData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(BoxedConfirmOperation<'b, F>, PaymentConfirmData<F>)>diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 24582ccd00..b9187a32a1 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -18,10 +18,7 @@ use diesel_models::payment_attempt::ConnectorMandateReferenceId as DieselConnectuse error_stack::{self, ResultExt};use hyperswitch_domain_models::{mandates::MandateDetails,- payments::{- payment_attempt::PaymentAttempt, payment_intent::CustomerData,- FromRequestEncryptablePaymentIntent,- },+ payments::{payment_attempt::PaymentAttempt, FromRequestEncryptablePaymentIntent},};use masking::{ExposeInterface, PeekInterface, Secret};use router_derive::PaymentOperation;@@ -36,7 +33,6 @@ use crate::{errors::{self, CustomResult, RouterResult, StorageErrorExt},mandate::helpers as m_helpers,payment_link,- payment_methods::cards::create_encrypted_data,payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData},utils as core_utils,},@@ -52,7 +48,7 @@ use crate::{self,enums::{self, IntentStatus},},- transformers::{ForeignFrom, ForeignTryFrom},+ transformers::ForeignFrom,},utils::{self, OptionExt},};@@ -629,17 +625,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>#[async_trait]impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for PaymentCreate {- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- state: &SessionState,- payment_data: &mut PaymentData<F>,- request: Option<&CustomerDetails>,- processor: &domain::Processor,- ) -> CustomResult<(), errors::StorageError> {- helpers::populate_raw_customer_details(state, payment_data, request, processor).await- }-#[instrument(skip_all)]async fn get_or_create_customer_details<'a>(&'a self,@@ -790,7 +775,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forpayment_data: &mut PaymentData<F>,storage_scheme: enums::MerchantStorageScheme,platform: &domain::Platform,- customer: &Option<domain::Customer>,business_profile: &domain::Profile,should_retry_with_pan: bool,) -> RouterResult<(@@ -803,7 +787,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forstate,payment_data,platform,- customer,storage_scheme,business_profile,should_retry_with_pan,@@ -852,7 +835,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> forreq_state: ReqState,processor: &domain::Processor,mut payment_data: PaymentData<F>,- customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(PaymentCreateOperation<'b, F>, PaymentData<F>)>@@ -929,21 +911,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> forlet customer_id = payment_data.payment_intent.customer_id.clone();- let raw_customer_details = customer- .map(|customer| CustomerData::foreign_try_from(customer.clone()))- .transpose()?;- let key_manager_state = state.into();- // Updation of Customer Details for the cases where both customer_id and specific customer- // details are provided in Payment Create Request- let customer_details = raw_customer_details- .clone()- .async_map(|customer_details| {- create_encrypted_data(&key_manager_state, key_store, customer_details)- })- .await- .transpose()- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Unable to encrypt customer details")?;+ let customer_details = payment_data.payment_intent.customer_details.clone();payment_data.payment_intent = state.store@@ -1510,22 +1478,9 @@ impl PaymentCreate {let split_payments = request.split_payments.clone();// Derivation of directly supplied Customer data in our Payment Create Request- let raw_customer_details = if request.customer_id.is_none()- && (request.name.is_some()- || request.email.is_some()- || request.phone.is_some()- || request.phone_country_code.is_some())- {- Some(CustomerData {- name: request.name.clone(),- phone: request.phone.clone(),- email: request.email.clone(),- phone_country_code: request.phone_country_code.clone(),- tax_registration_id: None,- })- } else {- None- };+ let raw_customer_details =+ helpers::get_customer_details_from_request(request).get_customer_data();+let is_payment_processor_token_flow = request.recurring_details.as_ref().and_then(|recurring_details| match recurring_details {RecurringDetails::ProcessorPaymentToken(_) => Some(true),diff --git a/crates/router/src/core/payments/operations/payment_create_intent.rs b/crates/router/src/core/payments/operations/payment_create_intent.rsindex eb0db904c9..355fefc7e3 100644--- a/crates/router/src/core/payments/operations/payment_create_intent.rs+++ b/crates/router/src/core/payments/operations/payment_create_intent.rs@@ -199,7 +199,6 @@ impl<F: Clone + Sync> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsC_req_state: ReqState,_processor: &domain::Processor,payment_data: payments::PaymentIntentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(@@ -266,7 +265,6 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsCreateIntentRequest, payments::Pa_payment_data: &mut payments::PaymentIntentData<F>,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(diff --git a/crates/router/src/core/payments/operations/payment_get.rs b/crates/router/src/core/payments/operations/payment_get.rsindex bc756ab4b4..acc22e511a 100644--- a/crates/router/src/core/payments/operations/payment_get.rs+++ b/crates/router/src/core/payments/operations/payment_get.rs@@ -285,7 +285,6 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsRetrieveRequest, PaymentStatusDat_payment_data: &mut PaymentStatusData<F>,_storage_scheme: storage_enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(@@ -371,7 +370,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentStatusData<F>, PaymentsRetrieveReq_req_state: ReqState,_processor: &domain::Processor,payment_data: PaymentStatusData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(BoxedConfirmOperation<'b, F>, PaymentStatusData<F>)>diff --git a/crates/router/src/core/payments/operations/payment_get_intent.rs b/crates/router/src/core/payments/operations/payment_get_intent.rsindex bf8e7a70ac..bacc38fdd8 100644--- a/crates/router/src/core/payments/operations/payment_get_intent.rs+++ b/crates/router/src/core/payments/operations/payment_get_intent.rs@@ -127,7 +127,6 @@ impl<F: Clone + Sync> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsG_req_state: ReqState,_processor: &domain::Processor,payment_data: payments::PaymentIntentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(@@ -187,7 +186,6 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsGetIntentRequest, payments::Payme_payment_data: &mut payments::PaymentIntentData<F>,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(diff --git a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs b/crates/router/src/core/payments/operations/payment_post_session_tokens.rsindex 31a27efc32..256566bb17 100644--- a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs+++ b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs@@ -192,17 +192,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsPostSessimpl<F: Clone + Send + Sync> Domain<F, api::PaymentsPostSessionTokensRequest, PaymentData<F>>for PaymentPostSessionTokens{- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- _state: &SessionState,- _payment_data: &mut PaymentData<F>,- _request: Option<&payments::CustomerDetails>,- _processor: &domain::Processor,- ) -> errors::CustomResult<(), errors::StorageError> {- Ok(())- }-#[instrument(skip_all)]async fn get_or_create_customer_details<'a>(&'a self,@@ -227,7 +216,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsPostSessionTokensRequest, Pa_payment_data: &mut PaymentData<F>,_storage_scheme: storage_enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(@@ -270,7 +258,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsPostSessionT_req_state: ReqState,_processor: &domain::Processor,payment_data: PaymentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(PaymentPostSessionTokensOperation<'b, F>, PaymentData<F>)>diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rsindex 767a36cf9c..79c3779559 100644--- a/crates/router/src/core/payments/operations/payment_reject.rs+++ b/crates/router/src/core/payments/operations/payment_reject.rs@@ -224,7 +224,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, PaymentsCancelRequest> foreq_state: ReqState,processor: &domain::Processor,mut payment_data: PaymentData<F>,- _customer: Option<domain::Customer>,_should_decline_transaction: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(PaymentRejectOperation<'b, F>, PaymentData<F>)>diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rsindex f844c9441d..4f1f9dce76 100644--- a/crates/router/src/core/payments/operations/payment_session.rs+++ b/crates/router/src/core/payments/operations/payment_session.rs@@ -250,7 +250,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsSessionReque_req_state: ReqState,processor: &domain::Processor,mut payment_data: PaymentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(PaymentSessionOperation<'b, F>, PaymentData<F>)>@@ -314,17 +313,6 @@ impl<wherefor<'a> &'a Op: Operation<F, api::PaymentsSessionRequest, Data = PaymentData<F>>,{- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- state: &SessionState,- payment_data: &mut PaymentData<F>,- request: Option<&payments::CustomerDetails>,- processor: &domain::Processor,- ) -> errors::CustomResult<(), errors::StorageError> {- helpers::populate_raw_customer_details(state, payment_data, request, processor).await- }-#[instrument(skip_all)]async fn get_or_create_customer_details<'a>(&'a self,@@ -380,7 +368,6 @@ where_payment_data: &mut PaymentData<F>,_storage_scheme: storage_enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(diff --git a/crates/router/src/core/payments/operations/payment_session_intent.rs b/crates/router/src/core/payments/operations/payment_session_intent.rsindex a298931eb0..bbcbd0c208 100644--- a/crates/router/src/core/payments/operations/payment_session_intent.rs+++ b/crates/router/src/core/payments/operations/payment_session_intent.rs@@ -168,7 +168,6 @@ impl<F: Clone + Sync> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsS_req_state: ReqState,processor: &domain::Processor,mut payment_data: payments::PaymentIntentData<F>,- customer: Option<domain::Customer>,_frm_suggestion: Option<common_enums::FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(@@ -256,7 +255,6 @@ impl<F: Clone + Send + Sync> Domain<F, PaymentsSessionRequest, payments::Payment_payment_data: &mut payments::PaymentIntentData<F>,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rsindex b7283837ab..0fb1f8339c 100644--- a/crates/router/src/core/payments/operations/payment_start.rs+++ b/crates/router/src/core/payments/operations/payment_start.rs@@ -235,7 +235,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsStartRequest_req_state: ReqState,_processor: &domain::Processor,payment_data: PaymentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(PaymentSessionOperation<'b, F>, PaymentData<F>)>@@ -284,17 +283,6 @@ impl<wherefor<'a> &'a Op: Operation<F, api::PaymentsStartRequest, Data = PaymentData<F>>,{- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- state: &SessionState,- payment_data: &mut PaymentData<F>,- request: Option<&CustomerDetails>,- processor: &domain::Processor,- ) -> CustomResult<(), errors::StorageError> {- helpers::populate_raw_customer_details(state, payment_data, request, processor).await- }-#[instrument(skip_all)]async fn get_or_create_customer_details<'a>(&'a self,@@ -350,7 +338,6 @@ wherepayment_data: &mut PaymentData<F>,storage_scheme: storage_enums::MerchantStorageScheme,platform: &domain::Platform,- customer: &Option<domain::Customer>,business_profile: &domain::Profile,should_retry_with_pan: bool,) -> RouterResult<(@@ -370,7 +357,6 @@ wherestate,payment_data,platform,- customer,storage_scheme,business_profile,should_retry_with_pan,diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rsindex 4d1f11a657..d2c822b8fa 100644--- a/crates/router/src/core/payments/operations/payment_status.rs+++ b/crates/router/src/core/payments/operations/payment_status.rs@@ -59,17 +59,6 @@ impl<F: Send + Clone + Sync> Operation<F, api::PaymentsRequest> for &PaymentStat#[async_trait]impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for PaymentStatus {- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- state: &SessionState,- payment_data: &mut PaymentData<F>,- request: Option<&CustomerDetails>,- processor: &domain::Processor,- ) -> CustomResult<(), errors::StorageError> {- helpers::populate_raw_customer_details(state, payment_data, request, processor).await- }-#[instrument(skip_all)]async fn get_or_create_customer_details<'a>(&'a self,@@ -128,7 +117,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for_payment_data: &mut PaymentData<F>,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(@@ -179,7 +167,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> forreq_state: ReqState,_processor: &domain::Processor,payment_data: PaymentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(@@ -209,7 +196,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRetrieveRequreq_state: ReqState,_processor: &domain::Processor,payment_data: PaymentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rsindex b69b435251..92a627539e 100644--- a/crates/router/src/core/payments/operations/payment_update.rs+++ b/crates/router/src/core/payments/operations/payment_update.rs@@ -187,6 +187,16 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>payment_method_type.or(payment_attempt.payment_method_type);let customer_details = helpers::get_customer_details_from_request(request);+ payment_intent.customer_details = helpers::merge_request_and_intent_customer_data(+ state,+ payment_intent.customer_details,+ &customer_details,+ platform.get_processor(),+ )+ .await+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Unable to store customer data in payment intent")?;+let amount = request.amount.unwrap_or_else(|| payment_attempt.net_amount.get_order_amount().into());@@ -562,17 +572,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>#[async_trait]impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for PaymentUpdate {- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- state: &SessionState,- payment_data: &mut PaymentData<F>,- request: Option<&CustomerDetails>,- processor: &domain::Processor,- ) -> CustomResult<(), errors::StorageError> {- helpers::populate_raw_customer_details(state, payment_data, request, processor).await- }-#[instrument(skip_all)]async fn get_or_create_customer_details<'a>(&'a self,@@ -734,7 +733,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forpayment_data: &mut PaymentData<F>,storage_scheme: storage_enums::MerchantStorageScheme,platform: &domain::Platform,- customer: &Option<domain::Customer>,business_profile: &domain::Profile,should_retry_with_pan: bool,) -> RouterResult<(@@ -747,7 +745,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> forstate,payment_data,platform,- customer,storage_scheme,business_profile,should_retry_with_pan,@@ -815,7 +812,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> forreq_state: ReqState,processor: &domain::Processor,mut payment_data: PaymentData<F>,- customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(PaymentUpdateOperation<'b, F>, PaymentData<F>)>@@ -932,7 +928,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for.await.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;- let customer_id = customer.clone().map(|c| c.customer_id);+ let customer_id = payment_data.payment_intent.customer_id.clone();let intent_status = {let current_intent_status = payment_data.payment_intent.status;diff --git a/crates/router/src/core/payments/operations/payment_update_intent.rs b/crates/router/src/core/payments/operations/payment_update_intent.rsindex a55ea0c3f8..7fabcbac76 100644--- a/crates/router/src/core/payments/operations/payment_update_intent.rs+++ b/crates/router/src/core/payments/operations/payment_update_intent.rs@@ -331,7 +331,6 @@ impl<F: Clone> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsUpdateIn_req_state: ReqState,processor: &domain::Processor,mut payment_data: payments::PaymentIntentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(@@ -460,7 +459,6 @@ impl<F: Clone + Send> Domain<F, PaymentsUpdateIntentRequest, payments::PaymentIn_payment_data: &mut payments::PaymentIntentData<F>,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(diff --git a/crates/router/src/core/payments/operations/payment_update_metadata.rs b/crates/router/src/core/payments/operations/payment_update_metadata.rsindex cf2d2b78f3..c412d389e5 100644--- a/crates/router/src/core/payments/operations/payment_update_metadata.rs+++ b/crates/router/src/core/payments/operations/payment_update_metadata.rs@@ -178,17 +178,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsUpdateMeimpl<F: Clone + Send + Sync> Domain<F, api::PaymentsUpdateMetadataRequest, PaymentData<F>>for PaymentUpdateMetadata{- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- _state: &SessionState,- _payment_data: &mut PaymentData<F>,- _request: Option<&payments::CustomerDetails>,- _processor: &domain::Processor,- ) -> errors::CustomResult<(), errors::StorageError> {- Ok(())- }-#[instrument(skip_all)]async fn get_or_create_customer_details<'a>(&'a self,@@ -213,7 +202,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsUpdateMetadataRequest, Payme_payment_data: &mut PaymentData<F>,_storage_scheme: storage_enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(@@ -256,7 +244,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsUpdateMetada_req_state: ReqState,_processor: &domain::Processor,payment_data: PaymentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(PaymentUpdateMetadataOperation<'b, F>, PaymentData<F>)>diff --git a/crates/router/src/core/payments/operations/payments_extend_authorization.rs b/crates/router/src/core/payments/operations/payments_extend_authorization.rsindex 86d8ab7579..d9fd41c615 100644--- a/crates/router/src/core/payments/operations/payments_extend_authorization.rs+++ b/crates/router/src/core/payments/operations/payments_extend_authorization.rs@@ -220,17 +220,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsExtendAuimpl<F: Clone + Send + Sync> Domain<F, api::PaymentsExtendAuthorizationRequest, PaymentData<F>>for PaymentExtendAuthorization{- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- _state: &SessionState,- _payment_data: &mut PaymentData<F>,- _request: Option<&payments::CustomerDetails>,- _processor: &domain::Processor,- ) -> errors::CustomResult<(), errors::StorageError> {- Ok(())- }-#[instrument(skip_all)]async fn get_or_create_customer_details<'a>(&'a self,@@ -255,7 +244,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsExtendAuthorizationRequest,_payment_data: &mut PaymentData<F>,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(@@ -298,7 +286,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsExtendAuthor_req_state: ReqState,_processor: &domain::Processor,payment_data: PaymentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(PaymentExtendAuthorizationOperation<'b, F>, PaymentData<F>)>diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rsindex 02f8bb5478..8b0bc88d89 100644--- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs+++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs@@ -207,7 +207,6 @@ impl<F: Clone + Sync>_req_state: ReqState,processor: &domain::Processor,mut payment_data: payments::PaymentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(@@ -318,17 +317,6 @@ impl<F: Clone + Send + Sync>Domain<F, PaymentsIncrementalAuthorizationRequest, payments::PaymentData<F>>for PaymentIncrementalAuthorization{- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- _state: &SessionState,- _payment_data: &mut payments::PaymentData<F>,- _request: Option<&CustomerDetails>,- _processor: &domain::Processor,- ) -> CustomResult<(), errors::StorageError> {- Ok(())- }-#[instrument(skip_all)]async fn get_or_create_customer_details<'a>(&'a self,@@ -358,7 +346,6 @@ impl<F: Clone + Send + Sync>_payment_data: &mut payments::PaymentData<F>,_storage_scheme: enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(diff --git a/crates/router/src/core/payments/operations/proxy_payments_intent.rs b/crates/router/src/core/payments/operations/proxy_payments_intent.rsindex caa865c7ed..28363bb36a 100644--- a/crates/router/src/core/payments/operations/proxy_payments_intent.rs+++ b/crates/router/src/core/payments/operations/proxy_payments_intent.rs@@ -301,7 +301,6 @@ impl<F: Clone + Send + Sync> Domain<F, ProxyPaymentsRequest, PaymentConfirmData<_payment_data: &mut PaymentConfirmData<F>,_storage_scheme: storage_enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(@@ -366,7 +365,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentConfirmData<F>, ProxyPaymentsReque_req_state: ReqState,processor: &domain::Processor,mut payment_data: PaymentConfirmData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<api_models::enums::FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(BoxedConfirmOperation<'b, F>, PaymentConfirmData<F>)>diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rsindex 34b891b66d..80ad3b299b 100644--- a/crates/router/src/core/payments/operations/tax_calculation.rs+++ b/crates/router/src/core/payments/operations/tax_calculation.rs@@ -208,17 +208,6 @@ impl<F: Send + Clone + Sync>impl<F: Clone + Send + Sync> Domain<F, api::PaymentsDynamicTaxCalculationRequest, PaymentData<F>>for PaymentSessionUpdate{- #[instrument(skip_all)]- async fn populate_raw_customer_details<'a>(- &'a self,- _state: &SessionState,- _payment_data: &mut PaymentData<F>,- _request: Option<&payments::CustomerDetails>,- _processor: &domain::Processor,- ) -> errors::CustomResult<(), errors::StorageError> {- Ok(())- }-#[instrument(skip_all)]async fn get_or_create_customer_details<'a>(&'a self,@@ -346,7 +335,6 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsDynamicTaxCalculationRequest_payment_data: &mut PaymentData<F>,_storage_scheme: storage_enums::MerchantStorageScheme,_platform: &domain::Platform,- _customer: &Option<domain::Customer>,_business_profile: &domain::Profile,_should_retry_with_pan: bool,) -> RouterResult<(@@ -389,7 +377,6 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsDynamicTaxCa_req_state: ReqState,processor: &domain::Processor,mut payment_data: PaymentData<F>,- _customer: Option<domain::Customer>,_frm_suggestion: Option<FrmSuggestion>,_header_payload: hyperswitch_domain_models::payments::HeaderPayload,) -> RouterResult<(PaymentSessionUpdateOperation<'b, F>, PaymentData<F>)>diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rsindex 1d4a0c4bde..6b9211021d 100644--- a/crates/router/src/core/payments/retry.rs+++ b/crates/router/src/core/payments/retry.rs@@ -405,7 +405,6 @@ whereconnector.clone(),operation,payment_data,- customer,validate_result,business_profile,should_retry_with_pan,@@ -413,6 +412,10 @@ where).await?;+ let connector_customer_map = customer+ .as_ref()+ .and_then(|customer| customer.connector_customer.as_ref());+let (updated_customer, call_connector_service_response, updated_state) =payments::decide_unified_connector_service_call(state,@@ -420,7 +423,7 @@ whereconnector.clone(),operation,payment_data,- customer,+ connector_customer_map,payments::CallConnectorAction::Trigger,None,validate_result,@@ -449,7 +452,6 @@ whereplatform.get_processor(),operation,payment_data,- customer,business_profile,None,connector,diff --git a/crates/router/src/core/payments/session_operation.rs b/crates/router/src/core/payments/session_operation.rsindex 36e84aa94e..0117ebcac0 100644--- a/crates/router/src/core/payments/session_operation.rs+++ b/crates/router/src/core/payments/session_operation.rs@@ -189,7 +189,6 @@ wherereq_state,platform.get_processor(),payment_data.clone(),- customer.clone(),None,header_payload.clone(),)diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex a5aadec281..756ce16bbd 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -99,7 +99,6 @@ pub async fn construct_router_data_to_update_calculated_tax<'a, F, T>(payment_data: PaymentData<F>,connector_id: &str,processor: &domain::Processor,- customer: &'a Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,) -> RouterResult<types::RouterData<F, T, types::PaymentsResponseData>>where@@ -121,12 +120,28 @@ where.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed while parsing value for ConnectorAuthType")?;+ let customer_details = payment_data+ .payment_intent+ .customer_details+ .clone()+ .map(|customer_details_encrypted| {+ customer_details_encrypted+ .into_inner()+ .expose()+ .parse_value::<CustomerData>("CustomerData")+ })+ .transpose()+ .change_context(errors::StorageError::DeserializationFailed)+ .attach_printable("Failed to parse customer data from payment intent")+ .change_context(errors::ApiErrorResponse::InternalServerError)?;+let additional_data = PaymentAdditionalData {router_base_url: state.base_url.clone(),connector_name: connector_id.to_string(),payment_data: payment_data.clone(),state,- customer_data: customer,+ customer_data: customer_details,+ customer_id: payment_data.payment_intent.customer_id.clone(),};let connector_mandate_request_reference_id = payment_data@@ -1639,7 +1654,6 @@ pub async fn construct_payment_router_data<'a, F, T>(payment_data: PaymentData<F>,connector_id: &str,processor: &domain::Processor,- customer: &'a Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -1698,15 +1712,31 @@ wherecharges: None,});+ let customer_details = payment_data+ .payment_intent+ .customer_details+ .clone()+ .map(|customer_details_encrypted| {+ customer_details_encrypted+ .into_inner()+ .expose()+ .parse_value::<CustomerData>("CustomerData")+ })+ .transpose()+ .change_context(errors::StorageError::DeserializationFailed)+ .attach_printable("Failed to parse customer data from payment intent")+ .change_context(errors::ApiErrorResponse::InternalServerError)?;+let additional_data = PaymentAdditionalData {router_base_url: state.base_url.clone(),connector_name: connector_id.to_string(),payment_data: payment_data.clone(),state,- customer_data: customer,+ customer_data: customer_details.clone(),+ customer_id: payment_data.payment_intent.customer_id.clone(),};- let customer_id = customer.to_owned().map(|customer| customer.customer_id);+ let customer_id = payment_data.payment_intent.customer_id.clone();let supported_connector = &state.conf@@ -1797,12 +1827,9 @@ where}),tax_info: Some(types::TaxInfo {tax_status: payment_data.payment_intent.tax_status,- customer_tax_registration_id: customer.as_ref().and_then(|customer| {- customer- .tax_registration_id- .as_ref()- .map(|tax_registration_id| tax_registration_id.clone().into_inner())- }),+ customer_tax_registration_id: customer_details+ .as_ref()+ .and_then(|customer| customer.tax_registration_id.clone()),merchant_tax_registration_id,shipping_amount_tax: payment_data.payment_intent.shipping_amount_tax,order_tax_amount: payment_data@@ -1812,20 +1839,16 @@ where}),customer_info: Some(types::CustomerInfo {customer_id: payment_data.payment_intent.customer_id.clone(),- customer_email: payment_data.email,- customer_name: customer.as_ref().and_then(|customer_data| {- customer_data- .name- .as_ref()- .map(|name| name.clone().into_inner())- }),- customer_phone_number: customer.as_ref().and_then(|customer_data| {- customer_data- .phone- .as_ref()- .map(|phone| phone.clone().into_inner())- }),- customer_phone_country_code: customer+ customer_email: customer_details+ .as_ref()+ .and_then(|customer_data| customer_data.email.clone()),+ customer_name: customer_details+ .as_ref()+ .and_then(|customer_data| customer_data.name.clone()),+ customer_phone_number: customer_details+ .as_ref()+ .and_then(|customer_data| customer_data.phone.clone()),+ customer_phone_country_code: customer_details.as_ref().and_then(|customer_data| customer_data.phone_country_code.clone()),}),@@ -1944,7 +1967,6 @@ pub async fn construct_payment_router_data_for_update_metadata<'a>(payment_data: PaymentData<api::UpdateMetadata>,connector_id: &str,processor: &domain::Processor,- customer: &'a Option<domain::Customer>,merchant_connector_account: &helpers::MerchantConnectorAccountType,merchant_recipient_data: Option<types::MerchantRecipientData>,header_payload: Option<hyperswitch_domain_models::payments::HeaderPayload>,@@ -1990,15 +2012,31 @@ pub async fn construct_payment_router_data_for_update_metadata<'a>(connector_metadata: None,});+ let customer_details = payment_data+ .payment_intent+ .customer_details+ .clone()+ .map(|customer_details_encrypted| {+ customer_details_encrypted+ .into_inner()+ .expose()+ .parse_value::<CustomerData>("CustomerData")+ })+ .transpose()+ .change_context(errors::StorageError::DeserializationFailed)+ .attach_printable("Failed to parse customer data from payment intent")+ .change_context(errors::ApiErrorResponse::InternalServerError)?;+let additional_data = PaymentAdditionalData {router_base_url: state.base_url.clone(),connector_name: connector_id.to_string(),payment_data: payment_data.clone(),state,- customer_data: customer,+ customer_data: customer_details,+ customer_id: payment_data.payment_intent.customer_id.clone(),};- let customer_id = customer.to_owned().map(|customer| customer.customer_id);+ let customer_id = payment_data.payment_intent.customer_id.clone();let supported_connector = &state.conf@@ -2146,7 +2184,6 @@ where#[allow(clippy::too_many_arguments)]fn generate_response(data: D,- customer: Option<domain::Customer>,auth_flow: services::AuthFlow,base_url: &str,operation: Op,@@ -2380,7 +2417,6 @@ where#[allow(clippy::too_many_arguments)]fn generate_response(payment_data: D,- customer: Option<domain::Customer>,auth_flow: services::AuthFlow,base_url: &str,operation: Op,@@ -2409,7 +2445,6 @@ wherepayments_to_payments_response(payment_data,captures,- customer,auth_flow,base_url,&operation,@@ -2433,7 +2468,6 @@ where#[allow(clippy::too_many_arguments)]fn generate_response(payment_data: D,- _customer: Option<domain::Customer>,_auth_flow: services::AuthFlow,_base_url: &str,_operation: Op,@@ -2499,7 +2533,6 @@ where#[allow(clippy::too_many_arguments)]fn generate_response(payment_data: D,- _customer: Option<domain::Customer>,_auth_flow: services::AuthFlow,_base_url: &str,_operation: Op,@@ -3178,7 +3211,6 @@ where{fn generate_response(payment_data: D,- _customer: Option<domain::Customer>,_auth_flow: services::AuthFlow,_base_url: &str,_operation: Op,@@ -3215,7 +3247,6 @@ where{fn generate_response(payment_data: D,- _customer: Option<domain::Customer>,_auth_flow: services::AuthFlow,_base_url: &str,_operation: Op,@@ -3318,7 +3349,6 @@ where#[allow(clippy::too_many_arguments)]fn generate_response(payment_data: D,- customer: Option<domain::Customer>,_auth_flow: services::AuthFlow,_base_url: &str,_operation: Op,@@ -3339,6 +3369,23 @@ where})?;let payment_method_data_response =additional_payment_method_data.map(api::PaymentMethodDataResponse::from);++ let payment_intent = payment_data.get_payment_intent();++ let customer = payment_intent+ .customer_details+ .clone()+ .map(|customer_details_encrypted| {+ customer_details_encrypted+ .into_inner()+ .expose()+ .parse_value::<CustomerData>("CustomerData")+ })+ .transpose()+ .change_context(errors::StorageError::DeserializationFailed)+ .attach_printable("Failed to parse customer data from payment intent")+ .change_context(errors::ApiErrorResponse::InternalServerError)?;+Ok(services::ApplicationResponse::JsonWithHeaders((Self {verify_id: Some(payment_data.get_payment_intent().payment_id.clone()),@@ -3348,7 +3395,7 @@ where.client_secret.clone().map(Secret::new),- customer_id: customer.as_ref().map(|x| x.customer_id.clone()),+ customer_id: payment_intent.customer_id.clone(),email: customer.as_ref().and_then(|cus| cus.email.as_ref().map(|s| s.to_owned())),@@ -3404,7 +3451,6 @@ wherepub fn payments_to_payments_response<Op, F: Clone, D>(payment_data: D,captures: Option<Vec<storage::Capture>>,- customer: Option<domain::Customer>,_auth_flow: services::AuthFlow,base_url: &str,operation: &Op,@@ -3551,61 +3597,25 @@ where))}- // For the case when we don't have Customer data directly stored in Payment intent- let customer_table_response: Option<CustomerDetailsResponse> =- customer.as_ref().map(ForeignInto::foreign_into);-// If we have customer data in Payment Intent and if the customer is not deleted, We are populating the Retrieve response from the// same. If the customer is deleted then we use the customer table to populate customer details- let customer_details_response =- if let Some(customer_details_raw) = payment_intent.customer_details.clone() {- let customer_details_encrypted =- serde_json::from_value::<CustomerData>(customer_details_raw.into_inner().expose());- if let Ok(customer_details_encrypted_data) = customer_details_encrypted {- Some(CustomerDetailsResponse {- id: customer_table_response- .as_ref()- .and_then(|customer_data| customer_data.id.clone()),- name: customer_table_response- .as_ref()- .and_then(|customer_data| customer_data.name.clone())- .or(customer_details_encrypted_data- .name- .or(customer.as_ref().and_then(|customer| {- customer.name.as_ref().map(|name| name.clone().into_inner())- }))),- email: customer_table_response- .as_ref()- .and_then(|customer_data| customer_data.email.clone())- .or(customer_details_encrypted_data.email.or(customer- .as_ref()- .and_then(|customer| customer.email.clone().map(pii::Email::from)))),- phone: customer_table_response- .as_ref()- .and_then(|customer_data| customer_data.phone.clone())- .or(customer_details_encrypted_data- .phone- .or(customer.as_ref().and_then(|customer| {- customer- .phone- .as_ref()- .map(|phone| phone.clone().into_inner())- }))),- phone_country_code: customer_table_response- .as_ref()- .and_then(|customer_data| customer_data.phone_country_code.clone())- .or(customer_details_encrypted_data- .phone_country_code- .or(customer- .as_ref()- .and_then(|customer| customer.phone_country_code.clone()))),- })- } else {- customer_table_response- }- } else {- customer_table_response- };+ let customer_details_response = payment_intent+ .customer_details+ .clone()+ .and_then(|customer_details_raw| {+ customer_details_raw+ .into_inner()+ .expose()+ .parse_value::<CustomerData>("CustomerData")+ .ok()+ })+ .map(|customer_details| CustomerDetailsResponse {+ id: payment_intent.customer_id.clone(),+ name: customer_details.name,+ email: customer_details.email,+ phone: customer_details.phone,+ phone_country_code: customer_details.phone_country_code,+ });headers.extend(external_latency@@ -3911,8 +3921,10 @@ wherecreated: Some(payment_intent.created_at),modified_at: Some(payment_intent.modified_at),currency: currency.to_string(),- customer_id: customer.as_ref().map(|cus| cus.clone().customer_id),- customer: customer_details_response,+ customer_id: customer_details_response+ .as_ref()+ .and_then(|cus| cus.id.clone()),+ customer: customer_details_response.clone(),description: payment_intent.description,refunds: refunds_response,disputes: disputes_response,@@ -3940,13 +3952,13 @@ where.cloned().map(From::from),order_details: payment_intent.order_details,- email: customer+ email: customer_details_response.as_ref().and_then(|cus| cus.email.as_ref().map(|s| s.to_owned())),- name: customer+ name: customer_details_response.as_ref().and_then(|cus| cus.name.as_ref().map(|s| s.to_owned())),- phone: customer+ phone: customer_details_response.as_ref().and_then(|cus| cus.phone.as_ref().map(|s| s.to_owned())),return_url: payment_intent.return_url,@@ -4585,7 +4597,8 @@ whereconnector_name: String,payment_data: PaymentData<F>,state: &'a SessionState,- customer_data: &'a Option<domain::Customer>,+ customer_data: Option<CustomerData>,+ customer_id: Option<common_utils::id_type::CustomerId>,}#[cfg(feature = "v2")]@@ -4644,17 +4657,9 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthorizlet customer_name = additional_data.customer_data.as_ref()- .and_then(|customer_data| {- customer_data- .name- .as_ref()- .map(|customer| customer.clone().into_inner())- });+ .and_then(|customer_data| customer_data.name.clone());- let customer_id = additional_data- .customer_data- .as_ref()- .and_then(|data| data.get_id().clone().try_into().ok());+ let customer_id = additional_data.customer_id.clone();let merchant_order_reference_id = payment_data.payment_intent@@ -4846,17 +4851,9 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthorizlet customer_name = additional_data.customer_data.as_ref()- .and_then(|customer_data| {- customer_data- .name- .as_ref()- .map(|customer| customer.clone().into_inner())- });+ .and_then(|customer_data| customer_data.name.clone());- let customer_id = additional_data- .customer_data- .as_ref()- .map(|data| data.customer_id.clone());+ let customer_id = additional_data.customer_id.clone();let split_payments = payment_data.payment_intent.split_payments.clone();@@ -5896,12 +5893,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequlet customer_name = additional_data.customer_data.as_ref()- .and_then(|customer_data| {- customer_data- .name- .as_ref()- .map(|customer| customer.clone().into_inner())- });+ .and_then(|customer_data| customer_data.name.clone());let amount = payment_data.payment_attempt.get_total_amount();let merchant_connector_account_id_or_connector_name = payment_data.payment_attemptdiff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rsindex 09744ee2da..8b6e600795 100644--- a/crates/router/src/core/payouts.rs+++ b/crates/router/src/core/payouts.rs@@ -1241,7 +1241,7 @@ pub async fn create_recipient(if let Some(updated_customer) =customers::update_connector_customer_in_customers(&connector_label,- Some(&customer),+ customer.connector_customer.as_ref(),recipient_create_data.connector_payout_id.clone(),).awaitdiff --git a/crates/router/src/core/pm_auth.rs b/crates/router/src/core/pm_auth.rsindex cac2c62b49..bec8637514 100644--- a/crates/router/src/core/pm_auth.rs+++ b/crates/router/src/core/pm_auth.rs@@ -767,7 +767,6 @@ pub async fn retrieve_payment_method_from_auth_service(processor: &domain::Processor,auth_token: &payment_methods::BankAccountTokenData,payment_intent: &PaymentIntent,- _customer: &Option<domain::Customer>,) -> RouterResult<Option<(domain::PaymentMethodData, enums::PaymentMethod)>> {let db = state.store.as_ref();diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rsindex 63d322d987..f1700dd9b6 100644--- a/crates/router/src/types/transformers.rs+++ b/crates/router/src/types/transformers.rs@@ -1629,26 +1629,33 @@ impl.map(api_types::Address::from);// This change is to fix a merchant integration- // If billing.email is not passed by the merchant, and if the customer email is present, then use the `customer.email` as the billing email+ // If billing.email is not passed by the merchant, and if the customer email is present, then use that as the billing email+ // Priority order for fallback email: `payment_intent.customer_details.email` > `customer.email`if let Some(billing_address) = &mut billing_address {billing_address.email = billing_address.email.clone().or_else(|| {- customer- .and_then(|cust| {- cust.email- .as_ref()- .map(|email| pii::Email::from(email.clone()))+ customer_details_from_pi+ .as_ref()+ .and_then(|cd| cd.email.clone())+ .or_else(|| {+ customer.and_then(|cust| {+ cust.email+ .as_ref()+ .map(|email| pii::Email::from(email.clone()))+ })})- .or(customer_details_from_pi.clone().and_then(|cd| cd.email))});} else {billing_address = Some(payments::Address {- email: customer- .and_then(|cust| {- cust.email- .as_ref()- .map(|email| pii::Email::from(email.clone()))- })- .or(customer_details_from_pi.clone().and_then(|cd| cd.email)),+ email: customer_details_from_pi+ .as_ref()+ .and_then(|cd| cd.email.clone())+ .or_else(|| {+ customer.and_then(|cust| {+ cust.email+ .as_ref()+ .map(|email| pii::Email::from(email.clone()))+ })+ }),..Default::default()});}@@ -1661,15 +1668,25 @@ implbilling: billing_address,amount: payment_attempt.map(|pa| api_types::Amount::from(pa.net_amount.get_order_amount())),- email: customer- .and_then(|cust| cust.email.as_ref().map(|em| pii::Email::from(em.clone())))- .or(customer_details_from_pi.clone().and_then(|cd| cd.email)),- phone: customer- .and_then(|cust| cust.phone.as_ref().map(|p| p.clone().into_inner()))- .or(customer_details_from_pi.clone().and_then(|cd| cd.phone)),- name: customer- .and_then(|cust| cust.name.as_ref().map(|n| n.clone().into_inner()))- .or(customer_details_from_pi.clone().and_then(|cd| cd.name)),+ email: customer_details_from_pi+ .as_ref()+ .and_then(|cd| cd.email.clone())+ .or_else(|| {+ customer+ .and_then(|cust| cust.email.as_ref().map(|em| pii::Email::from(em.clone())))+ }),+ phone: customer_details_from_pi+ .as_ref()+ .and_then(|cd| cd.phone.clone())+ .or_else(|| {+ customer.and_then(|cust| cust.phone.as_ref().map(|p| p.clone().into_inner()))+ }),+ name: customer_details_from_pi+ .as_ref()+ .and_then(|cd| cd.name.clone())+ .or_else(|| {+ customer.and_then(|cust| cust.name.as_ref().map(|n| n.clone().into_inner()))+ }),..Self::default()})}diff --git a/crates/router/src/utils.rs b/crates/router/src/utils.rsindex 8fd71114d8..5e777517de 100644--- a/crates/router/src/utils.rs+++ b/crates/router/src/utils.rs@@ -1165,7 +1165,6 @@ pub async fn trigger_payments_webhook<F, Op, D>(initiator: Option<&domain::Initiator>,business_profile: domain::Profile,payment_data: D,- customer: Option<domain::Customer>,state: &SessionState,operation: Op,) -> RouterResult<()>@@ -1196,7 +1195,6 @@ wherelet payments_response = crate::core::payments::transformers::payments_to_payments_response(payment_data,captures,- customer,services::AuthFlow::Merchant,&state.base_url,&operation,diff --git a/crates/router/src/workflows/payment_sync.rs b/crates/router/src/workflows/payment_sync.rsindex 084f596740..699acb6fbb 100644--- a/crates/router/src/workflows/payment_sync.rs+++ b/crates/router/src/workflows/payment_sync.rs@@ -80,27 +80,26 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentsSyncWorkflow {None,);// TODO: Add support for ReqState in PT flows- let (mut payment_data, _, customer, _, _) =- Box::pin(payment_flows::payments_operation_core::<- api::PSync,- _,- _,- _,- payment_flows::PaymentData<api::PSync>,- >(- state,- state.get_req_state(),- &platform,- None,- operations::PaymentStatus,- tracking_data.clone(),- payment_flows::CallConnectorAction::Trigger,- None,- services::AuthFlow::Client,- None,- hyperswitch_domain_models::payments::HeaderPayload::default(),- ))- .await?;+ let (mut payment_data, _, _, _) = Box::pin(payment_flows::payments_operation_core::<+ api::PSync,+ _,+ _,+ _,+ payment_flows::PaymentData<api::PSync>,+ >(+ state,+ state.get_req_state(),+ &platform,+ None,+ operations::PaymentStatus,+ tracking_data.clone(),+ payment_flows::CallConnectorAction::Trigger,+ None,+ services::AuthFlow::Client,+ None,+ hyperswitch_domain_models::payments::HeaderPayload::default(),+ ))+ .await?;let terminal_status = [enums::AttemptStatus::RouterDeclined,@@ -216,7 +215,6 @@ impl ProcessTrackerWorkflow<SessionState> for PaymentsSyncWorkflow {platform.get_initiator(),business_profile,payment_data,- customer,state,operation,))diff --git a/crates/subscriptions/src/core/subscription_handler.rs b/crates/subscriptions/src/core/subscription_handler.rsindex 0181d6d7a5..b323cb7423 100644--- a/crates/subscriptions/src/core/subscription_handler.rs+++ b/crates/subscriptions/src/core/subscription_handler.rs@@ -116,7 +116,7 @@ impl<'a> SubscriptionHandler<'a> {Some(customer_response) => {match customer::update_connector_customer_in_customers(merchant_connector_id.get_string_repr(),- Some(customer),+ customer.connector_customer.as_ref(),Some(customer_response.connector_customer_id),).await