diff --git a/.typos.toml b/.typos.toml index 642eaded60..3223e799cc 100644 --- a/.typos.toml +++ b/.typos.toml @@ -36,6 +36,7 @@ ws = "ws" # Web socket ws2ipdef = "ws2ipdef" # WinSock Extension ws2tcpip = "ws2tcpip" # WinSock Extension ZAR = "ZAR" # South African Rand currency code +JOD = "JOD" # Jordan currency code [default.extend-words] diff --git a/crates/router/src/compatibility/stripe/payment_intents.rs b/crates/router/src/compatibility/stripe/payment_intents.rs index d67e10a96e..b8ef4137f9 100644 --- a/crates/router/src/compatibility/stripe/payment_intents.rs +++ b/crates/router/src/compatibility/stripe/payment_intents.rs @@ -6,7 +6,7 @@ use router_env::{instrument, tracing, Flow, Tag}; use crate::{ compatibility::{stripe::errors, wrap}, - core::{api_locking::GetLockingInput, payment_methods::Oss, payments}, + core::{api_locking::GetLockingInput, payments}, logger, routes::{self, payments::get_or_generate_payment_id}, services::{api, authentication as auth}, @@ -58,7 +58,7 @@ pub async fn payment_intents_create( create_payment_req, |state, auth, req, req_state| { let eligible_connectors = req.connector.clone(); - payments::payments_core::( + payments::payments_core::( state, req_state, auth.merchant_account, @@ -118,7 +118,7 @@ pub async fn payment_intents_retrieve( &req, payload, |state, auth, payload, req_state| { - payments::payments_core::( + payments::payments_core::( state, req_state, auth.merchant_account, @@ -188,7 +188,7 @@ pub async fn payment_intents_retrieve_with_gateway_creds( &req, payload, |state, auth, req, req_state| { - payments::payments_core::( + payments::payments_core::( state, req_state, auth.merchant_account, @@ -197,7 +197,7 @@ pub async fn payment_intents_retrieve_with_gateway_creds( req, api::AuthFlow::Merchant, payments::CallConnectorAction::Trigger, - None, + None, api_types::HeaderPayload::default(), ) }, @@ -254,7 +254,7 @@ pub async fn payment_intents_update( payload, |state, auth, req, req_state| { let eligible_connectors = req.connector.clone(); - payments::payments_core::( + payments::payments_core::( state, req_state, auth.merchant_account, @@ -326,7 +326,7 @@ pub async fn payment_intents_confirm( payload, |state, auth, req, req_state| { let eligible_connectors = req.connector.clone(); - payments::payments_core::( + payments::payments_core::( state, req_state, auth.merchant_account, @@ -387,7 +387,7 @@ pub async fn payment_intents_capture( &req, payload, |state, auth, payload, req_state| { - payments::payments_core::( + payments::payments_core::( state, req_state, auth.merchant_account, @@ -396,7 +396,7 @@ pub async fn payment_intents_capture( payload, api::AuthFlow::Merchant, payments::CallConnectorAction::Trigger, - None, + None, api_types::HeaderPayload::default(), ) }, @@ -452,7 +452,7 @@ pub async fn payment_intents_cancel( &req, payload, |state, auth, req, req_state| { - payments::payments_core::( + payments::payments_core::( state, req_state, auth.merchant_account, diff --git a/crates/router/src/compatibility/stripe/setup_intents.rs b/crates/router/src/compatibility/stripe/setup_intents.rs index 60627ee564..c7bde0dbcd 100644 --- a/crates/router/src/compatibility/stripe/setup_intents.rs +++ b/crates/router/src/compatibility/stripe/setup_intents.rs @@ -9,7 +9,7 @@ use crate::{ stripe::{errors, payment_intents::types as stripe_payment_types}, wrap, }, - core::{api_locking, payment_methods::Oss, payments}, + core::{api_locking, payments}, routes, services::{api, authentication as auth}, types::api as api_types, @@ -58,8 +58,7 @@ pub async fn setup_intents_create( api_types::PaymentsResponse, _, _, - _, - Oss, + _ >( state, req_state, @@ -120,7 +119,7 @@ pub async fn setup_intents_retrieve( &req, payload, |state, auth, payload, req_state| { - payments::payments_core::( + payments::payments_core::( state, req_state, auth.merchant_account, @@ -191,8 +190,7 @@ pub async fn setup_intents_update( api_types::PaymentsResponse, _, _, - _, - Oss, + _ >( state, req_state, @@ -265,8 +263,7 @@ pub async fn setup_intents_confirm( api_types::PaymentsResponse, _, _, - _, - Oss, + _ >( state, req_state, diff --git a/crates/router/src/connector/rapyd/transformers.rs b/crates/router/src/connector/rapyd/transformers.rs index 22e1074802..d949a30a01 100644 --- a/crates/router/src/connector/rapyd/transformers.rs +++ b/crates/router/src/connector/rapyd/transformers.rs @@ -454,7 +454,7 @@ impl }), ), _ => { - let redirction_url = data + let redirection_url = data .redirect_url .as_ref() .filter(|redirect_str| !redirect_str.is_empty()) @@ -465,7 +465,7 @@ impl }) .transpose()?; - let redirection_data = redirction_url + let redirection_data = redirection_url .map(|url| services::RedirectForm::from((url, services::Method::Get))); ( diff --git a/crates/router/src/core/fraud_check.rs b/crates/router/src/core/fraud_check.rs index e26d5d0b46..4d614662a4 100644 --- a/crates/router/src/core/fraud_check.rs +++ b/crates/router/src/core/fraud_check.rs @@ -437,7 +437,7 @@ where } #[allow(clippy::too_many_arguments)] -pub async fn pre_payment_frm_core<'a, F, Req, Ctx>( +pub async fn pre_payment_frm_core<'a, F, Req>( state: &AppState, merchant_account: &domain::MerchantAccount, payment_data: &mut payments::PaymentData, @@ -447,7 +447,7 @@ pub async fn pre_payment_frm_core<'a, F, Req, Ctx>( should_continue_transaction: &mut bool, should_continue_capture: &mut bool, key_store: domain::MerchantKeyStore, - operation: &BoxedOperation<'_, F, Req, Ctx>, + operation: &BoxedOperation<'_, F, Req>, ) -> RouterResult> where F: Send + Clone, @@ -616,9 +616,9 @@ where } #[allow(clippy::too_many_arguments)] -pub async fn call_frm_before_connector_call<'a, F, Req, Ctx>( +pub async fn call_frm_before_connector_call<'a, F, Req>( db: &dyn StorageInterface, - operation: &BoxedOperation<'_, F, Req, Ctx>, + operation: &BoxedOperation<'_, F, Req>, merchant_account: &domain::MerchantAccount, payment_data: &mut payments::PaymentData, state: &AppState, diff --git a/crates/router/src/core/fraud_check/operation/fraud_check_post.rs b/crates/router/src/core/fraud_check/operation/fraud_check_post.rs index 49862495f3..758574809c 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 @@ -17,7 +17,6 @@ use crate::{ types::{FrmData, PaymentDetails, PaymentToFrmData, CANCEL_INITIATED}, ConnectorDetailsCore, FrmConfigsObject, }, - payment_methods::Oss, payments, }, db::StorageInterface, @@ -214,7 +213,6 @@ impl Domain for FraudCheckPost { _, _, _, - Oss, >( state.clone(), req_state.clone(), @@ -269,7 +267,6 @@ impl Domain for FraudCheckPost { _, _, _, - Oss, >( state.clone(), req_state.clone(), diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs index b2a4959edf..71f0bdac03 100644 --- a/crates/router/src/core/payment_methods.rs +++ b/crates/router/src/core/payment_methods.rs @@ -9,6 +9,7 @@ use api_models::payments::CardToken; pub use api_models::{enums::PayoutConnectors, payouts as payout_types}; use diesel_models::enums; use hyperswitch_domain_models::payments::{payment_attempt::PaymentAttempt, PaymentIntent}; +use router_env::{instrument, tracing}; use crate::{ core::{errors::RouterResult, payments::helpers, pm_auth as core_pm_auth}, @@ -19,238 +20,214 @@ use crate::{ }, }; -pub struct Oss; +#[instrument(skip_all)] +pub async fn retrieve_payment_method( + pm_data: &Option, + state: &AppState, + payment_intent: &PaymentIntent, + payment_attempt: &PaymentAttempt, + merchant_key_store: &domain::MerchantKeyStore, +) -> RouterResult<(Option, Option)> { + match pm_data { + pm_opt @ Some(pm @ api::PaymentMethodData::Card(_)) => { + let payment_token = helpers::store_payment_method_data_in_vault( + state, + payment_attempt, + payment_intent, + enums::PaymentMethod::Card, + pm, + merchant_key_store, + ) + .await?; -#[async_trait::async_trait] -pub trait PaymentMethodRetrieve { - async fn retrieve_payment_method( - pm_data: &Option, - state: &AppState, - payment_intent: &PaymentIntent, - payment_attempt: &PaymentAttempt, - merchant_key_store: &domain::MerchantKeyStore, - ) -> RouterResult<(Option, Option)>; - - async fn retrieve_payment_method_with_token( - state: &AppState, - key_store: &domain::MerchantKeyStore, - token: &storage::PaymentTokenData, - payment_intent: &PaymentIntent, - card_token_data: Option<&CardToken>, - customer: &Option, - storage_scheme: common_enums::enums::MerchantStorageScheme, - ) -> RouterResult; -} - -#[async_trait::async_trait] -impl PaymentMethodRetrieve for Oss { - async fn retrieve_payment_method( - pm_data: &Option, - state: &AppState, - payment_intent: &PaymentIntent, - payment_attempt: &PaymentAttempt, - merchant_key_store: &domain::MerchantKeyStore, - ) -> RouterResult<(Option, Option)> { - match pm_data { - pm_opt @ Some(pm @ api::PaymentMethodData::Card(_)) => { - let payment_token = helpers::store_payment_method_data_in_vault( - state, - payment_attempt, - payment_intent, - enums::PaymentMethod::Card, - pm, - merchant_key_store, - ) - .await?; - - Ok((pm_opt.to_owned(), payment_token)) - } - pm @ Some(api::PaymentMethodData::PayLater(_)) => Ok((pm.to_owned(), None)), - pm @ Some(api::PaymentMethodData::Crypto(_)) => Ok((pm.to_owned(), None)), - pm @ Some(api::PaymentMethodData::BankDebit(_)) => Ok((pm.to_owned(), None)), - pm @ Some(api::PaymentMethodData::Upi(_)) => Ok((pm.to_owned(), None)), - pm @ Some(api::PaymentMethodData::Voucher(_)) => Ok((pm.to_owned(), None)), - pm @ Some(api::PaymentMethodData::Reward) => Ok((pm.to_owned(), None)), - pm @ Some(api::PaymentMethodData::CardRedirect(_)) => Ok((pm.to_owned(), None)), - pm @ Some(api::PaymentMethodData::GiftCard(_)) => Ok((pm.to_owned(), None)), - pm_opt @ Some(pm @ api::PaymentMethodData::BankTransfer(_)) => { - let payment_token = helpers::store_payment_method_data_in_vault( - state, - payment_attempt, - payment_intent, - enums::PaymentMethod::BankTransfer, - pm, - merchant_key_store, - ) - .await?; - - Ok((pm_opt.to_owned(), payment_token)) - } - pm_opt @ Some(pm @ api::PaymentMethodData::Wallet(_)) => { - let payment_token = helpers::store_payment_method_data_in_vault( - state, - payment_attempt, - payment_intent, - enums::PaymentMethod::Wallet, - pm, - merchant_key_store, - ) - .await?; - - Ok((pm_opt.to_owned(), payment_token)) - } - pm_opt @ Some(pm @ api::PaymentMethodData::BankRedirect(_)) => { - let payment_token = helpers::store_payment_method_data_in_vault( - state, - payment_attempt, - payment_intent, - enums::PaymentMethod::BankRedirect, - pm, - merchant_key_store, - ) - .await?; - - Ok((pm_opt.to_owned(), payment_token)) - } - _ => Ok((None, None)), + Ok((pm_opt.to_owned(), payment_token)) } - } + pm @ Some(api::PaymentMethodData::PayLater(_)) => Ok((pm.to_owned(), None)), + pm @ Some(api::PaymentMethodData::Crypto(_)) => Ok((pm.to_owned(), None)), + pm @ Some(api::PaymentMethodData::BankDebit(_)) => Ok((pm.to_owned(), None)), + pm @ Some(api::PaymentMethodData::Upi(_)) => Ok((pm.to_owned(), None)), + pm @ Some(api::PaymentMethodData::Voucher(_)) => Ok((pm.to_owned(), None)), + pm @ Some(api::PaymentMethodData::Reward) => Ok((pm.to_owned(), None)), + pm @ Some(api::PaymentMethodData::CardRedirect(_)) => Ok((pm.to_owned(), None)), + pm @ Some(api::PaymentMethodData::GiftCard(_)) => Ok((pm.to_owned(), None)), + pm_opt @ Some(pm @ api::PaymentMethodData::BankTransfer(_)) => { + let payment_token = helpers::store_payment_method_data_in_vault( + state, + payment_attempt, + payment_intent, + enums::PaymentMethod::BankTransfer, + pm, + merchant_key_store, + ) + .await?; - async fn retrieve_payment_method_with_token( - state: &AppState, - merchant_key_store: &domain::MerchantKeyStore, - token_data: &storage::PaymentTokenData, - payment_intent: &PaymentIntent, - card_token_data: Option<&CardToken>, - customer: &Option, - storage_scheme: common_enums::enums::MerchantStorageScheme, - ) -> RouterResult { - let token = match token_data { - storage::PaymentTokenData::TemporaryGeneric(generic_token) => { - helpers::retrieve_payment_method_with_temporary_token( - state, - &generic_token.token, - payment_intent, - merchant_key_store, - card_token_data, - ) - .await? - .map( - |(payment_method_data, payment_method)| storage::PaymentMethodDataWithId { - payment_method_data: Some(payment_method_data), - payment_method: Some(payment_method), - payment_method_id: None, - }, - ) - .unwrap_or_default() - } + Ok((pm_opt.to_owned(), payment_token)) + } + pm_opt @ Some(pm @ api::PaymentMethodData::Wallet(_)) => { + let payment_token = helpers::store_payment_method_data_in_vault( + state, + payment_attempt, + payment_intent, + enums::PaymentMethod::Wallet, + pm, + merchant_key_store, + ) + .await?; - storage::PaymentTokenData::Temporary(generic_token) => { - helpers::retrieve_payment_method_with_temporary_token( - state, - &generic_token.token, - payment_intent, - merchant_key_store, - card_token_data, - ) - .await? - .map( - |(payment_method_data, payment_method)| storage::PaymentMethodDataWithId { - payment_method_data: Some(payment_method_data), - payment_method: Some(payment_method), - payment_method_id: None, - }, - ) - .unwrap_or_default() - } + Ok((pm_opt.to_owned(), payment_token)) + } + pm_opt @ Some(pm @ api::PaymentMethodData::BankRedirect(_)) => { + let payment_token = helpers::store_payment_method_data_in_vault( + state, + payment_attempt, + payment_intent, + enums::PaymentMethod::BankRedirect, + pm, + merchant_key_store, + ) + .await?; - storage::PaymentTokenData::Permanent(card_token) => { - helpers::retrieve_card_with_permanent_token( - state, - card_token.locker_id.as_ref().unwrap_or(&card_token.token), - card_token - .payment_method_id - .as_ref() - .unwrap_or(&card_token.token), - payment_intent, - card_token_data, - merchant_key_store, - storage_scheme, - ) - .await - .map(|card| Some((card, enums::PaymentMethod::Card)))? - .map( - |(payment_method_data, payment_method)| storage::PaymentMethodDataWithId { - payment_method_data: Some(payment_method_data), - payment_method: Some(payment_method), - payment_method_id: Some( - card_token - .payment_method_id - .as_ref() - .unwrap_or(&card_token.token) - .to_string(), - ), - }, - ) - .unwrap_or_default() - } - - storage::PaymentTokenData::PermanentCard(card_token) => { - helpers::retrieve_card_with_permanent_token( - state, - card_token.locker_id.as_ref().unwrap_or(&card_token.token), - card_token - .payment_method_id - .as_ref() - .unwrap_or(&card_token.token), - payment_intent, - card_token_data, - merchant_key_store, - storage_scheme, - ) - .await - .map(|card| Some((card, enums::PaymentMethod::Card)))? - .map( - |(payment_method_data, payment_method)| storage::PaymentMethodDataWithId { - payment_method_data: Some(payment_method_data), - payment_method: Some(payment_method), - payment_method_id: Some( - card_token - .payment_method_id - .as_ref() - .unwrap_or(&card_token.token) - .to_string(), - ), - }, - ) - .unwrap_or_default() - } - - storage::PaymentTokenData::AuthBankDebit(auth_token) => { - core_pm_auth::retrieve_payment_method_from_auth_service( - state, - merchant_key_store, - auth_token, - payment_intent, - customer, - ) - .await? - .map( - |(payment_method_data, payment_method)| storage::PaymentMethodDataWithId { - payment_method_data: Some(payment_method_data), - payment_method: Some(payment_method), - payment_method_id: None, - }, - ) - .unwrap_or_default() - } - - storage::PaymentTokenData::WalletToken(_) => storage::PaymentMethodDataWithId { - payment_method: None, - payment_method_data: None, - payment_method_id: None, - }, - }; - Ok(token) + Ok((pm_opt.to_owned(), payment_token)) + } + _ => Ok((None, None)), } } + +#[instrument(skip_all)] +pub async fn retrieve_payment_method_with_token( + state: &AppState, + merchant_key_store: &domain::MerchantKeyStore, + token_data: &storage::PaymentTokenData, + payment_intent: &PaymentIntent, + card_token_data: Option<&CardToken>, + customer: &Option, + storage_scheme: common_enums::enums::MerchantStorageScheme, +) -> RouterResult { + let token = match token_data { + storage::PaymentTokenData::TemporaryGeneric(generic_token) => { + helpers::retrieve_payment_method_with_temporary_token( + state, + &generic_token.token, + payment_intent, + merchant_key_store, + card_token_data, + ) + .await? + .map( + |(payment_method_data, payment_method)| storage::PaymentMethodDataWithId { + payment_method_data: Some(payment_method_data), + payment_method: Some(payment_method), + payment_method_id: None, + }, + ) + .unwrap_or_default() + } + + storage::PaymentTokenData::Temporary(generic_token) => { + helpers::retrieve_payment_method_with_temporary_token( + state, + &generic_token.token, + payment_intent, + merchant_key_store, + card_token_data, + ) + .await? + .map( + |(payment_method_data, payment_method)| storage::PaymentMethodDataWithId { + payment_method_data: Some(payment_method_data), + payment_method: Some(payment_method), + payment_method_id: None, + }, + ) + .unwrap_or_default() + } + + storage::PaymentTokenData::Permanent(card_token) => { + helpers::retrieve_card_with_permanent_token( + state, + card_token.locker_id.as_ref().unwrap_or(&card_token.token), + card_token + .payment_method_id + .as_ref() + .unwrap_or(&card_token.token), + payment_intent, + card_token_data, + merchant_key_store, + storage_scheme, + ) + .await + .map(|card| Some((card, enums::PaymentMethod::Card)))? + .map( + |(payment_method_data, payment_method)| storage::PaymentMethodDataWithId { + payment_method_data: Some(payment_method_data), + payment_method: Some(payment_method), + payment_method_id: Some( + card_token + .payment_method_id + .as_ref() + .unwrap_or(&card_token.token) + .to_string(), + ), + }, + ) + .unwrap_or_default() + } + + storage::PaymentTokenData::PermanentCard(card_token) => { + helpers::retrieve_card_with_permanent_token( + state, + card_token.locker_id.as_ref().unwrap_or(&card_token.token), + card_token + .payment_method_id + .as_ref() + .unwrap_or(&card_token.token), + payment_intent, + card_token_data, + merchant_key_store, + storage_scheme, + ) + .await + .map(|card| Some((card, enums::PaymentMethod::Card)))? + .map( + |(payment_method_data, payment_method)| storage::PaymentMethodDataWithId { + payment_method_data: Some(payment_method_data), + payment_method: Some(payment_method), + payment_method_id: Some( + card_token + .payment_method_id + .as_ref() + .unwrap_or(&card_token.token) + .to_string(), + ), + }, + ) + .unwrap_or_default() + } + + storage::PaymentTokenData::AuthBankDebit(auth_token) => { + core_pm_auth::retrieve_payment_method_from_auth_service( + state, + merchant_key_store, + auth_token, + payment_intent, + customer, + ) + .await? + .map( + |(payment_method_data, payment_method)| storage::PaymentMethodDataWithId { + payment_method_data: Some(payment_method_data), + payment_method: Some(payment_method), + payment_method_id: None, + }, + ) + .unwrap_or_default() + } + + storage::PaymentTokenData::WalletToken(_) => storage::PaymentMethodDataWithId { + payment_method: None, + payment_method_data: None, + payment_method_id: None, + }, + }; + Ok(token) +} diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index 578b8d8030..46eea17ba2 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -69,7 +69,6 @@ use crate::{ core::{ authentication as authentication_core, errors::{self, CustomResult, RouterResponse, RouterResult}, - payment_methods::PaymentMethodRetrieve, utils, }, db::StorageInterface, @@ -93,7 +92,7 @@ use crate::{ #[allow(clippy::too_many_arguments, clippy::type_complexity)] #[instrument(skip_all, fields(payment_id, merchant_id))] -pub async fn payments_operation_core( +pub async fn payments_operation_core( state: &AppState, req_state: ReqState, merchant_account: domain::MerchantAccount, @@ -114,7 +113,7 @@ pub async fn payments_operation_core( where F: Send + Clone + Sync, Req: Authenticate + Clone, - Op: Operation + Send + Sync, + Op: Operation + Send + Sync, // To create connector flow specific interface data PaymentData: ConstructFlowSpecificData, @@ -125,11 +124,10 @@ where services::api::ConnectorIntegration, // To perform router related operation for PaymentResponse - PaymentResponse: Operation, + PaymentResponse: Operation, FData: Send + Sync + Clone, - Ctx: PaymentMethodRetrieve, { - let operation: BoxedOperation<'_, F, Req, Ctx> = Box::new(operation); + let operation: BoxedOperation<'_, F, Req> = Box::new(operation); tracing::Span::current().record("merchant_id", merchant_account.merchant_id.as_str()); let (operation, validate_result) = operation @@ -734,7 +732,7 @@ where } } #[allow(clippy::too_many_arguments)] -pub async fn payments_core( +pub async fn payments_core( state: AppState, req_state: ReqState, merchant_account: domain::MerchantAccount, @@ -749,20 +747,19 @@ pub async fn payments_core( where F: Send + Clone + Sync, FData: Send + Sync + Clone, - Op: Operation + Send + Sync + Clone, + Op: Operation + Send + Sync + Clone, Req: Debug + Authenticate + Clone, Res: transformers::ToResponse, Op>, // To create connector flow specific interface data PaymentData: ConstructFlowSpecificData, router_types::RouterData: Feature, - Ctx: PaymentMethodRetrieve, // To construct connector flow specific api dyn api::Connector: services::api::ConnectorIntegration, // To perform router related operation for PaymentResponse - PaymentResponse: Operation, + PaymentResponse: Operation, { let eligible_routable_connectors = eligible_connectors.map(|connectors| { connectors @@ -771,7 +768,7 @@ where .collect() }); let (payment_data, _req, customer, connector_http_status_code, external_latency) = - payments_operation_core::<_, _, _, _, Ctx>( + payments_operation_core::<_, _, _, _>( &state, req_state, merchant_account, @@ -814,7 +811,7 @@ pub struct PaymentsRedirectResponseData { } #[async_trait::async_trait] -pub trait PaymentRedirectFlow: Sync { +pub trait PaymentRedirectFlow: Sync { // Associated type for call_payment_flow response type PaymentFlowResponse; @@ -912,7 +909,7 @@ pub trait PaymentRedirectFlow: Sync { pub struct PaymentRedirectCompleteAuthorize; #[async_trait::async_trait] -impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize { +impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize { type PaymentFlowResponse = router_types::RedirectPaymentFlowResponse; #[allow(clippy::too_many_arguments)] @@ -944,7 +941,6 @@ impl PaymentRedirectFlow for PaymentRedirectCom _, _, _, - Ctx, >( state.clone(), req_state, @@ -1043,7 +1039,7 @@ impl PaymentRedirectFlow for PaymentRedirectCom pub struct PaymentRedirectSync; #[async_trait::async_trait] -impl PaymentRedirectFlow for PaymentRedirectSync { +impl PaymentRedirectFlow for PaymentRedirectSync { type PaymentFlowResponse = router_types::RedirectPaymentFlowResponse; #[allow(clippy::too_many_arguments)] @@ -1074,14 +1070,7 @@ impl PaymentRedirectFlow for PaymentRedirectSyn expand_attempts: None, expand_captures: None, }; - let response = Box::pin(payments_core::< - api::PSync, - api::PaymentsResponse, - _, - _, - _, - Ctx, - >( + let response = Box::pin(payments_core::( state.clone(), req_state, merchant_account, @@ -1141,7 +1130,7 @@ impl PaymentRedirectFlow for PaymentRedirectSyn pub struct PaymentAuthenticateCompleteAuthorize; #[async_trait::async_trait] -impl PaymentRedirectFlow for PaymentAuthenticateCompleteAuthorize { +impl PaymentRedirectFlow for PaymentAuthenticateCompleteAuthorize { type PaymentFlowResponse = router_types::AuthenticatePaymentFlowResponse; #[allow(clippy::too_many_arguments)] @@ -1235,7 +1224,6 @@ impl PaymentRedirectFlow for PaymentAuthenticat _, _, _, - Ctx, >( state.clone(), req_state, @@ -1266,14 +1254,7 @@ impl PaymentRedirectFlow for PaymentAuthenticat expand_attempts: None, expand_captures: None, }; - Box::pin(payments_core::< - api::PSync, - api::PaymentsResponse, - _, - _, - _, - Ctx, - >( + Box::pin(payments_core::( state.clone(), req_state, merchant_account.clone(), @@ -1386,13 +1367,13 @@ impl PaymentRedirectFlow for PaymentAuthenticat #[allow(clippy::too_many_arguments)] #[instrument(skip_all)] -pub async fn call_connector_service( +pub async fn call_connector_service( state: &AppState, req_state: ReqState, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, connector: api::ConnectorData, - operation: &BoxedOperation<'_, F, ApiRequest, Ctx>, + operation: &BoxedOperation<'_, F, ApiRequest>, payment_data: &mut PaymentData, customer: &Option, call_connector_action: CallConnectorAction, @@ -1409,8 +1390,6 @@ where PaymentData: ConstructFlowSpecificData, router_types::RouterData: Feature + Send, - Ctx: PaymentMethodRetrieve, - // To construct connector flow specific api dyn api::Connector: services::api::ConnectorIntegration, @@ -1611,15 +1590,14 @@ where router_data_res } -async fn blocklist_guard( +async fn blocklist_guard( state: &AppState, merchant_account: &domain::MerchantAccount, - operation: &BoxedOperation<'_, F, ApiRequest, Ctx>, + operation: &BoxedOperation<'_, F, ApiRequest>, payment_data: &mut PaymentData, ) -> CustomResult where F: Send + Clone + Sync, - Ctx: PaymentMethodRetrieve, { let merchant_id = &payment_data.payment_attempt.merchant_id; let blocklist_enabled_key = format!("guard_blocklist_for_{merchant_id}"); @@ -1651,7 +1629,7 @@ where } #[allow(clippy::too_many_arguments)] -pub async fn call_multiple_connectors_service( +pub async fn call_multiple_connectors_service( state: &AppState, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, @@ -1672,10 +1650,9 @@ where // To construct connector flow specific api dyn api::Connector: services::api::ConnectorIntegration, - Ctx: PaymentMethodRetrieve, // To perform router related operation for PaymentResponse - PaymentResponse: Operation, + PaymentResponse: Operation, { let call_connectors_start_time = Instant::now(); let mut join_handlers = Vec::with_capacity(connectors.len()); @@ -1869,12 +1846,12 @@ where } } -async fn complete_preprocessing_steps_if_required( +async fn complete_preprocessing_steps_if_required( state: &AppState, connector: &api::ConnectorData, payment_data: &PaymentData, mut router_data: router_types::RouterData, - operation: &BoxedOperation<'_, F, Q, Ctx>, + operation: &BoxedOperation<'_, F, Q>, should_continue_payment: bool, ) -> RouterResult<( router_types::RouterData, @@ -2234,9 +2211,9 @@ pub enum TokenizationAction { } #[allow(clippy::too_many_arguments)] -pub async fn get_connector_tokenization_action_when_confirm_true( +pub async fn get_connector_tokenization_action_when_confirm_true( state: &AppState, - operation: &BoxedOperation<'_, F, Req, Ctx>, + operation: &BoxedOperation<'_, F, Req>, payment_data: &mut PaymentData, validate_result: &operations::ValidateResult<'_>, merchant_connector_account: &helpers::MerchantConnectorAccountType, @@ -2245,7 +2222,6 @@ pub async fn get_connector_tokenization_action_when_confirm_true( ) -> RouterResult<(PaymentData, TokenizationAction)> where F: Send + Clone, - Ctx: PaymentMethodRetrieve, { let connector = payment_data.payment_attempt.connector.to_owned(); @@ -2359,9 +2335,9 @@ where Ok(payment_data_and_tokenization_action) } -pub async fn tokenize_in_router_when_confirm_false_or_external_authentication( +pub async fn tokenize_in_router_when_confirm_false_or_external_authentication( state: &AppState, - operation: &BoxedOperation<'_, F, Req, Ctx>, + operation: &BoxedOperation<'_, F, Req>, payment_data: &mut PaymentData, validate_result: &operations::ValidateResult<'_>, merchant_key_store: &domain::MerchantKeyStore, @@ -2369,7 +2345,6 @@ pub async fn tokenize_in_router_when_confirm_false_or_external_authentication RouterResult> where F: Send + Clone, - Ctx: PaymentMethodRetrieve, { // On confirm is false and only router related let is_external_authentication_requested = payment_data @@ -2612,16 +2587,15 @@ impl CustomerDetailsExt for CustomerDetails { } } -pub fn if_not_create_change_operation<'a, Op, F, Ctx>( +pub fn if_not_create_change_operation<'a, Op, F>( status: storage_enums::IntentStatus, confirm: Option, current: &'a Op, -) -> BoxedOperation<'_, F, api::PaymentsRequest, Ctx> +) -> BoxedOperation<'_, F, api::PaymentsRequest> where F: Send + Clone, - Op: Operation + Send + Sync, - &'a Op: Operation, - Ctx: PaymentMethodRetrieve, + Op: Operation + Send + Sync, + &'a Op: Operation, { if confirm.unwrap_or(false) { Box::new(PaymentConfirm) @@ -2635,16 +2609,15 @@ where } } -pub fn is_confirm<'a, F: Clone + Send, R, Op, Ctx>( +pub fn is_confirm<'a, F: Clone + Send, R, Op>( operation: &'a Op, confirm: Option, -) -> BoxedOperation<'_, F, R, Ctx> +) -> BoxedOperation<'_, F, R> where - PaymentConfirm: Operation, - &'a PaymentConfirm: Operation, - Op: Operation + Send + Sync, - &'a Op: Operation, - Ctx: PaymentMethodRetrieve, + PaymentConfirm: Operation, + &'a PaymentConfirm: Operation, + Op: Operation + Send + Sync, + &'a Op: Operation, { if confirm.unwrap_or(false) { Box::new(&PaymentConfirm) @@ -3028,8 +3001,8 @@ where } #[allow(clippy::too_many_arguments)] -pub async fn get_connector_choice( - operation: &BoxedOperation<'_, F, Req, Ctx>, +pub async fn get_connector_choice( + operation: &BoxedOperation<'_, F, Req>, state: &AppState, req: &Req, merchant_account: &domain::MerchantAccount, @@ -3041,7 +3014,6 @@ pub async fn get_connector_choice( ) -> RouterResult> where F: Send + Clone, - Ctx: PaymentMethodRetrieve, { let connector_choice = operation .to_domain()? diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index 2d20ae6b87..b4b1b09c3f 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -40,12 +40,12 @@ use crate::{ authentication, errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers::MandateGenericData, - payment_methods::{cards, vault, PaymentMethodRetrieve}, + payment_methods::{self, cards, vault}, payments, pm_auth::retrieve_payment_method_from_auth_service, }, db::StorageInterface, - routes::{metrics, payment_methods, AppState}, + routes::{metrics, payment_methods as payment_methods_handler, AppState}, services, types::{ self as core_types, @@ -1234,11 +1234,10 @@ where } } -pub fn response_operation<'a, F, R, Ctx>() -> BoxedOperation<'a, F, R, Ctx> +pub fn response_operation<'a, F, R>() -> BoxedOperation<'a, F, R> where F: Send + Clone, - Ctx: PaymentMethodRetrieve, - PaymentResponse: Operation, + PaymentResponse: Operation, { Box::new(PaymentResponse) } @@ -1468,15 +1467,15 @@ pub async fn get_connector_default( #[instrument(skip_all)] #[allow(clippy::type_complexity)] -pub async fn create_customer_if_not_exist<'a, F: Clone, R, Ctx>( - operation: BoxedOperation<'a, F, R, Ctx>, +pub async fn create_customer_if_not_exist<'a, F: Clone, R>( + operation: BoxedOperation<'a, F, R>, db: &dyn StorageInterface, payment_data: &mut PaymentData, req: Option, merchant_id: &str, key_store: &domain::MerchantKeyStore, storage_scheme: common_enums::enums::MerchantStorageScheme, -) -> CustomResult<(BoxedOperation<'a, F, R, Ctx>, Option), errors::StorageError> { +) -> CustomResult<(BoxedOperation<'a, F, R>, Option), errors::StorageError> { let request_customer_details = req .get_required_value("customer") .change_context(errors::StorageError::ValueNotFound("customer".to_owned()))?; @@ -1884,15 +1883,15 @@ pub async fn retrieve_payment_token_data( Ok(token_data) } -pub async fn make_pm_data<'a, F: Clone, R, Ctx: PaymentMethodRetrieve>( - operation: BoxedOperation<'a, F, R, Ctx>, +pub async fn make_pm_data<'a, F: Clone, R>( + operation: BoxedOperation<'a, F, R>, state: &'a AppState, payment_data: &mut PaymentData, merchant_key_store: &domain::MerchantKeyStore, customer: &Option, storage_scheme: common_enums::enums::MerchantStorageScheme, ) -> RouterResult<( - BoxedOperation<'a, F, R, Ctx>, + BoxedOperation<'a, F, R>, Option, Option, )> { @@ -1935,7 +1934,7 @@ pub async fn make_pm_data<'a, F: Clone, R, Ctx: PaymentMethodRetrieve>( // TODO: Handle case where payment method and token both are present in request properly. let (payment_method, pm_id) = match (request, payment_data.token_data.as_ref()) { (_, Some(hyperswitch_token)) => { - let pm_data = Ctx::retrieve_payment_method_with_token( + let pm_data = payment_methods::retrieve_payment_method_with_token( state, merchant_key_store, hyperswitch_token, @@ -1963,7 +1962,7 @@ pub async fn make_pm_data<'a, F: Clone, R, Ctx: PaymentMethodRetrieve>( } (Some(_), _) => { - let (payment_method_data, payment_token) = Ctx::retrieve_payment_method( + let (payment_method_data, payment_token) = payment_methods::retrieve_payment_method( request, state, &payment_data.payment_intent, @@ -2001,7 +2000,7 @@ pub async fn store_in_vault_and_generate_ppmt( .await?; let parent_payment_method_token = generate_id(consts::ID_LENGTH, "token"); let key_for_hyperswitch_token = payment_attempt.payment_method.map(|payment_method| { - payment_methods::ParentPaymentMethodToken::create_key_for_token(( + payment_methods_handler::ParentPaymentMethodToken::create_key_for_token(( &parent_payment_method_token, payment_method, )) diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rs index da9a210869..35fc2897ea 100644 --- a/crates/router/src/core/payments/operations.rs +++ b/crates/router/src/core/payments/operations.rs @@ -27,10 +27,7 @@ pub use self::{ }; use super::{helpers, CustomerDetails, PaymentData}; use crate::{ - core::{ - errors::{self, CustomResult, RouterResult}, - payment_methods::PaymentMethodRetrieve, - }, + core::errors::{self, CustomResult, RouterResult}, db::StorageInterface, routes::{app::ReqState, AppState}, services, @@ -43,26 +40,26 @@ use crate::{ }, }; -pub type BoxedOperation<'a, F, T, Ctx> = Box + Send + Sync + 'a>; +pub type BoxedOperation<'a, F, T> = Box + Send + Sync + 'a>; -pub trait Operation: Send + std::fmt::Debug { - fn to_validate_request(&self) -> RouterResult<&(dyn ValidateRequest + Send + Sync)> { +pub trait Operation: Send + std::fmt::Debug { + fn to_validate_request(&self) -> RouterResult<&(dyn ValidateRequest + Send + Sync)> { Err(report!(errors::ApiErrorResponse::InternalServerError)) .attach_printable_lazy(|| format!("validate request interface not found for {self:?}")) } fn to_get_tracker( &self, - ) -> RouterResult<&(dyn GetTracker, T, Ctx> + Send + Sync)> { + ) -> RouterResult<&(dyn GetTracker, T> + Send + Sync)> { Err(report!(errors::ApiErrorResponse::InternalServerError)) .attach_printable_lazy(|| format!("get tracker interface not found for {self:?}")) } - fn to_domain(&self) -> RouterResult<&dyn Domain> { + fn to_domain(&self) -> RouterResult<&dyn Domain> { Err(report!(errors::ApiErrorResponse::InternalServerError)) .attach_printable_lazy(|| format!("domain interface not found for {self:?}")) } fn to_update_tracker( &self, - ) -> RouterResult<&(dyn UpdateTracker, T, Ctx> + Send + Sync)> { + ) -> RouterResult<&(dyn UpdateTracker, T> + Send + Sync)> { Err(report!(errors::ApiErrorResponse::InternalServerError)) .attach_printable_lazy(|| format!("update tracker interface not found for {self:?}")) } @@ -84,16 +81,16 @@ pub struct ValidateResult<'a> { } #[allow(clippy::type_complexity)] -pub trait ValidateRequest { +pub trait ValidateRequest { fn validate_request<'a, 'b>( &'b self, request: &R, merchant_account: &'a domain::MerchantAccount, - ) -> RouterResult<(BoxedOperation<'b, F, R, Ctx>, ValidateResult<'a>)>; + ) -> RouterResult<(BoxedOperation<'b, F, R>, ValidateResult<'a>)>; } -pub struct GetTrackerResponse<'a, F: Clone, R, Ctx> { - pub operation: BoxedOperation<'a, F, R, Ctx>, +pub struct GetTrackerResponse<'a, F: Clone, R> { + pub operation: BoxedOperation<'a, F, R>, pub customer_details: Option, pub payment_data: PaymentData, pub business_profile: storage::business_profile::BusinessProfile, @@ -101,7 +98,7 @@ pub struct GetTrackerResponse<'a, F: Clone, R, Ctx> { } #[async_trait] -pub trait GetTracker: Send { +pub trait GetTracker: Send { #[allow(clippy::too_many_arguments)] async fn get_trackers<'a>( &'a self, @@ -112,11 +109,11 @@ pub trait GetTracker: Send { mechant_key_store: &domain::MerchantKeyStore, auth_flow: services::AuthFlow, payment_confirm_source: Option, - ) -> RouterResult>; + ) -> RouterResult>; } #[async_trait] -pub trait Domain: Send + Sync { +pub trait Domain: Send + Sync { /// This will fetch customer details, (this operation is flow specific) async fn get_or_create_customer_details<'a>( &'a self, @@ -125,7 +122,7 @@ pub trait Domain: Send + Sync { request: Option, merchant_key_store: &domain::MerchantKeyStore, storage_scheme: enums::MerchantStorageScheme, - ) -> CustomResult<(BoxedOperation<'a, F, R, Ctx>, Option), errors::StorageError>; + ) -> CustomResult<(BoxedOperation<'a, F, R>, Option), errors::StorageError>; #[allow(clippy::too_many_arguments)] async fn make_pm_data<'a>( @@ -136,7 +133,7 @@ pub trait Domain: Send + Sync { merchant_key_store: &domain::MerchantKeyStore, customer: &Option, ) -> RouterResult<( - BoxedOperation<'a, F, R, Ctx>, + BoxedOperation<'a, F, R>, Option, Option, )>; @@ -204,7 +201,7 @@ pub trait Domain: Send + Sync { #[async_trait] #[allow(clippy::too_many_arguments)] -pub trait UpdateTracker: Send { +pub trait UpdateTracker: Send { async fn update_trackers<'b>( &'b self, db: &'b AppState, @@ -216,7 +213,7 @@ pub trait UpdateTracker: Send { mechant_key_store: &domain::MerchantKeyStore, frm_suggestion: Option, header_payload: api::HeaderPayload, - ) -> RouterResult<(BoxedOperation<'b, F, Req, Ctx>, D)> + ) -> RouterResult<(BoxedOperation<'b, F, Req>, D)> where F: 'b + Send; } @@ -251,13 +248,10 @@ pub trait PostUpdateTracker: Send { } #[async_trait] -impl< - F: Clone + Send, - Ctx: PaymentMethodRetrieve, - Op: Send + Sync + Operation, - > Domain for Op +impl> + Domain for Op where - for<'a> &'a Op: Operation, + for<'a> &'a Op: Operation, { #[instrument(skip_all)] async fn get_or_create_customer_details<'a>( @@ -269,7 +263,7 @@ where storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult< ( - BoxedOperation<'a, F, api::PaymentsRetrieveRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsRetrieveRequest>, Option, ), errors::StorageError, @@ -308,7 +302,7 @@ where merchant_key_store: &domain::MerchantKeyStore, customer: &Option, ) -> RouterResult<( - BoxedOperation<'a, F, api::PaymentsRetrieveRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsRetrieveRequest>, Option, Option, )> { @@ -335,13 +329,10 @@ where } #[async_trait] -impl< - F: Clone + Send, - Ctx: PaymentMethodRetrieve, - Op: Send + Sync + Operation, - > Domain for Op +impl> + Domain for Op where - for<'a> &'a Op: Operation, + for<'a> &'a Op: Operation, { #[instrument(skip_all)] async fn get_or_create_customer_details<'a>( @@ -353,7 +344,7 @@ where storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult< ( - BoxedOperation<'a, F, api::PaymentsCaptureRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsCaptureRequest>, Option, ), errors::StorageError, @@ -380,7 +371,7 @@ where _merchant_key_store: &domain::MerchantKeyStore, _customer: &Option, ) -> RouterResult<( - BoxedOperation<'a, F, api::PaymentsCaptureRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsCaptureRequest>, Option, Option, )> { @@ -410,13 +401,10 @@ where } #[async_trait] -impl< - F: Clone + Send, - Ctx: PaymentMethodRetrieve, - Op: Send + Sync + Operation, - > Domain for Op +impl> + Domain for Op where - for<'a> &'a Op: Operation, + for<'a> &'a Op: Operation, { #[instrument(skip_all)] async fn get_or_create_customer_details<'a>( @@ -428,7 +416,7 @@ where storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult< ( - BoxedOperation<'a, F, api::PaymentsCancelRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsCancelRequest>, Option, ), errors::StorageError, @@ -456,7 +444,7 @@ where _merchant_key_store: &domain::MerchantKeyStore, _customer: &Option, ) -> RouterResult<( - BoxedOperation<'a, F, api::PaymentsCancelRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsCancelRequest>, Option, Option, )> { @@ -486,13 +474,10 @@ where } #[async_trait] -impl< - F: Clone + Send, - Ctx: PaymentMethodRetrieve, - Op: Send + Sync + Operation, - > Domain for Op +impl> + Domain for Op where - for<'a> &'a Op: Operation, + for<'a> &'a Op: Operation, { #[instrument(skip_all)] async fn get_or_create_customer_details<'a>( @@ -504,7 +489,7 @@ where _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult< ( - BoxedOperation<'a, F, api::PaymentsRejectRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsRejectRequest>, Option, ), errors::StorageError, @@ -521,7 +506,7 @@ where _merchant_key_store: &domain::MerchantKeyStore, _customer: &Option, ) -> RouterResult<( - BoxedOperation<'a, F, api::PaymentsRejectRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsRejectRequest>, Option, Option, )> { diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rs index bc60d8a358..1a92ab0c52 100644 --- a/crates/router/src/core/payments/operations/payment_approve.rs +++ b/crates/router/src/core/payments/operations/payment_approve.rs @@ -10,7 +10,6 @@ use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, Valida use crate::{ core::{ errors::{self, RouterResult, StorageErrorExt}, - payment_methods::PaymentMethodRetrieve, payments::{helpers, operations, PaymentData}, }, routes::{app::ReqState, AppState}, @@ -29,8 +28,8 @@ use crate::{ pub struct PaymentApprove; #[async_trait] -impl - GetTracker, api::PaymentsCaptureRequest, Ctx> for PaymentApprove +impl GetTracker, api::PaymentsCaptureRequest> + for PaymentApprove { #[instrument(skip_all)] async fn get_trackers<'a>( @@ -42,7 +41,7 @@ impl key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, _payment_confirm_source: Option, - ) -> RouterResult> { + ) -> RouterResult> { let db = &*state.store; let merchant_id = &merchant_account.merchant_id; let storage_scheme = merchant_account.storage_scheme; @@ -192,9 +191,7 @@ impl } #[async_trait] -impl - UpdateTracker, api::PaymentsCaptureRequest, Ctx> for PaymentApprove -{ +impl UpdateTracker, api::PaymentsCaptureRequest> for PaymentApprove { #[instrument(skip_all)] async fn update_trackers<'b>( &'b self, @@ -208,7 +205,7 @@ impl frm_suggestion: Option, _header_payload: api::HeaderPayload, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsCaptureRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsCaptureRequest>, PaymentData, )> where @@ -248,16 +245,14 @@ impl } } -impl - ValidateRequest for PaymentApprove -{ +impl ValidateRequest for PaymentApprove { #[instrument(skip_all)] fn validate_request<'a, 'b>( &'b self, request: &api::PaymentsCaptureRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsCaptureRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsCaptureRequest>, operations::ValidateResult<'a>, )> { let request_merchant_id = request.merchant_id.as_deref(); diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rs index 2d05fa2152..73fecd2025 100644 --- a/crates/router/src/core/payments/operations/payment_cancel.rs +++ b/crates/router/src/core/payments/operations/payment_cancel.rs @@ -11,7 +11,6 @@ use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, Valida use crate::{ core::{ errors::{self, RouterResult, StorageErrorExt}, - payment_methods::PaymentMethodRetrieve, payments::{helpers, operations, PaymentData}, }, events::audit_events::{AuditEvent, AuditEventType}, @@ -31,9 +30,7 @@ use crate::{ pub struct PaymentCancel; #[async_trait] -impl - GetTracker, api::PaymentsCancelRequest, Ctx> for PaymentCancel -{ +impl GetTracker, api::PaymentsCancelRequest> for PaymentCancel { #[instrument(skip_all)] async fn get_trackers<'a>( &'a self, @@ -44,7 +41,7 @@ impl key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, _payment_confirm_source: Option, - ) -> RouterResult> { + ) -> RouterResult> { let db = &*state.store; let merchant_id = &merchant_account.merchant_id; let storage_scheme = merchant_account.storage_scheme; @@ -207,9 +204,7 @@ impl } #[async_trait] -impl - UpdateTracker, api::PaymentsCancelRequest, Ctx> for PaymentCancel -{ +impl UpdateTracker, api::PaymentsCancelRequest> for PaymentCancel { #[instrument(skip_all)] async fn update_trackers<'b>( &'b self, @@ -223,7 +218,7 @@ impl _frm_suggestion: Option, _header_payload: api::HeaderPayload, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsCancelRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsCancelRequest>, PaymentData, )> where @@ -277,16 +272,14 @@ impl } } -impl - ValidateRequest for PaymentCancel -{ +impl ValidateRequest for PaymentCancel { #[instrument(skip_all)] fn validate_request<'a, 'b>( &'b self, request: &api::PaymentsCancelRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsCancelRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsCancelRequest>, operations::ValidateResult<'a>, )> { Ok(( diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rs index 71549a17c2..29f9c14e54 100644 --- a/crates/router/src/core/payments/operations/payment_capture.rs +++ b/crates/router/src/core/payments/operations/payment_capture.rs @@ -10,7 +10,6 @@ use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, Valida use crate::{ core::{ errors::{self, RouterResult, StorageErrorExt}, - payment_methods::PaymentMethodRetrieve, payments::{self, helpers, operations, types::MultipleCaptureData}, }, routes::{app::ReqState, AppState}, @@ -29,8 +28,8 @@ use crate::{ pub struct PaymentCapture; #[async_trait] -impl - GetTracker, api::PaymentsCaptureRequest, Ctx> for PaymentCapture +impl GetTracker, api::PaymentsCaptureRequest> + for PaymentCapture { #[instrument(skip_all)] async fn get_trackers<'a>( @@ -42,7 +41,7 @@ impl key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, _payment_confirm_source: Option, - ) -> RouterResult> { + ) -> RouterResult> { let db = &*state.store; let merchant_id = &merchant_account.merchant_id; let storage_scheme = merchant_account.storage_scheme; @@ -248,8 +247,7 @@ impl } #[async_trait] -impl - UpdateTracker, api::PaymentsCaptureRequest, Ctx> +impl UpdateTracker, api::PaymentsCaptureRequest> for PaymentCapture { #[instrument(skip_all)] @@ -265,7 +263,7 @@ impl _frm_suggestion: Option, _header_payload: api::HeaderPayload, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsCaptureRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsCaptureRequest>, payments::PaymentData, )> where @@ -299,16 +297,14 @@ impl } } -impl - ValidateRequest for PaymentCapture -{ +impl ValidateRequest for PaymentCapture { #[instrument(skip_all)] fn validate_request<'a, 'b>( &'b self, request: &api::PaymentsCaptureRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsCaptureRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsCaptureRequest>, operations::ValidateResult<'a>, )> { Ok(( diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs index f1cb0fa92e..06627920d7 100644 --- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs +++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs @@ -11,7 +11,6 @@ use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, - payment_methods::PaymentMethodRetrieve, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, @@ -31,9 +30,7 @@ use crate::{ pub struct CompleteAuthorize; #[async_trait] -impl - GetTracker, api::PaymentsRequest, Ctx> for CompleteAuthorize -{ +impl GetTracker, api::PaymentsRequest> for CompleteAuthorize { #[instrument(skip_all)] async fn get_trackers<'a>( &'a self, @@ -44,7 +41,7 @@ impl key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, _payment_confirm_source: Option, - ) -> RouterResult> { + ) -> RouterResult> { let db = &*state.store; let merchant_id = &merchant_account.merchant_id; let storage_scheme = merchant_account.storage_scheme; @@ -332,9 +329,7 @@ impl } #[async_trait] -impl Domain - for CompleteAuthorize -{ +impl Domain for CompleteAuthorize { #[instrument(skip_all)] async fn get_or_create_customer_details<'a>( &'a self, @@ -345,7 +340,7 @@ impl Domain CustomResult< ( - BoxedOperation<'a, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsRequest>, Option, ), errors::StorageError, @@ -371,7 +366,7 @@ impl Domain, ) -> RouterResult<( - BoxedOperation<'a, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsRequest>, Option, Option, )> { @@ -423,9 +418,7 @@ impl Domain - UpdateTracker, api::PaymentsRequest, Ctx> for CompleteAuthorize -{ +impl UpdateTracker, api::PaymentsRequest> for CompleteAuthorize { #[instrument(skip_all)] async fn update_trackers<'b>( &'b self, @@ -438,10 +431,7 @@ impl _merchant_key_store: &domain::MerchantKeyStore, _frm_suggestion: Option, _header_payload: api::HeaderPayload, - ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsRequest, Ctx>, - PaymentData, - )> + ) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsRequest>, PaymentData)> where F: 'b + Send, { @@ -449,16 +439,14 @@ impl } } -impl ValidateRequest - for CompleteAuthorize -{ +impl ValidateRequest for CompleteAuthorize { #[instrument(skip_all)] fn validate_request<'a, 'b>( &'b self, request: &api::PaymentsRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsRequest>, operations::ValidateResult<'a>, )> { let payment_id = request diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs index e77ffa611e..f5ab92911e 100644 --- a/crates/router/src/core/payments/operations/payment_confirm.rs +++ b/crates/router/src/core/payments/operations/payment_confirm.rs @@ -17,7 +17,6 @@ use crate::{ blocklist::utils as blocklist_utils, errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, - payment_methods::PaymentMethodRetrieve, payments::{ self, helpers, operations, populate_surcharge_details, CustomerDetails, PaymentAddress, PaymentData, @@ -40,9 +39,7 @@ use crate::{ #[operation(operations = "all", flow = "authorize")] pub struct PaymentConfirm; #[async_trait] -impl - GetTracker, api::PaymentsRequest, Ctx> for PaymentConfirm -{ +impl GetTracker, api::PaymentsRequest> for PaymentConfirm { #[instrument(skip_all)] async fn get_trackers<'a>( &'a self, @@ -53,7 +50,7 @@ impl key_store: &domain::MerchantKeyStore, auth_flow: services::AuthFlow, payment_confirm_source: Option, - ) -> RouterResult> { + ) -> RouterResult> { let merchant_id = &merchant_account.merchant_id; let storage_scheme = merchant_account.storage_scheme; let (currency, amount); @@ -654,9 +651,7 @@ impl } #[async_trait] -impl Domain - for PaymentConfirm -{ +impl Domain for PaymentConfirm { #[instrument(skip_all)] async fn get_or_create_customer_details<'a>( &'a self, @@ -667,7 +662,7 @@ impl Domain CustomResult< ( - BoxedOperation<'a, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsRequest>, Option, ), errors::StorageError, @@ -693,7 +688,7 @@ impl Domain, ) -> RouterResult<( - BoxedOperation<'a, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsRequest>, Option, Option, )> { @@ -930,9 +925,7 @@ impl Domain - UpdateTracker, api::PaymentsRequest, Ctx> for PaymentConfirm -{ +impl UpdateTracker, api::PaymentsRequest> for PaymentConfirm { #[instrument(skip_all)] async fn update_trackers<'b>( &'b self, @@ -945,10 +938,7 @@ impl key_store: &domain::MerchantKeyStore, frm_suggestion: Option, header_payload: api::HeaderPayload, - ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsRequest, Ctx>, - PaymentData, - )> + ) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsRequest>, PaymentData)> where F: 'b + Send, { @@ -1248,16 +1238,14 @@ impl } } -impl ValidateRequest - for PaymentConfirm -{ +impl ValidateRequest for PaymentConfirm { #[instrument(skip_all)] fn validate_request<'a, 'b>( &'b self, request: &api::PaymentsRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsRequest>, operations::ValidateResult<'a>, )> { helpers::validate_customer_details_in_request(request)?; diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs index e90617f538..f8ea543823 100644 --- a/crates/router/src/core/payments/operations/payment_create.rs +++ b/crates/router/src/core/payments/operations/payment_create.rs @@ -23,7 +23,6 @@ use crate::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, payment_link, - payment_methods::PaymentMethodRetrieve, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, @@ -48,9 +47,7 @@ pub struct PaymentCreate; /// The `get_trackers` function for `PaymentsCreate` is an entrypoint for new payments /// This will create all the entities required for a new payment from the request #[async_trait] -impl - GetTracker, api::PaymentsRequest, Ctx> for PaymentCreate -{ +impl GetTracker, api::PaymentsRequest> for PaymentCreate { #[instrument(skip_all)] async fn get_trackers<'a>( &'a self, @@ -61,7 +58,7 @@ impl merchant_key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, _payment_confirm_source: Option, - ) -> RouterResult> { + ) -> RouterResult> { let db = &*state.store; let ephemeral_key = Self::get_ephemeral_key(request, state, merchant_account).await; let merchant_id = &merchant_account.merchant_id; @@ -362,7 +359,7 @@ impl .await .transpose()?; - let operation = payments::if_not_create_change_operation::<_, F, Ctx>( + let operation = payments::if_not_create_change_operation::<_, F>( payment_intent.status, request.confirm, self, @@ -467,9 +464,7 @@ impl } #[async_trait] -impl Domain - for PaymentCreate -{ +impl Domain for PaymentCreate { #[instrument(skip_all)] async fn get_or_create_customer_details<'a>( &'a self, @@ -480,7 +475,7 @@ impl Domain CustomResult< ( - BoxedOperation<'a, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsRequest>, Option, ), errors::StorageError, @@ -506,7 +501,7 @@ impl Domain, ) -> RouterResult<( - BoxedOperation<'a, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsRequest>, Option, Option, )> { @@ -555,9 +550,7 @@ impl Domain - UpdateTracker, api::PaymentsRequest, Ctx> for PaymentCreate -{ +impl UpdateTracker, api::PaymentsRequest> for PaymentCreate { #[instrument(skip_all)] async fn update_trackers<'b>( &'b self, @@ -570,10 +563,7 @@ impl _merchant_key_store: &domain::MerchantKeyStore, _frm_suggestion: Option, _header_payload: api::HeaderPayload, - ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsRequest, Ctx>, - PaymentData, - )> + ) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsRequest>, PaymentData)> where F: 'b + Send, { @@ -660,16 +650,14 @@ impl } } -impl ValidateRequest - for PaymentCreate -{ +impl ValidateRequest for PaymentCreate { #[instrument(skip_all)] fn validate_request<'a, 'b>( &'b self, request: &api::PaymentsRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsRequest>, operations::ValidateResult<'a>, )> { helpers::validate_customer_details_in_request(request)?; diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rs index 8ba627dc56..e03f3ce6cb 100644 --- a/crates/router/src/core/payments/operations/payment_reject.rs +++ b/crates/router/src/core/payments/operations/payment_reject.rs @@ -10,7 +10,6 @@ use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, Valida use crate::{ core::{ errors::{self, RouterResult, StorageErrorExt}, - payment_methods::PaymentMethodRetrieve, payments::{helpers, operations, PaymentAddress, PaymentData}, }, routes::{app::ReqState, AppState}, @@ -28,9 +27,7 @@ use crate::{ pub struct PaymentReject; #[async_trait] -impl - GetTracker, PaymentsCancelRequest, Ctx> for PaymentReject -{ +impl GetTracker, PaymentsCancelRequest> for PaymentReject { #[instrument(skip_all)] async fn get_trackers<'a>( &'a self, @@ -41,7 +38,7 @@ impl key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, _payment_confirm_source: Option, - ) -> RouterResult> { + ) -> RouterResult> { let db = &*state.store; let merchant_id = &merchant_account.merchant_id; let storage_scheme = merchant_account.storage_scheme; @@ -191,9 +188,7 @@ impl } #[async_trait] -impl - UpdateTracker, PaymentsCancelRequest, Ctx> for PaymentReject -{ +impl UpdateTracker, PaymentsCancelRequest> for PaymentReject { #[instrument(skip_all)] async fn update_trackers<'b>( &'b self, @@ -206,10 +201,7 @@ impl _mechant_key_store: &domain::MerchantKeyStore, _should_decline_transaction: Option, _header_payload: api::HeaderPayload, - ) -> RouterResult<( - BoxedOperation<'b, F, PaymentsCancelRequest, Ctx>, - PaymentData, - )> + ) -> RouterResult<(BoxedOperation<'b, F, PaymentsCancelRequest>, PaymentData)> where F: 'b + Send, { @@ -259,16 +251,14 @@ impl } } -impl ValidateRequest - for PaymentReject -{ +impl ValidateRequest for PaymentReject { #[instrument(skip_all)] fn validate_request<'a, 'b>( &'b self, request: &PaymentsCancelRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<( - BoxedOperation<'b, F, PaymentsCancelRequest, Ctx>, + BoxedOperation<'b, F, PaymentsCancelRequest>, operations::ValidateResult<'a>, )> { Ok(( diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs index d70052f731..9867d59a69 100644 --- a/crates/router/src/core/payments/operations/payment_response.rs +++ b/crates/router/src/core/payments/operations/payment_response.rs @@ -16,8 +16,7 @@ use crate::{ connector::utils::PaymentResponseRouterData, core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, - mandate, - payment_methods::{self, PaymentMethodRetrieve}, + mandate, payment_methods, payments::{ helpers::{ self as payments_helpers, diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rs index 485e25c2c9..db8b3131c5 100644 --- a/crates/router/src/core/payments/operations/payment_session.rs +++ b/crates/router/src/core/payments/operations/payment_session.rs @@ -11,7 +11,6 @@ use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, Valida use crate::{ core::{ errors::{self, RouterResult, StorageErrorExt}, - payment_methods::PaymentMethodRetrieve, payments::{self, helpers, operations, PaymentData}, }, db::StorageInterface, @@ -30,8 +29,8 @@ use crate::{ pub struct PaymentSession; #[async_trait] -impl - GetTracker, api::PaymentsSessionRequest, Ctx> for PaymentSession +impl GetTracker, api::PaymentsSessionRequest> + for PaymentSession { #[instrument(skip_all)] async fn get_trackers<'a>( @@ -43,7 +42,7 @@ impl key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, _payment_confirm_source: Option, - ) -> RouterResult> { + ) -> RouterResult> { let payment_id = payment_id .get_payment_intent_id() .change_context(errors::ApiErrorResponse::PaymentNotFound)?; @@ -216,9 +215,7 @@ impl } #[async_trait] -impl - UpdateTracker, api::PaymentsSessionRequest, Ctx> for PaymentSession -{ +impl UpdateTracker, api::PaymentsSessionRequest> for PaymentSession { #[instrument(skip_all)] async fn update_trackers<'b>( &'b self, @@ -232,7 +229,7 @@ impl _frm_suggestion: Option, _header_payload: api::HeaderPayload, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsSessionRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsSessionRequest>, PaymentData, )> where @@ -259,16 +256,14 @@ impl } } -impl - ValidateRequest for PaymentSession -{ +impl ValidateRequest for PaymentSession { #[instrument(skip_all)] fn validate_request<'a, 'b>( &'b self, request: &api::PaymentsSessionRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsSessionRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsSessionRequest>, operations::ValidateResult<'a>, )> { //paymentid is already generated and should be sent in the request @@ -287,13 +282,10 @@ impl } #[async_trait] -impl< - F: Clone + Send, - Ctx: PaymentMethodRetrieve, - Op: Send + Sync + Operation, - > Domain for Op +impl> + Domain for Op where - for<'a> &'a Op: Operation, + for<'a> &'a Op: Operation, { #[instrument(skip_all)] async fn get_or_create_customer_details<'a>( @@ -305,7 +297,7 @@ where storage_scheme: common_enums::enums::MerchantStorageScheme, ) -> errors::CustomResult< ( - BoxedOperation<'a, F, api::PaymentsSessionRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsSessionRequest>, Option, ), errors::StorageError, @@ -331,7 +323,7 @@ where _merchant_key_store: &domain::MerchantKeyStore, _customer: &Option, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsSessionRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsSessionRequest>, Option, Option, )> { diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rs index 01ab858635..cf012aa09e 100644 --- a/crates/router/src/core/payments/operations/payment_start.rs +++ b/crates/router/src/core/payments/operations/payment_start.rs @@ -10,7 +10,6 @@ use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, Valida use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, - payment_methods::PaymentMethodRetrieve, payments::{helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, }, db::StorageInterface, @@ -29,9 +28,7 @@ use crate::{ pub struct PaymentStart; #[async_trait] -impl - GetTracker, api::PaymentsStartRequest, Ctx> for PaymentStart -{ +impl GetTracker, api::PaymentsStartRequest> for PaymentStart { #[instrument(skip_all)] async fn get_trackers<'a>( &'a self, @@ -42,7 +39,7 @@ impl key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, _payment_confirm_source: Option, - ) -> RouterResult> { + ) -> RouterResult> { let (mut payment_intent, payment_attempt, currency, amount); let db = &*state.store; @@ -203,9 +200,7 @@ impl } #[async_trait] -impl - UpdateTracker, api::PaymentsStartRequest, Ctx> for PaymentStart -{ +impl UpdateTracker, api::PaymentsStartRequest> for PaymentStart { #[instrument(skip_all)] async fn update_trackers<'b>( &'b self, @@ -219,7 +214,7 @@ impl _frm_suggestion: Option, _header_payload: api::HeaderPayload, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsStartRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsStartRequest>, PaymentData, )> where @@ -229,16 +224,14 @@ impl } } -impl ValidateRequest - for PaymentStart -{ +impl ValidateRequest for PaymentStart { #[instrument(skip_all)] fn validate_request<'a, 'b>( &'b self, request: &api::PaymentsStartRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsStartRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsStartRequest>, operations::ValidateResult<'a>, )> { let request_merchant_id = Some(&request.merchant_id[..]); @@ -263,13 +256,10 @@ impl ValidateRequest, - > Domain for Op +impl> + Domain for Op where - for<'a> &'a Op: Operation, + for<'a> &'a Op: Operation, { #[instrument(skip_all)] async fn get_or_create_customer_details<'a>( @@ -281,7 +271,7 @@ where storage_scheme: common_enums::enums::MerchantStorageScheme, ) -> CustomResult< ( - BoxedOperation<'a, F, api::PaymentsStartRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsStartRequest>, Option, ), errors::StorageError, @@ -307,7 +297,7 @@ where merchant_key_store: &domain::MerchantKeyStore, customer: &Option, ) -> RouterResult<( - BoxedOperation<'a, F, api::PaymentsStartRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsStartRequest>, Option, Option, )> { diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rs index 85e7fa2bf5..4d5b87b671 100644 --- a/crates/router/src/core/payments/operations/payment_status.rs +++ b/crates/router/src/core/payments/operations/payment_status.rs @@ -11,7 +11,6 @@ use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, Valida use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, - payment_methods::PaymentMethodRetrieve, payments::{ helpers, operations, types as payment_types, CustomerDetails, PaymentAddress, PaymentData, @@ -31,39 +30,31 @@ use crate::{ #[operation(operations = "all", flow = "sync")] pub struct PaymentStatus; -impl Operation - for PaymentStatus -{ - fn to_domain(&self) -> RouterResult<&dyn Domain> { +impl Operation for PaymentStatus { + fn to_domain(&self) -> RouterResult<&dyn Domain> { Ok(self) } fn to_update_tracker( &self, - ) -> RouterResult< - &(dyn UpdateTracker, api::PaymentsRequest, Ctx> + Send + Sync), - > { + ) -> RouterResult<&(dyn UpdateTracker, api::PaymentsRequest> + Send + Sync)> + { Ok(self) } } -impl Operation - for &PaymentStatus -{ - fn to_domain(&self) -> RouterResult<&dyn Domain> { +impl Operation for &PaymentStatus { + fn to_domain(&self) -> RouterResult<&dyn Domain> { Ok(*self) } fn to_update_tracker( &self, - ) -> RouterResult< - &(dyn UpdateTracker, api::PaymentsRequest, Ctx> + Send + Sync), - > { + ) -> RouterResult<&(dyn UpdateTracker, api::PaymentsRequest> + Send + Sync)> + { Ok(*self) } } #[async_trait] -impl Domain - for PaymentStatus -{ +impl Domain for PaymentStatus { #[instrument(skip_all)] async fn get_or_create_customer_details<'a>( &'a self, @@ -74,7 +65,7 @@ impl Domain CustomResult< ( - BoxedOperation<'a, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsRequest>, Option, ), errors::StorageError, @@ -100,7 +91,7 @@ impl Domain, ) -> RouterResult<( - BoxedOperation<'a, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsRequest>, Option, Option, )> { @@ -149,9 +140,28 @@ impl Domain - UpdateTracker, api::PaymentsRequest, Ctx> for PaymentStatus -{ +impl UpdateTracker, api::PaymentsRequest> for PaymentStatus { + async fn update_trackers<'b>( + &'b self, + _state: &'b AppState, + _req_state: ReqState, + payment_data: PaymentData, + _customer: Option, + _storage_scheme: enums::MerchantStorageScheme, + _updated_customer: Option, + _key_store: &domain::MerchantKeyStore, + _frm_suggestion: Option, + _header_payload: api::HeaderPayload, + ) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsRequest>, PaymentData)> + where + F: 'b + Send, + { + Ok((Box::new(self), payment_data)) + } +} + +#[async_trait] +impl UpdateTracker, api::PaymentsRetrieveRequest> for PaymentStatus { async fn update_trackers<'b>( &'b self, _state: &'b AppState, @@ -164,7 +174,7 @@ impl _frm_suggestion: Option, _header_payload: api::HeaderPayload, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsRetrieveRequest>, PaymentData, )> where @@ -175,34 +185,8 @@ impl } #[async_trait] -impl - UpdateTracker, api::PaymentsRetrieveRequest, Ctx> for PaymentStatus -{ - async fn update_trackers<'b>( - &'b self, - _state: &'b AppState, - _req_state: ReqState, - payment_data: PaymentData, - _customer: Option, - _storage_scheme: enums::MerchantStorageScheme, - _updated_customer: Option, - _key_store: &domain::MerchantKeyStore, - _frm_suggestion: Option, - _header_payload: api::HeaderPayload, - ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsRetrieveRequest, Ctx>, - PaymentData, - )> - where - F: 'b + Send, - { - Ok((Box::new(self), payment_data)) - } -} - -#[async_trait] -impl - GetTracker, api::PaymentsRetrieveRequest, Ctx> for PaymentStatus +impl GetTracker, api::PaymentsRetrieveRequest> + for PaymentStatus { #[instrument(skip_all)] async fn get_trackers<'a>( @@ -214,8 +198,7 @@ impl key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, _payment_confirm_source: Option, - ) -> RouterResult> - { + ) -> RouterResult> { get_tracker_for_sync( payment_id, merchant_account, @@ -232,8 +215,7 @@ impl async fn get_tracker_for_sync< 'a, F: Send + Clone, - Ctx: PaymentMethodRetrieve, - Op: Operation + 'a + Send + Sync, + Op: Operation + 'a + Send + Sync, >( payment_id: &api::PaymentIdType, merchant_account: &domain::MerchantAccount, @@ -242,7 +224,7 @@ async fn get_tracker_for_sync< request: &api::PaymentsRetrieveRequest, operation: Op, storage_scheme: enums::MerchantStorageScheme, -) -> RouterResult> { +) -> RouterResult> { let (payment_intent, mut payment_attempt, currency, amount); (payment_intent, payment_attempt) = get_payment_intent_payment_attempt( @@ -505,15 +487,13 @@ async fn get_tracker_for_sync< Ok(get_trackers_response) } -impl - ValidateRequest for PaymentStatus -{ +impl ValidateRequest for PaymentStatus { fn validate_request<'a, 'b>( &'b self, request: &api::PaymentsRetrieveRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsRetrieveRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsRetrieveRequest>, operations::ValidateResult<'a>, )> { let request_merchant_id = request.merchant_id.as_deref(); diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs index ff0b3a9f15..b52611e6f9 100644 --- a/crates/router/src/core/payments/operations/payment_update.rs +++ b/crates/router/src/core/payments/operations/payment_update.rs @@ -14,7 +14,6 @@ use crate::{ core::{ errors::{self, CustomResult, RouterResult, StorageErrorExt}, mandate::helpers as m_helpers, - payment_methods::PaymentMethodRetrieve, payments::{self, helpers, operations, CustomerDetails, PaymentAddress, PaymentData}, utils as core_utils, }, @@ -34,9 +33,7 @@ use crate::{ pub struct PaymentUpdate; #[async_trait] -impl - GetTracker, api::PaymentsRequest, Ctx> for PaymentUpdate -{ +impl GetTracker, api::PaymentsRequest> for PaymentUpdate { #[instrument(skip_all)] async fn get_trackers<'a>( &'a self, @@ -47,7 +44,7 @@ impl key_store: &domain::MerchantKeyStore, auth_flow: services::AuthFlow, _payment_confirm_source: Option, - ) -> RouterResult> { + ) -> RouterResult> { let (mut payment_intent, mut payment_attempt, currency): (_, _, storage_enums::Currency); let payment_id = payment_id @@ -325,7 +322,7 @@ impl }) .await .transpose()?; - let (next_operation, amount): (BoxedOperation<'a, F, api::PaymentsRequest, Ctx>, _) = + let (next_operation, amount): (BoxedOperation<'a, F, api::PaymentsRequest>, _) = if request.confirm.unwrap_or(false) { let amount = { let amount = request @@ -472,9 +469,7 @@ impl } #[async_trait] -impl Domain - for PaymentUpdate -{ +impl Domain for PaymentUpdate { #[instrument(skip_all)] async fn get_or_create_customer_details<'a>( &'a self, @@ -485,7 +480,7 @@ impl Domain CustomResult< ( - BoxedOperation<'a, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsRequest>, Option, ), errors::StorageError, @@ -511,7 +506,7 @@ impl Domain, ) -> RouterResult<( - BoxedOperation<'a, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'a, F, api::PaymentsRequest>, Option, Option, )> { @@ -560,9 +555,7 @@ impl Domain - UpdateTracker, api::PaymentsRequest, Ctx> for PaymentUpdate -{ +impl UpdateTracker, api::PaymentsRequest> for PaymentUpdate { #[instrument(skip_all)] async fn update_trackers<'b>( &'b self, @@ -575,10 +568,7 @@ impl _key_store: &domain::MerchantKeyStore, _frm_suggestion: Option, _header_payload: api::HeaderPayload, - ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsRequest, Ctx>, - PaymentData, - )> + ) -> RouterResult<(BoxedOperation<'b, F, api::PaymentsRequest>, PaymentData)> where F: 'b + Send, { @@ -742,16 +732,14 @@ impl } } -impl ValidateRequest - for PaymentUpdate -{ +impl ValidateRequest for PaymentUpdate { #[instrument(skip_all)] fn validate_request<'a, 'b>( &'b self, request: &api::PaymentsRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<( - BoxedOperation<'b, F, api::PaymentsRequest, Ctx>, + BoxedOperation<'b, F, api::PaymentsRequest>, operations::ValidateResult<'a>, )> { helpers::validate_customer_details_in_request(request)?; diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs index c28e6b35d5..c81773a734 100644 --- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs +++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs @@ -11,7 +11,6 @@ use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, Valida use crate::{ core::{ errors::{self, RouterResult, StorageErrorExt}, - payment_methods::PaymentMethodRetrieve, payments::{ self, helpers, operations, CustomerDetails, IncrementalAuthorizationDetails, PaymentAddress, @@ -35,8 +34,8 @@ use crate::{ pub struct PaymentIncrementalAuthorization; #[async_trait] -impl - GetTracker, PaymentsIncrementalAuthorizationRequest, Ctx> +impl + GetTracker, PaymentsIncrementalAuthorizationRequest> for PaymentIncrementalAuthorization { #[instrument(skip_all)] @@ -49,9 +48,8 @@ impl _key_store: &domain::MerchantKeyStore, _auth_flow: services::AuthFlow, _payment_confirm_source: Option, - ) -> RouterResult< - operations::GetTrackerResponse<'a, F, PaymentsIncrementalAuthorizationRequest, Ctx>, - > { + ) -> RouterResult> + { let db = &*state.store; let merchant_id = &merchant_account.merchant_id; let storage_scheme = merchant_account.storage_scheme; @@ -171,8 +169,7 @@ impl } #[async_trait] -impl - UpdateTracker, PaymentsIncrementalAuthorizationRequest, Ctx> +impl UpdateTracker, PaymentsIncrementalAuthorizationRequest> for PaymentIncrementalAuthorization { #[instrument(skip_all)] @@ -188,7 +185,7 @@ impl _frm_suggestion: Option, _header_payload: api::HeaderPayload, ) -> RouterResult<( - BoxedOperation<'b, F, PaymentsIncrementalAuthorizationRequest, Ctx>, + BoxedOperation<'b, F, PaymentsIncrementalAuthorizationRequest>, payments::PaymentData, )> where @@ -262,8 +259,7 @@ impl } } -impl - ValidateRequest +impl ValidateRequest for PaymentIncrementalAuthorization { #[instrument(skip_all)] @@ -272,7 +268,7 @@ impl request: &PaymentsIncrementalAuthorizationRequest, merchant_account: &'a domain::MerchantAccount, ) -> RouterResult<( - BoxedOperation<'b, F, PaymentsIncrementalAuthorizationRequest, Ctx>, + BoxedOperation<'b, F, PaymentsIncrementalAuthorizationRequest>, operations::ValidateResult<'a>, )> { Ok(( @@ -288,8 +284,8 @@ impl } #[async_trait] -impl - Domain for PaymentIncrementalAuthorization +impl Domain + for PaymentIncrementalAuthorization { #[instrument(skip_all)] async fn get_or_create_customer_details<'a>( @@ -301,7 +297,7 @@ impl _storage_scheme: enums::MerchantStorageScheme, ) -> CustomResult< ( - BoxedOperation<'a, F, PaymentsIncrementalAuthorizationRequest, Ctx>, + BoxedOperation<'a, F, PaymentsIncrementalAuthorizationRequest>, Option, ), errors::StorageError, @@ -318,7 +314,7 @@ impl _merchant_key_store: &domain::MerchantKeyStore, _customer: &Option, ) -> RouterResult<( - BoxedOperation<'a, F, PaymentsIncrementalAuthorizationRequest, Ctx>, + BoxedOperation<'a, F, PaymentsIncrementalAuthorizationRequest>, Option, Option, )> { diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rs index 58c58ffaef..1a39c06fb0 100644 --- a/crates/router/src/core/payments/retry.rs +++ b/crates/router/src/core/payments/retry.rs @@ -11,7 +11,6 @@ use router_env::{ use crate::{ core::{ errors::{self, RouterResult, StorageErrorExt}, - payment_methods::PaymentMethodRetrieve, payments::{ self, flows::{ConstructFlowSpecificData, Feature}, @@ -31,7 +30,7 @@ use crate::{ #[instrument(skip_all)] #[allow(clippy::too_many_arguments)] -pub async fn do_gsm_actions( +pub async fn do_gsm_actions( state: &app::AppState, req_state: ReqState, payment_data: &mut payments::PaymentData, @@ -40,7 +39,7 @@ pub async fn do_gsm_actions( mut router_data: types::RouterData, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, - operation: &operations::BoxedOperation<'_, F, ApiRequest, Ctx>, + operation: &operations::BoxedOperation<'_, F, ApiRequest>, customer: &Option, validate_result: &operations::ValidateResult<'_>, schedule_time: Option, @@ -49,12 +48,11 @@ pub async fn do_gsm_actions( where F: Clone + Send + Sync, FData: Send + Sync, - payments::PaymentResponse: operations::Operation, + payments::PaymentResponse: operations::Operation, payments::PaymentData: ConstructFlowSpecificData, types::RouterData: Feature, dyn api::Connector: services::api::ConnectorIntegration, - Ctx: PaymentMethodRetrieve, { let mut retries = None; @@ -267,11 +265,11 @@ fn get_flow_name() -> RouterResult { #[allow(clippy::too_many_arguments)] #[instrument(skip_all)] -pub async fn do_retry( +pub async fn do_retry( state: &routes::AppState, req_state: ReqState, connector: api::ConnectorData, - operation: &operations::BoxedOperation<'_, F, ApiRequest, Ctx>, + operation: &operations::BoxedOperation<'_, F, ApiRequest>, customer: &Option, merchant_account: &domain::MerchantAccount, key_store: &domain::MerchantKeyStore, @@ -285,12 +283,11 @@ pub async fn do_retry( where F: Clone + Send + Sync, FData: Send + Sync, - payments::PaymentResponse: operations::Operation, + payments::PaymentResponse: operations::Operation, payments::PaymentData: ConstructFlowSpecificData, types::RouterData: Feature, dyn api::Connector: services::api::ConnectorIntegration, - Ctx: PaymentMethodRetrieve, { metrics::AUTO_RETRY_PAYMENT_COUNT.add(&metrics::CONTEXT, 1, &[]); diff --git a/crates/router/src/core/webhooks.rs b/crates/router/src/core/webhooks.rs index 3c04fdb7e4..37393f0aab 100644 --- a/crates/router/src/core/webhooks.rs +++ b/crates/router/src/core/webhooks.rs @@ -30,7 +30,6 @@ use crate::{ core::{ api_locking, errors::{self, ConnectorErrorExt, CustomResult, RouterResponse}, - payment_methods::PaymentMethodRetrieve, payments, refunds, }, db::StorageInterface, @@ -59,7 +58,7 @@ use crate::{ const OUTGOING_WEBHOOK_TIMEOUT_SECS: u64 = 5; const MERCHANT_ID: &str = "merchant_id"; -pub async fn payments_incoming_webhook_flow( +pub async fn payments_incoming_webhook_flow( state: AppState, req_state: ReqState, merchant_account: domain::MerchantAccount, @@ -102,7 +101,6 @@ pub async fn payments_incoming_webhook_flow( _, _, _, - Ctx, >( state.clone(), req_state, @@ -419,7 +417,7 @@ pub async fn get_or_update_dispute_object( } #[allow(clippy::too_many_arguments)] -pub async fn external_authentication_incoming_webhook_flow( +pub async fn external_authentication_incoming_webhook_flow( state: AppState, req_state: ReqState, merchant_account: domain::MerchantAccount, @@ -511,7 +509,6 @@ pub async fn external_authentication_incoming_webhook_flow( state.clone(), req_state, @@ -752,7 +749,7 @@ pub async fn disputes_incoming_webhook_flow( } } -async fn bank_transfer_webhook_flow( +async fn bank_transfer_webhook_flow( state: AppState, req_state: ReqState, merchant_account: domain::MerchantAccount, @@ -782,7 +779,6 @@ async fn bank_transfer_webhook_flow( _, _, _, - Ctx, >( state.clone(), req_state, @@ -1448,7 +1444,7 @@ fn raise_webhooks_analytics_event( } #[allow(clippy::too_many_arguments)] -pub async fn webhooks_wrapper( +pub async fn webhooks_wrapper( flow: &impl router_env::types::FlowMetric, state: AppState, req_state: ReqState, @@ -1460,7 +1456,7 @@ pub async fn webhooks_wrapper RouterResponse { let start_instant = Instant::now(); let (application_response, webhooks_response_tracker, serialized_req) = - Box::pin(webhooks_core::( + Box::pin(webhooks_core::( state.clone(), req_state, req, @@ -1513,7 +1509,7 @@ pub async fn webhooks_wrapper( +pub async fn webhooks_core( state: AppState, req_state: ReqState, req: &actix_web::HttpRequest, @@ -1750,7 +1746,7 @@ pub async fn webhooks_core Box::pin(payments_incoming_webhook_flow::( + api::WebhookFlow::Payment => Box::pin(payments_incoming_webhook_flow( state.clone(), req_state, merchant_account, @@ -1789,7 +1785,7 @@ pub async fn webhooks_core Box::pin(bank_transfer_webhook_flow::( + api::WebhookFlow::BankTransfer => Box::pin(bank_transfer_webhook_flow( state.clone(), req_state, merchant_account, @@ -1816,7 +1812,7 @@ pub async fn webhooks_core { - Box::pin(external_authentication_incoming_webhook_flow::( + Box::pin(external_authentication_incoming_webhook_flow( state.clone(), req_state, merchant_account, diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rs index 70112e2703..6a1b424a33 100644 --- a/crates/router/src/routes/payments.rs +++ b/crates/router/src/routes/payments.rs @@ -14,7 +14,6 @@ use crate::{ self as app, core::{ errors::{self, http_not_implemented}, - payment_methods::{Oss, PaymentMethodRetrieve}, payments::{self, PaymentRedirectFlow}, utils as core_utils, }, @@ -125,7 +124,7 @@ pub async fn payments_create( &req, payload, |state, auth, req, req_state| { - authorize_verify_select::<_, Oss>( + authorize_verify_select::<_>( payments::PaymentCreate, state, req_state, @@ -195,7 +194,7 @@ pub async fn payments_start( _, _, _, - Oss, + >( state, req_state, @@ -271,7 +270,7 @@ pub async fn payments_retrieve( &req, payload, |state, auth, req, req_state| { - payments::payments_core::( + payments::payments_core::( state, req_state, auth.merchant_account, @@ -344,7 +343,7 @@ pub async fn payments_retrieve_with_gateway_creds( &req, payload, |state, auth, req, req_state| { - payments::payments_core::( + payments::payments_core::( state, req_state, auth.merchant_account, @@ -414,7 +413,7 @@ pub async fn payments_update( &req, payload, |state, auth, req, req_state| { - authorize_verify_select::<_, Oss>( + authorize_verify_select::<_>( payments::PaymentUpdate, state, req_state, @@ -492,7 +491,7 @@ pub async fn payments_confirm( &req, payload, |state, auth, req, req_state| { - authorize_verify_select::<_, Oss>( + authorize_verify_select::<_>( payments::PaymentConfirm, state, req_state, @@ -551,14 +550,7 @@ pub async fn payments_capture( &req, payload, |state, auth, payload, req_state| { - payments::payments_core::< - api_types::Capture, - payment_types::PaymentsResponse, - _, - _, - _, - Oss, - >( + payments::payments_core::( state, req_state, auth.merchant_account, @@ -616,7 +608,6 @@ pub async fn payments_connector_session( _, _, _, - Oss, >( state, req_state, @@ -682,7 +673,7 @@ pub async fn payments_redirect_response( &req, payload, |state, auth, req, req_state| { - >::handle_payments_redirect_response( + ::handle_payments_redirect_response( &payments::PaymentRedirectSync {}, state, req_state, @@ -743,7 +734,7 @@ pub async fn payments_redirect_response_with_creds_identifier( &req, payload, |state, auth, req, req_state| { - >::handle_payments_redirect_response( + ::handle_payments_redirect_response( &payments::PaymentRedirectSync {}, state, req_state, @@ -787,7 +778,7 @@ pub async fn payments_complete_authorize( payload, |state, auth, req, req_state| { - >::handle_payments_redirect_response( + ::handle_payments_redirect_response( &payments::PaymentRedirectCompleteAuthorize {}, state, req_state, @@ -841,7 +832,7 @@ pub async fn payments_cancel( &req, payload, |state, auth, req, req_state| { - payments::payments_core::( + payments::payments_core::( state, req_state, auth.merchant_account, @@ -999,14 +990,7 @@ pub async fn payments_approve( &http_req, payload.clone(), |state, auth, req, req_state| { - payments::payments_core::< - api_types::Capture, - payment_types::PaymentsResponse, - _, - _, - _, - Oss, - >( + payments::payments_core::( state, req_state, auth.merchant_account, @@ -1060,14 +1044,7 @@ pub async fn payments_reject( &http_req, payload.clone(), |state, auth, req, req_state| { - payments::payments_core::< - api_types::Void, - payment_types::PaymentsResponse, - _, - _, - _, - Oss, - >( + payments::payments_core::( state, req_state, auth.merchant_account, @@ -1098,7 +1075,7 @@ pub async fn payments_reject( } #[allow(clippy::too_many_arguments)] -async fn authorize_verify_select( +async fn authorize_verify_select( operation: Op, state: app::AppState, req_state: ReqState, @@ -1109,18 +1086,13 @@ async fn authorize_verify_select( auth_flow: api::AuthFlow, ) -> errors::RouterResponse where - Ctx: PaymentMethodRetrieve, Op: Sync + Clone + std::fmt::Debug + + payments::operations::Operation + payments::operations::Operation< - api_types::Authorize, - api_models::payments::PaymentsRequest, - Ctx, - > + payments::operations::Operation< api_types::SetupMandate, api_models::payments::PaymentsRequest, - Ctx, >, { // TODO: Change for making it possible for the flow to be inferred internally or through validation layer @@ -1133,28 +1105,25 @@ where match req.payment_type.unwrap_or_default() { api_models::enums::PaymentType::Normal | api_models::enums::PaymentType::RecurringMandate - | api_models::enums::PaymentType::NewMandate => { - payments::payments_core::< - api_types::Authorize, - payment_types::PaymentsResponse, - _, - _, - _, - Ctx, - >( - state, - req_state, - merchant_account, - key_store, - operation, - req, - auth_flow, - payments::CallConnectorAction::Trigger, - eligible_connectors, - header_payload, - ) - .await - } + | api_models::enums::PaymentType::NewMandate => payments::payments_core::< + api_types::Authorize, + payment_types::PaymentsResponse, + _, + _, + _, + >( + state, + req_state, + merchant_account, + key_store, + operation, + req, + auth_flow, + payments::CallConnectorAction::Trigger, + eligible_connectors, + header_payload, + ) + .await, api_models::enums::PaymentType::SetupMandate => { payments::payments_core::< api_types::SetupMandate, @@ -1162,7 +1131,6 @@ where _, _, _, - Ctx, >( state, req_state, @@ -1225,7 +1193,6 @@ pub async fn payments_incremental_authorization( _, _, _, - Oss, >( state, req_state, @@ -1342,7 +1309,7 @@ pub async fn post_3ds_payments_authorize( &req, payload, |state, auth, req, req_state| { - >::handle_payments_redirect_response( + ::handle_payments_redirect_response( &payments::PaymentAuthenticateCompleteAuthorize {}, state, req_state, diff --git a/crates/router/src/routes/webhooks.rs b/crates/router/src/routes/webhooks.rs index cdf680548a..fee38dbacd 100644 --- a/crates/router/src/routes/webhooks.rs +++ b/crates/router/src/routes/webhooks.rs @@ -5,7 +5,6 @@ use super::app::AppState; use crate::{ core::{ api_locking, - payment_methods::Oss, webhooks::{self, types}, }, services::{api, authentication as auth}, @@ -27,7 +26,7 @@ pub async fn receive_incoming_webhook( &req, (), |state, auth, _, req_state| { - webhooks::webhooks_wrapper::( + webhooks::webhooks_wrapper::( &flow, state.to_owned(), req_state, diff --git a/crates/router/src/workflows/outgoing_webhook_retry.rs b/crates/router/src/workflows/outgoing_webhook_retry.rs index 760993decb..726cbf9de0 100644 --- a/crates/router/src/workflows/outgoing_webhook_retry.rs +++ b/crates/router/src/workflows/outgoing_webhook_retry.rs @@ -329,7 +329,6 @@ async fn get_outgoing_webhook_content_and_event_type( core::{ disputes::retrieve_dispute, mandate::get_mandate, - payment_methods::Oss, payments::{payments_core, CallConnectorAction, PaymentStatus}, refunds::refund_retrieve_core, }, @@ -351,7 +350,7 @@ async fn get_outgoing_webhook_content_and_event_type( }; let payments_response = - match Box::pin(payments_core::( + match Box::pin(payments_core::( state, req_state, merchant_account, diff --git a/crates/router/src/workflows/payment_sync.rs b/crates/router/src/workflows/payment_sync.rs index 00db8fb29d..482b076a67 100644 --- a/crates/router/src/workflows/payment_sync.rs +++ b/crates/router/src/workflows/payment_sync.rs @@ -10,7 +10,6 @@ use crate::{ consts, core::{ errors::StorageErrorExt, - payment_methods::Oss, payments::{self as payment_flows, operations}, }, db::StorageInterface, @@ -60,14 +59,8 @@ impl ProcessTrackerWorkflow for PaymentsSyncWorkflow { .await?; // TODO: Add support for ReqState in PT flows - let (mut payment_data, _, customer, _, _) = - Box::pin(payment_flows::payments_operation_core::< - api::PSync, - _, - _, - _, - Oss, - >( + let (mut payment_data, _, customer, _, _) = Box::pin( + payment_flows::payments_operation_core::( state, state.get_req_state(), merchant_account.clone(), @@ -78,8 +71,9 @@ impl ProcessTrackerWorkflow for PaymentsSyncWorkflow { services::AuthFlow::Client, None, api::HeaderPayload::default(), - )) - .await?; + ), + ) + .await?; let terminal_status = [ enums::AttemptStatus::RouterDeclined, diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rs index f4325d01b9..45d3b29d66 100644 --- a/crates/router/tests/payments.rs +++ b/crates/router/tests/payments.rs @@ -4,7 +4,7 @@ mod utils; use router::{ configs, - core::{payment_methods::Oss, payments}, + core::payments, db::StorageImpl, routes, services, types::{ @@ -371,7 +371,6 @@ async fn payments_create_core() { _, _, _, - Oss, >( state.clone(), state.get_req_state(), @@ -554,7 +553,6 @@ async fn payments_create_core_adyen_no_redirect() { _, _, _, - Oss, >( state.clone(), state.get_req_state(), diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rs index 56ab453a0f..278ee80a92 100644 --- a/crates/router/tests/payments2.rs +++ b/crates/router/tests/payments2.rs @@ -3,7 +3,7 @@ mod utils; use router::{ - core::{payment_methods::Oss, payments}, + core::payments, db::StorageImpl, types::api::{self, enums as api_enums}, *, @@ -131,7 +131,6 @@ async fn payments_create_core() { _, _, _, - Oss, >( state.clone(), state.get_req_state(), @@ -322,7 +321,6 @@ async fn payments_create_core_adyen_no_redirect() { _, _, _, - Oss, >( state.clone(), state.get_req_state(), diff --git a/crates/router_derive/src/macros/operation.rs b/crates/router_derive/src/macros/operation.rs index e743a2d9cc..c1e8c4e5bb 100644 --- a/crates/router_derive/src/macros/operation.rs +++ b/crates/router_derive/src/macros/operation.rs @@ -40,7 +40,7 @@ impl Derives { let req_type = Conversion::get_req_type(self); quote! { #[automatically_derived] - impl Operation for #struct_name { + impl Operation for #struct_name { #(#fns)* } } @@ -54,7 +54,7 @@ impl Derives { let req_type = Conversion::get_req_type(self); quote! { #[automatically_derived] - impl Operation for &#struct_name { + impl Operation for &#struct_name { #(#ref_fns)* } } @@ -110,22 +110,22 @@ impl Conversion { let req_type = Self::get_req_type(ident); match self { Self::ValidateRequest => quote! { - fn to_validate_request(&self) -> RouterResult<&(dyn ValidateRequest + Send + Sync)> { + fn to_validate_request(&self) -> RouterResult<&(dyn ValidateRequest + Send + Sync)> { Ok(self) } }, Self::GetTracker => quote! { - fn to_get_tracker(&self) -> RouterResult<&(dyn GetTracker,#req_type,Ctx> + Send + Sync)> { + fn to_get_tracker(&self) -> RouterResult<&(dyn GetTracker,#req_type> + Send + Sync)> { Ok(self) } }, Self::Domain => quote! { - fn to_domain(&self) -> RouterResult<&dyn Domain> { + fn to_domain(&self) -> RouterResult<&dyn Domain> { Ok(self) } }, Self::UpdateTracker => quote! { - fn to_update_tracker(&self) -> RouterResult<&(dyn UpdateTracker,#req_type,Ctx> + Send + Sync)> { + fn to_update_tracker(&self) -> RouterResult<&(dyn UpdateTracker,#req_type> + Send + Sync)> { Ok(self) } }, @@ -158,22 +158,22 @@ impl Conversion { let req_type = Self::get_req_type(ident); match self { Self::ValidateRequest => quote! { - fn to_validate_request(&self) -> RouterResult<&(dyn ValidateRequest + Send + Sync)> { + fn to_validate_request(&self) -> RouterResult<&(dyn ValidateRequest + Send + Sync)> { Ok(*self) } }, Self::GetTracker => quote! { - fn to_get_tracker(&self) -> RouterResult<&(dyn GetTracker,#req_type,Ctx> + Send + Sync)> { + fn to_get_tracker(&self) -> RouterResult<&(dyn GetTracker,#req_type> + Send + Sync)> { Ok(*self) } }, Self::Domain => quote! { - fn to_domain(&self) -> RouterResult<&(dyn Domain)> { + fn to_domain(&self) -> RouterResult<&(dyn Domain)> { Ok(*self) } }, Self::UpdateTracker => quote! { - fn to_update_tracker(&self) -> RouterResult<&(dyn UpdateTracker,#req_type,Ctx> + Send + Sync)> { + fn to_update_tracker(&self) -> RouterResult<&(dyn UpdateTracker,#req_type> + Send + Sync)> { Ok(*self) } },