mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 12:06:56 +08:00
chore: introduce placeholders for complete authorize through ucs
This commit is contained in:
@ -79,19 +79,19 @@ pub trait ConstructFlowSpecificData<F, Req, Res> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PreDecideFlowOutput {
|
||||
pub connector_response_reference_id: Option<String>,
|
||||
pub session_token: Option<api::SessionToken>,
|
||||
pub connector_request: Option<services::Request>,
|
||||
pub should_continue_further: bool,
|
||||
}
|
||||
// pub struct PreDecideFlowOutput {
|
||||
// pub connector_response_reference_id: Option<String>,
|
||||
// pub session_token: Option<api::SessionToken>,
|
||||
// pub connector_request: Option<services::Request>,
|
||||
// pub should_continue_further: bool,
|
||||
// }
|
||||
|
||||
pub struct PreDecideFlowInputs<'a> {
|
||||
pub call_connector_action: &'a payments::CallConnectorAction,
|
||||
pub tokenization_action: &'a payments::TokenizationAction,
|
||||
pub is_retry_payment: bool,
|
||||
pub creds_identifier: Option<&'a str>,
|
||||
}
|
||||
// pub struct PreDecideFlowInputs<'a> {
|
||||
// pub call_connector_action: &'a payments::CallConnectorAction,
|
||||
// pub tokenization_action: &'a payments::TokenizationAction,
|
||||
// pub is_retry_payment: bool,
|
||||
// pub creds_identifier: Option<&'a str>,
|
||||
// }
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[async_trait]
|
||||
@ -227,6 +227,28 @@ pub trait Feature<F, T> {
|
||||
fn get_current_flow_info(&self) -> Option<api_interfaces::CurrentFlowInfo<'_>> {
|
||||
None
|
||||
}
|
||||
|
||||
async fn call_preprocessing_through_unified_connector_service<'a>(
|
||||
self,
|
||||
_state: &SessionState,
|
||||
_header_payload: &domain_payments::HeaderPayload,
|
||||
_lineage_ids: &grpc_client::LineageIds,
|
||||
#[cfg(feature = "v1")] _merchant_connector_account: helpers::MerchantConnectorAccountType,
|
||||
#[cfg(feature = "v2")]
|
||||
_merchant_connector_account: domain::MerchantConnectorAccountTypeDetails,
|
||||
_merchant_context: &domain::MerchantContext,
|
||||
_connector_data: &api::ConnectorData,
|
||||
_unified_connector_service_execution_mode: ExecutionMode,
|
||||
) -> RouterResult<(Self, bool)>
|
||||
where
|
||||
F: Clone,
|
||||
Self: Sized,
|
||||
dyn api::Connector: services::ConnectorIntegration<F, T, types::PaymentsResponseData>,
|
||||
{
|
||||
// Default behaviour is to do nothing and continue further
|
||||
Ok((self, true))
|
||||
}
|
||||
|
||||
async fn call_unified_connector_service<'a>(
|
||||
&mut self,
|
||||
_state: &SessionState,
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
use async_trait::async_trait;
|
||||
use external_services::grpc_client;
|
||||
use hyperswitch_interfaces::{api as api_interface, api::ConnectorSpecifications};
|
||||
use masking::ExposeInterface;
|
||||
|
||||
use super::{ConstructFlowSpecificData, Feature};
|
||||
@ -214,6 +216,63 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
|
||||
) -> RouterResult<Self> {
|
||||
complete_authorize_preprocessing_steps(state, &self, true, connector).await
|
||||
}
|
||||
|
||||
async fn call_preprocessing_through_unified_connector_service<'a>(
|
||||
self,
|
||||
_state: &SessionState,
|
||||
_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
|
||||
_lineage_ids: &grpc_client::LineageIds,
|
||||
#[cfg(feature = "v1")] _merchant_connector_account: helpers::MerchantConnectorAccountType,
|
||||
#[cfg(feature = "v2")]
|
||||
_merchant_connector_account: domain::MerchantConnectorAccountTypeDetails,
|
||||
_merchant_context: &domain::MerchantContext,
|
||||
connector_data: &api::ConnectorData,
|
||||
_unified_connector_service_execution_mode: common_enums::ExecutionMode,
|
||||
) -> RouterResult<(Self, bool)> {
|
||||
let current_flow = api_interface::CurrentFlowInfo::CompleteAuthorize {
|
||||
request_data: &self.request,
|
||||
};
|
||||
if let Some(preprocessing_flow_details) = connector_data
|
||||
.connector
|
||||
.get_preprocessing_flow_if_needed(current_flow)
|
||||
{
|
||||
let updated_router_data = match preprocessing_flow_details.flow_name {
|
||||
api_interface::PreProcessingFlowName::Authenticate => {
|
||||
// Call UCS for Authenticate flow
|
||||
self
|
||||
}
|
||||
api_interface::PreProcessingFlowName::PostAuthenticate => {
|
||||
// Call UCS for PostAuthenticate flow
|
||||
self
|
||||
}
|
||||
};
|
||||
let pre_processing_flow_response = api_interface::PreProcessingFlowResponse {
|
||||
response: &updated_router_data.response,
|
||||
attempt_status: updated_router_data.status,
|
||||
};
|
||||
let should_continue =
|
||||
(preprocessing_flow_details.should_continue)(&pre_processing_flow_response);
|
||||
Ok((updated_router_data, should_continue))
|
||||
} else {
|
||||
Ok((self, true))
|
||||
}
|
||||
}
|
||||
|
||||
async fn call_unified_connector_service<'a>(
|
||||
&mut self,
|
||||
_state: &SessionState,
|
||||
_header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
|
||||
_lineage_ids: grpc_client::LineageIds,
|
||||
#[cfg(feature = "v1")] _merchant_connector_account: helpers::MerchantConnectorAccountType,
|
||||
#[cfg(feature = "v2")]
|
||||
_merchant_connector_account: domain::MerchantConnectorAccountTypeDetails,
|
||||
_merchant_context: &domain::MerchantContext,
|
||||
_connector_data: &api::ConnectorData,
|
||||
_unified_connector_service_execution_mode: common_enums::ExecutionMode,
|
||||
) -> RouterResult<()> {
|
||||
// Call UCS for Authorize flow
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn complete_authorize_preprocessing_steps<F: Clone>(
|
||||
|
||||
@ -7873,7 +7873,7 @@ pub async fn process_through_ucs<'a, F, RouterDReq, ApiRequest, D>(
|
||||
business_profile: &'a domain::Profile,
|
||||
merchant_connector_account: MerchantConnectorAccountType,
|
||||
connector_data: &api::ConnectorData,
|
||||
mut router_data: RouterData<F, RouterDReq, PaymentsResponseData>,
|
||||
router_data: RouterData<F, RouterDReq, PaymentsResponseData>,
|
||||
) -> RouterResult<(
|
||||
RouterData<F, RouterDReq, PaymentsResponseData>,
|
||||
MerchantConnectorAccountType,
|
||||
@ -7917,6 +7917,22 @@ where
|
||||
GatewaySystem::UnifiedConnectorService,
|
||||
)?;
|
||||
|
||||
let lineage_ids = grpc_client::LineageIds::new(
|
||||
business_profile.merchant_id.clone(),
|
||||
business_profile.get_id().clone(),
|
||||
);
|
||||
let (mut router_data, should_continue) = router_data
|
||||
.call_preprocessing_through_unified_connector_service(
|
||||
state,
|
||||
&header_payload,
|
||||
&lineage_ids,
|
||||
merchant_connector_account.clone(),
|
||||
merchant_context,
|
||||
connector_data,
|
||||
ExecutionMode::Primary, // UCS is called in primary mode
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Update trackers
|
||||
(_, *payment_data) = operation
|
||||
.to_update_tracker()?
|
||||
@ -7933,23 +7949,20 @@ where
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Call UCS
|
||||
let lineage_ids = grpc_client::LineageIds::new(
|
||||
business_profile.merchant_id.clone(),
|
||||
business_profile.get_id().clone(),
|
||||
);
|
||||
|
||||
router_data
|
||||
.call_unified_connector_service(
|
||||
state,
|
||||
&header_payload,
|
||||
lineage_ids,
|
||||
merchant_connector_account.clone(),
|
||||
merchant_context,
|
||||
connector_data,
|
||||
ExecutionMode::Primary, // UCS is called in primary mode
|
||||
)
|
||||
.await?;
|
||||
// Based on the preprocessing response, decide whether to continue with UCS call
|
||||
if should_continue {
|
||||
router_data
|
||||
.call_unified_connector_service(
|
||||
state,
|
||||
&header_payload,
|
||||
lineage_ids,
|
||||
merchant_connector_account.clone(),
|
||||
merchant_context,
|
||||
connector_data,
|
||||
ExecutionMode::Primary, // UCS is called in primary mode
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok((router_data, merchant_connector_account))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user