diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 0236ee0c51..23c3b219b6 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -641,6 +641,8 @@ pub struct HeaderPayload { pub x_client_platform: Option, pub x_merchant_domain: Option, pub locale: Option, + pub x_app_id: Option, + pub x_redirect_uri: Option, } impl HeaderPayload { diff --git a/crates/api_models/src/pm_auth.rs b/crates/api_models/src/pm_auth.rs index 8ed52907da..443a4c3039 100644 --- a/crates/api_models/src/pm_auth.rs +++ b/crates/api_models/src/pm_auth.rs @@ -4,6 +4,8 @@ use common_utils::{ id_type, impl_api_event_type, }; +use crate::enums as api_enums; + #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] #[serde(rename_all = "snake_case")] pub struct LinkTokenCreateRequest { @@ -12,6 +14,9 @@ pub struct LinkTokenCreateRequest { pub payment_id: id_type::PaymentId, // payment_id to be passed in req body for redis pm_auth connector name fetch pub payment_method: PaymentMethod, // payment_method to be used for filtering pm_auth connector pub payment_method_type: PaymentMethodType, // payment_method_type to be used for filtering pm_auth connector + pub client_platform: api_enums::ClientPlatform, // Client Platform to perform platform based processing + pub android_package_name: Option, // Android Package name to be sent for Android platform + pub redirect_uri: Option, // Merchant redirect_uri to be sent in case of IOS platform } #[derive(Debug, Clone, serde::Serialize)] diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 65ef8d8725..a6a001ad06 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -2480,6 +2480,7 @@ pub enum ClientPlatform { #[default] Web, Ios, + Android, #[serde(other)] Unknown, } diff --git a/crates/hyperswitch_domain_models/src/router_data.rs b/crates/hyperswitch_domain_models/src/router_data.rs index a9451f6156..cd8ac85594 100644 --- a/crates/hyperswitch_domain_models/src/router_data.rs +++ b/crates/hyperswitch_domain_models/src/router_data.rs @@ -80,6 +80,10 @@ pub struct RouterData { pub minor_amount_captured: Option, pub integrity_check: Result<(), IntegrityCheckError>, + + pub additional_merchant_data: Option, + + pub header_payload: Option, } // Different patterns of authentication. diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs index ec182056f6..93ace230f1 100644 --- a/crates/hyperswitch_domain_models/src/router_request_types.rs +++ b/crates/hyperswitch_domain_models/src/router_request_types.rs @@ -346,6 +346,8 @@ pub struct PaymentsPostProcessingData { pub customer_id: Option, pub connector_transaction_id: Option, pub country: Option, + pub connector_meta_data: Option, + pub header_payload: Option, } impl TryFrom> @@ -371,6 +373,8 @@ impl TryFrom, user: User, + android_package_name: Option, + redirect_uri: Option, } #[derive(Debug, Serialize, Eq, PartialEq)] @@ -42,6 +44,30 @@ impl TryFrom<&types::LinkTokenRouterData> for PlaidLinkTokenRequest { }, )?, }, + android_package_name: match item.request.client_platform { + api_models::enums::ClientPlatform::Android => { + Some(item.request.android_package_name.clone().ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "android_package_name", + }, + )?) + } + api_models::enums::ClientPlatform::Ios + | api_models::enums::ClientPlatform::Web + | api_models::enums::ClientPlatform::Unknown => None, + }, + redirect_uri: match item.request.client_platform { + api_models::enums::ClientPlatform::Ios => { + Some(item.request.redirect_uri.clone().ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "redirect_uri", + }, + )?) + } + api_models::enums::ClientPlatform::Android + | api_models::enums::ClientPlatform::Web + | api_models::enums::ClientPlatform::Unknown => None, + }, }) } } diff --git a/crates/pm_auth/src/types.rs b/crates/pm_auth/src/types.rs index 4c20e879d8..878043afe5 100644 --- a/crates/pm_auth/src/types.rs +++ b/crates/pm_auth/src/types.rs @@ -3,6 +3,7 @@ pub mod api; use std::marker::PhantomData; use api::auth_service::{BankAccountCredentials, ExchangeToken, LinkToken, RecipientCreate}; +use api_models::enums as api_enums; use common_enums::{CountryAlpha2, PaymentMethod, PaymentMethodType}; use common_utils::{id_type, types}; use masking::Secret; @@ -24,6 +25,9 @@ pub struct LinkTokenRequest { pub country_codes: Option>, pub language: Option, pub user_info: Option, + pub client_platform: api_enums::ClientPlatform, + pub android_package_name: Option, + pub redirect_uri: Option, } #[derive(Debug, Clone)] diff --git a/crates/router/src/connector/plaid/transformers.rs b/crates/router/src/connector/plaid/transformers.rs index cf9c91afd0..c4eb5a7a03 100644 --- a/crates/router/src/connector/plaid/transformers.rs +++ b/crates/router/src/connector/plaid/transformers.rs @@ -1,6 +1,5 @@ use common_enums::Currency; use common_utils::types::FloatMajorUnit; -use error_stack::ResultExt; use masking::{PeekInterface, Secret}; use serde::{Deserialize, Serialize}; @@ -73,6 +72,8 @@ pub struct PlaidLinkTokenRequest { products: Vec, user: User, payment_initiation: PlaidPaymentInitiation, + redirect_uri: Option, + android_package_name: Option, } #[derive(Default, Debug, Serialize, Deserialize)] @@ -105,21 +106,21 @@ impl TryFrom<&PlaidRouterData<&types::PaymentsAuthorizeRouterData>> for PlaidPay .ok_or(errors::ConnectorError::MissingRequiredField { field_name: "payment_id", })?; - let recipient_val = item + let recipient_type = item .router_data - .connector_meta_data + .additional_merchant_data .as_ref() + .map(|merchant_data| match merchant_data { + api_models::admin::AdditionalMerchantData::OpenBankingRecipientData( + data, + ) => data.clone(), + }) .ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "connector_customer", - })? - .peek() - .clone(); + field_name: "additional_merchant_data", + })?; - let recipient_type = - serde_json::from_value::(recipient_val) - .change_context(errors::ConnectorError::ParsingFailed)?; let recipient_id = match recipient_type { - types::MerchantRecipientData::ConnectorRecipientId(id) => { + api_models::admin::MerchantRecipientData::ConnectorRecipientId(id) => { Ok(id.peek().to_string()) } _ => Err(errors::ConnectorError::MissingRequiredField { @@ -159,35 +160,73 @@ impl TryFrom<&types::PaymentsSyncRouterData> for PlaidSyncRequest { impl TryFrom<&types::PaymentsPostProcessingRouterData> for PlaidLinkTokenRequest { type Error = error_stack::Report; fn try_from(item: &types::PaymentsPostProcessingRouterData) -> Result { - match item.request.payment_method_data.clone() { + match item.request.payment_method_data { domain::PaymentMethodData::OpenBanking(ref data) => match data { - domain::OpenBankingData::OpenBankingPIS { .. } => Ok(Self { - client_name: "Hyperswitch".to_string(), - country_codes: item - .request - .country - .map(|code| vec![code.to_string()]) - .ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "billing.address.country", - })?, - language: "en".to_string(), - products: vec!["payment_initiation".to_string()], - user: User { - client_user_id: item + domain::OpenBankingData::OpenBankingPIS { .. } => { + let headers = item.header_payload.clone().ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "header_payload", + }, + )?; + + let platform = headers.x_client_platform.ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "x_client_platform", + }, + )?; + + let (is_android, is_ios) = match platform { + common_enums::ClientPlatform::Android => (true, false), + common_enums::ClientPlatform::Ios => (false, true), + _ => (false, false), + }; + + Ok(Self { + client_name: "Hyperswitch".to_string(), + country_codes: item .request - .customer_id - .clone() - .map(|id| id.get_string_repr().to_string()) - .unwrap_or("default cust".to_string()), - }, - payment_initiation: PlaidPaymentInitiation { - payment_id: item - .request - .connector_transaction_id - .clone() - .ok_or(errors::ConnectorError::MissingConnectorTransactionID)?, - }, - }), + .country + .map(|code| vec![code.to_string()]) + .ok_or(errors::ConnectorError::MissingRequiredField { + field_name: "billing.address.country", + })?, + language: "en".to_string(), + products: vec!["payment_initiation".to_string()], + user: User { + client_user_id: item + .request + .customer_id + .clone() + .map(|id| id.get_string_repr().to_string()) + .unwrap_or("default cust".to_string()), + }, + payment_initiation: PlaidPaymentInitiation { + payment_id: item + .request + .connector_transaction_id + .clone() + .ok_or(errors::ConnectorError::MissingConnectorTransactionID)?, + }, + android_package_name: if is_android { + Some(headers.x_app_id.ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "x-app-id", + }, + )?) + } else { + None + }, + redirect_uri: if is_ios { + Some(headers.x_redirect_uri.ok_or( + errors::ConnectorError::MissingRequiredField { + field_name: "x_redirect_uri", + }, + )?) + } else { + None + }, + }) + } }, _ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()), } diff --git a/crates/router/src/core/authentication.rs b/crates/router/src/core/authentication.rs index 6f1746b527..29508b5c0f 100644 --- a/crates/router/src/core/authentication.rs +++ b/crates/router/src/core/authentication.rs @@ -61,8 +61,12 @@ pub async fn perform_authentication( webhook_url, three_ds_requestor_url, )?; - let response = - utils::do_auth_connector_call(state, authentication_connector.clone(), router_data).await?; + let response = Box::pin(utils::do_auth_connector_call( + state, + authentication_connector.clone(), + router_data, + )) + .await?; let authentication = utils::update_trackers(state, response.clone(), authentication_data, None).await?; response diff --git a/crates/router/src/core/authentication/transformers.rs b/crates/router/src/core/authentication/transformers.rs index 3372d9b355..6013cdbe97 100644 --- a/crates/router/src/core/authentication/transformers.rs +++ b/crates/router/src/core/authentication/transformers.rs @@ -182,6 +182,8 @@ pub fn construct_router_data( payment_method_status: None, connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, }) } diff --git a/crates/router/src/core/fraud_check.rs b/crates/router/src/core/fraud_check.rs index c696c5072b..2217de2090 100644 --- a/crates/router/src/core/fraud_check.rs +++ b/crates/router/src/core/fraud_check.rs @@ -119,6 +119,7 @@ where customer, &merchant_connector_account, None, + None, ) .await?; diff --git a/crates/router/src/core/fraud_check/flows/checkout_flow.rs b/crates/router/src/core/fraud_check/flows/checkout_flow.rs index 74606eb591..92dc2a99e8 100644 --- a/crates/router/src/core/fraud_check/flows/checkout_flow.rs +++ b/crates/router/src/core/fraud_check/flows/checkout_flow.rs @@ -39,6 +39,7 @@ impl ConstructFlowSpecificData, _merchant_connector_account: &helpers::MerchantConnectorAccountType, _merchant_recipient_data: Option, + _header_payload: Option, ) -> RouterResult> { todo!() @@ -54,6 +55,7 @@ impl ConstructFlowSpecificData, merchant_connector_account: &helpers::MerchantConnectorAccountType, _merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult> { let status = storage_enums::AttemptStatus::Pending; @@ -151,6 +153,8 @@ impl ConstructFlowSpecificData( dispute_id: None, connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, }; Ok(router_data) } diff --git a/crates/router/src/core/fraud_check/flows/record_return.rs b/crates/router/src/core/fraud_check/flows/record_return.rs index 6603f09cad..e4d002931e 100644 --- a/crates/router/src/core/fraud_check/flows/record_return.rs +++ b/crates/router/src/core/fraud_check/flows/record_return.rs @@ -36,6 +36,7 @@ impl ConstructFlowSpecificData, _merchant_connector_account: &helpers::MerchantConnectorAccountType, _merchant_recipient_data: Option, + _header_payload: Option, ) -> RouterResult> { todo!() @@ -51,6 +52,7 @@ impl ConstructFlowSpecificData, merchant_connector_account: &helpers::MerchantConnectorAccountType, _merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult> { let status = storage_enums::AttemptStatus::Pending; @@ -120,6 +122,8 @@ impl ConstructFlowSpecificData, _merchant_connector_account: &helpers::MerchantConnectorAccountType, _merchant_recipient_data: Option, + _header_payload: Option, ) -> RouterResult> { todo!() } @@ -48,6 +49,7 @@ impl ConstructFlowSpecificData, merchant_connector_account: &helpers::MerchantConnectorAccountType, _merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult> { let status = storage_enums::AttemptStatus::Pending; @@ -128,6 +130,8 @@ impl ConstructFlowSpecificData, _merchant_connector_account: &helpers::MerchantConnectorAccountType, _merchant_recipient_data: Option, + _header_payload: Option, ) -> RouterResult< RouterData, > { @@ -55,6 +56,7 @@ impl customer: &Option, merchant_connector_account: &helpers::MerchantConnectorAccountType, _merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult< RouterData, > { @@ -134,6 +136,8 @@ impl dispute_id: None, connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload, }; Ok(router_data) diff --git a/crates/router/src/core/mandate/utils.rs b/crates/router/src/core/mandate/utils.rs index de4b0b77fe..544f9ea756 100644 --- a/crates/router/src/core/mandate/utils.rs +++ b/crates/router/src/core/mandate/utils.rs @@ -78,6 +78,8 @@ pub async fn construct_mandate_revoke_router_data( dispute_id: None, connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, }; Ok(router_data) diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index 744b93032b..283e02f975 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -372,6 +372,7 @@ where &connector, &mut payment_data, op_ref, + Some(header_payload.clone()), ) .await?; } @@ -496,6 +497,7 @@ where &connector_data, &mut payment_data, op_ref, + Some(header_payload.clone()), ) .await?; } @@ -1642,6 +1644,7 @@ where customer, &merchant_connector_account, merchant_recipient_data, + None, ) .await?; @@ -1975,6 +1978,7 @@ where customer, &merchant_connector_account, None, + None, ) .await?; @@ -2120,6 +2124,7 @@ where customer, merchant_connector_account, None, + None, ) .await?; @@ -2304,6 +2309,7 @@ async fn complete_postprocessing_steps_if_required( connector: &api::ConnectorData, payment_data: &mut D, _operation: &BoxedOperation<'_, F, Q, D>, + header_payload: Option, ) -> RouterResult> where F: Send + Clone + Sync, @@ -2324,6 +2330,7 @@ where customer, merchant_conn_account, None, + header_payload, ) .await?; diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs index 245e8ae629..e364d662e2 100644 --- a/crates/router/src/core/payments/flows.rs +++ b/crates/router/src/core/payments/flows.rs @@ -38,6 +38,7 @@ pub trait ConstructFlowSpecificData { customer: &Option, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult>; #[cfg(all(feature = "v2", feature = "customer_v2"))] @@ -50,6 +51,7 @@ pub trait ConstructFlowSpecificData { _customer: &Option, _merchant_connector_account: &helpers::MerchantConnectorAccountType, _merchant_recipient_data: Option, + _header_payload: Option, ) -> RouterResult>; async fn get_merchant_recipient_data<'a>( diff --git a/crates/router/src/core/payments/flows/approve_flow.rs b/crates/router/src/core/payments/flows/approve_flow.rs index 4ede7c5085..c91de9eb3a 100644 --- a/crates/router/src/core/payments/flows/approve_flow.rs +++ b/crates/router/src/core/payments/flows/approve_flow.rs @@ -25,6 +25,7 @@ impl customer: &Option, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult { Box::pin(transformers::construct_payment_router_data::< api::Approve, @@ -38,6 +39,7 @@ impl customer, merchant_connector_account, merchant_recipient_data, + header_payload, )) .await } diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs index f4bf869daa..6fbe98b3a4 100644 --- a/crates/router/src/core/payments/flows/authorize_flow.rs +++ b/crates/router/src/core/payments/flows/authorize_flow.rs @@ -37,6 +37,7 @@ impl customer: &Option, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult< types::RouterData< api::Authorize, @@ -56,6 +57,7 @@ impl customer, merchant_connector_account, merchant_recipient_data, + header_payload, )) .await } diff --git a/crates/router/src/core/payments/flows/cancel_flow.rs b/crates/router/src/core/payments/flows/cancel_flow.rs index fb6ed6f3ac..1f212cc631 100644 --- a/crates/router/src/core/payments/flows/cancel_flow.rs +++ b/crates/router/src/core/payments/flows/cancel_flow.rs @@ -25,6 +25,7 @@ impl ConstructFlowSpecificData, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult { Box::pin(transformers::construct_payment_router_data::< api::Void, @@ -38,6 +39,7 @@ impl ConstructFlowSpecificData, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult { Box::pin(transformers::construct_payment_router_data::< api::Capture, @@ -38,6 +39,7 @@ impl customer, merchant_connector_account, merchant_recipient_data, + header_payload, )) .await } diff --git a/crates/router/src/core/payments/flows/complete_authorize_flow.rs b/crates/router/src/core/payments/flows/complete_authorize_flow.rs index 35038695f0..0e27e4f37a 100644 --- a/crates/router/src/core/payments/flows/complete_authorize_flow.rs +++ b/crates/router/src/core/payments/flows/complete_authorize_flow.rs @@ -29,6 +29,7 @@ impl customer: &Option, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult< types::RouterData< api::CompleteAuthorize, @@ -48,6 +49,7 @@ impl customer, merchant_connector_account, merchant_recipient_data, + header_payload, )) .await } diff --git a/crates/router/src/core/payments/flows/incremental_authorization_flow.rs b/crates/router/src/core/payments/flows/incremental_authorization_flow.rs index 6452d27913..7a3f9f0ac4 100644 --- a/crates/router/src/core/payments/flows/incremental_authorization_flow.rs +++ b/crates/router/src/core/payments/flows/incremental_authorization_flow.rs @@ -28,6 +28,7 @@ impl customer: &Option, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult { Box::pin(transformers::construct_payment_router_data::< api::IncrementalAuthorization, @@ -41,6 +42,7 @@ impl customer, merchant_connector_account, merchant_recipient_data, + header_payload, )) .await } diff --git a/crates/router/src/core/payments/flows/psync_flow.rs b/crates/router/src/core/payments/flows/psync_flow.rs index 9c06cc7fd1..2bb8fc1908 100644 --- a/crates/router/src/core/payments/flows/psync_flow.rs +++ b/crates/router/src/core/payments/flows/psync_flow.rs @@ -26,6 +26,7 @@ impl ConstructFlowSpecificData, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult< types::RouterData, > { @@ -41,6 +42,7 @@ impl ConstructFlowSpecificData, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult { Box::pin(transformers::construct_payment_router_data::< api::Reject, @@ -37,6 +38,7 @@ impl ConstructFlowSpecificData, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult { Box::pin(transformers::construct_payment_router_data::< api::Session, @@ -53,6 +54,7 @@ impl customer, merchant_connector_account, merchant_recipient_data, + header_payload, )) .await } diff --git a/crates/router/src/core/payments/flows/session_update_flow.rs b/crates/router/src/core/payments/flows/session_update_flow.rs index 3ada522a61..6cad250081 100644 --- a/crates/router/src/core/payments/flows/session_update_flow.rs +++ b/crates/router/src/core/payments/flows/session_update_flow.rs @@ -28,6 +28,7 @@ impl customer: &Option, merchant_connector_account: &helpers::MerchantConnectorAccountType, _merchant_recipient_data: Option, + _header_payload: Option, ) -> RouterResult { Box::pin( transformers::construct_router_data_to_update_calculated_tax::< diff --git a/crates/router/src/core/payments/flows/setup_mandate_flow.rs b/crates/router/src/core/payments/flows/setup_mandate_flow.rs index f9a5458840..69720b870a 100644 --- a/crates/router/src/core/payments/flows/setup_mandate_flow.rs +++ b/crates/router/src/core/payments/flows/setup_mandate_flow.rs @@ -32,6 +32,7 @@ impl customer: &Option, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult { Box::pin(transformers::construct_payment_router_data::< api::SetupMandate, @@ -45,6 +46,7 @@ impl customer, merchant_connector_account, merchant_recipient_data, + header_payload, )) .await } diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index b0e2f61d18..ded12b781d 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -3744,6 +3744,8 @@ pub fn router_data_type_conversion( connector_response: router_data.connector_response, integrity_check: Ok(()), connector_wallets_details: router_data.connector_wallets_details, + additional_merchant_data: router_data.additional_merchant_data, + header_payload: router_data.header_payload, } } diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 22c047edfc..37e178dc7f 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -151,6 +151,8 @@ where dispute_id: None, connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, }; Ok(router_data) } @@ -167,6 +169,7 @@ pub async fn construct_payment_router_data<'a, F, T>( _customer: &'a Option, _merchant_connector_account: &helpers::MerchantConnectorAccountType, _merchant_recipient_data: Option, + _header_payload: Option, ) -> RouterResult> where T: TryFrom>, @@ -190,6 +193,7 @@ pub async fn construct_payment_router_data<'a, F, T>( customer: &'a Option, merchant_connector_account: &helpers::MerchantConnectorAccountType, merchant_recipient_data: Option, + header_payload: Option, ) -> RouterResult> where T: TryFrom>, @@ -318,14 +322,7 @@ where .payment_attempt .authentication_type .unwrap_or_default(), - connector_meta_data: if let Some(data) = merchant_recipient_data { - let val = serde_json::to_value(data) - .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable("Failed while encoding MerchantRecipientData")?; - Some(Secret::new(val)) - } else { - merchant_connector_account.get_metadata() - }, + connector_meta_data: merchant_connector_account.get_metadata(), connector_wallets_details: merchant_connector_account.get_connector_wallets_details(), request: T::try_from(additional_data)?, response, @@ -364,6 +361,12 @@ where dispute_id: None, connector_response: None, integrity_check: Ok(()), + additional_merchant_data: merchant_recipient_data.map(|data| { + api_models::admin::AdditionalMerchantData::foreign_from( + types::AdditionalMerchantData::OpenBankingRecipientData(data), + ) + }), + header_payload, }; Ok(router_data) diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rs index e40c0f353a..c96da24443 100644 --- a/crates/router/src/core/payouts.rs +++ b/crates/router/src/core/payouts.rs @@ -730,13 +730,13 @@ pub async fn payouts_fulfill_core( .await? .get_required_value("payout_method_data")?, ); - fulfill_payout( + Box::pin(fulfill_payout( &state, &merchant_account, &key_store, &connector_data, &mut payout_data, - ) + )) .await .attach_printable("Payout fulfillment failed for given Payout request")?; @@ -1138,13 +1138,13 @@ pub async fn call_connector_payout( // Auto fulfillment flow let status = payout_data.payout_attempt.status; if payouts.auto_fulfill && status == storage_enums::PayoutStatus::RequiresFulfillment { - fulfill_payout( + Box::pin(fulfill_payout( state, merchant_account, key_store, connector_data, payout_data, - ) + )) .await .attach_printable("Payout fulfillment failed for given Payout request")?; } diff --git a/crates/router/src/core/pm_auth.rs b/crates/router/src/core/pm_auth.rs index d6d4df6700..a09ca4fc6e 100644 --- a/crates/router/src/core/pm_auth.rs +++ b/crates/router/src/core/pm_auth.rs @@ -165,6 +165,9 @@ pub async fn create_link_token( )?]), language: payload.language, user_info: payment_intent.and_then(|pi| pi.customer_id), + client_platform: payload.client_platform, + android_package_name: payload.android_package_name, + redirect_uri: payload.redirect_uri, }, response: Ok(pm_auth_types::LinkTokenResponse { link_token: "".to_string(), diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rs index 118f4b8176..0436ba2906 100644 --- a/crates/router/src/core/refunds.rs +++ b/crates/router/src/core/refunds.rs @@ -1185,7 +1185,7 @@ pub async fn schedule_refund_execution( Ok(refund) } api_models::refunds::RefundType::Instant => { - let update_refund = trigger_refund_to_gateway( + let update_refund = Box::pin(trigger_refund_to_gateway( state, &refund, merchant_account, @@ -1194,7 +1194,7 @@ pub async fn schedule_refund_execution( payment_intent, creds_identifier, charges, - ) + )) .await; match update_refund { @@ -1438,7 +1438,7 @@ pub async fn trigger_refund_execute_workflow( }; //trigger refund request to gateway - let updated_refund = trigger_refund_to_gateway( + let updated_refund = Box::pin(trigger_refund_to_gateway( state, &refund, &merchant_account, @@ -1447,7 +1447,7 @@ pub async fn trigger_refund_execute_workflow( &payment_intent, None, charges, - ) + )) .await?; add_refund_sync_task( db, diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rs index 53d97b43d9..607de45215 100644 --- a/crates/router/src/core/utils.rs +++ b/crates/router/src/core/utils.rs @@ -215,6 +215,8 @@ pub async fn construct_payout_router_data<'a, F>( dispute_id: None, connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, }; Ok(router_data) @@ -389,6 +391,8 @@ pub async fn construct_refund_router_data<'a, F>( dispute_id: None, connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, }; Ok(router_data) @@ -697,6 +701,8 @@ pub async fn construct_accept_dispute_router_data<'a>( refund_id: None, connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, }; Ok(router_data) } @@ -790,6 +796,8 @@ pub async fn construct_submit_evidence_router_data<'a>( dispute_id: Some(dispute.dispute_id.clone()), connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, }; Ok(router_data) } @@ -889,6 +897,8 @@ pub async fn construct_upload_file_router_data<'a>( dispute_id: None, connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, }; Ok(router_data) } @@ -1008,6 +1018,8 @@ pub async fn construct_payments_dynamic_tax_calculation_router_data<'a, F: Clone payment_method_status: None, minor_amount_captured: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, }; Ok(router_data) } @@ -1104,6 +1116,8 @@ pub async fn construct_defend_dispute_router_data<'a>( dispute_id: Some(dispute.dispute_id.clone()), connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, }; Ok(router_data) } @@ -1194,6 +1208,8 @@ pub async fn construct_retrieve_file_router_data<'a>( dispute_id: None, connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, }; Ok(router_data) } diff --git a/crates/router/src/core/webhooks/utils.rs b/crates/router/src/core/webhooks/utils.rs index 8987a9384d..8680e43eff 100644 --- a/crates/router/src/core/webhooks/utils.rs +++ b/crates/router/src/core/webhooks/utils.rs @@ -120,6 +120,8 @@ pub async fn construct_webhook_router_data<'a>( dispute_id: None, connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, }; Ok(router_data) } diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rs index b6ac439a5c..c1eac13832 100644 --- a/crates/router/src/lib.rs +++ b/crates/router/src/lib.rs @@ -83,6 +83,8 @@ pub mod headers { pub const BROWSER_NAME: &str = "x-browser-name"; pub const X_CLIENT_PLATFORM: &str = "x-client-platform"; pub const X_MERCHANT_DOMAIN: &str = "x-merchant-domain"; + pub const X_APP_ID: &str = "x-app-id"; + pub const X_REDIRECT_URI: &str = "x-redirect-uri"; pub const X_TENANT_ID: &str = "x-tenant-id"; } diff --git a/crates/router/src/services/conversion_impls.rs b/crates/router/src/services/conversion_impls.rs index f1aec19bd3..2293091609 100644 --- a/crates/router/src/services/conversion_impls.rs +++ b/crates/router/src/services/conversion_impls.rs @@ -74,6 +74,8 @@ fn get_default_router_data( payment_method_status: None, minor_amount_captured: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, } } diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs index 3a56271b08..30bb663068 100644 --- a/crates/router/src/types.rs +++ b/crates/router/src/types.rs @@ -907,6 +907,8 @@ impl ForeignFrom<(&RouterData, T2) refund_id: data.refund_id.clone(), connector_response: data.connector_response.clone(), integrity_check: Ok(()), + additional_merchant_data: data.additional_merchant_data.clone(), + header_payload: data.header_payload.clone(), } } } @@ -969,6 +971,8 @@ impl dispute_id: None, connector_response: data.connector_response.clone(), integrity_check: Ok(()), + additional_merchant_data: data.additional_merchant_data.clone(), + header_payload: data.header_payload.clone(), } } } diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rs index 1b3162a354..6c92b1b801 100644 --- a/crates/router/src/types/api/verify_connector.rs +++ b/crates/router/src/types/api/verify_connector.rs @@ -113,6 +113,8 @@ impl VerifyConnectorData { dispute_id: None, connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, } } } diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index bfad15e5d9..992816a361 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -20,8 +20,8 @@ use super::domain; use crate::{ core::errors, headers::{ - ACCEPT_LANGUAGE, BROWSER_NAME, X_CLIENT_PLATFORM, X_CLIENT_SOURCE, X_CLIENT_VERSION, - X_MERCHANT_DOMAIN, X_PAYMENT_CONFIRM_SOURCE, + ACCEPT_LANGUAGE, BROWSER_NAME, X_APP_ID, X_CLIENT_PLATFORM, X_CLIENT_SOURCE, + X_CLIENT_VERSION, X_MERCHANT_DOMAIN, X_PAYMENT_CONFIRM_SOURCE, X_REDIRECT_URI, }, services::authentication::get_header_value_by_key, types::{ @@ -1455,6 +1455,12 @@ impl ForeignTryFrom<&HeaderMap> for payments::HeaderPayload { let x_merchant_domain = get_header_value_by_key(X_MERCHANT_DOMAIN.into(), headers)?.map(|val| val.to_string()); + let x_app_id = + get_header_value_by_key(X_APP_ID.into(), headers)?.map(|val| val.to_string()); + + let x_redirect_uri = + get_header_value_by_key(X_REDIRECT_URI.into(), headers)?.map(|val| val.to_string()); + Ok(Self { payment_confirm_source, client_source, @@ -1464,6 +1470,8 @@ impl ForeignTryFrom<&HeaderMap> for payments::HeaderPayload { x_client_platform, x_merchant_domain, locale, + x_app_id, + x_redirect_uri, }) } } diff --git a/crates/router/tests/connectors/aci.rs b/crates/router/tests/connectors/aci.rs index f3ff1a6036..5d48a0188f 100644 --- a/crates/router/tests/connectors/aci.rs +++ b/crates/router/tests/connectors/aci.rs @@ -126,6 +126,8 @@ fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData { refund_id: None, dispute_id: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, } } @@ -193,6 +195,8 @@ fn construct_refund_router_data() -> types::RefundsRouterData { refund_id: None, dispute_id: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, } } diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs index ea12d463fb..582c212c24 100644 --- a/crates/router/tests/connectors/utils.rs +++ b/crates/router/tests/connectors/utils.rs @@ -544,6 +544,8 @@ pub trait ConnectorActions: Connector { dispute_id: None, connector_response: None, integrity_check: Ok(()), + additional_merchant_data: None, + header_payload: None, } }