mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
chore: handled V2
This commit is contained in:
@ -948,7 +948,7 @@ pub async fn create_payment_method_core(
|
||||
|
||||
match &req.payment_method_data {
|
||||
api::PaymentMethodCreateData::Card(_) => {
|
||||
create_payment_method_card_core(
|
||||
Box::pin(create_payment_method_card_core(
|
||||
state,
|
||||
req,
|
||||
merchant_context,
|
||||
@ -957,7 +957,7 @@ pub async fn create_payment_method_core(
|
||||
&customer_id,
|
||||
payment_method_id,
|
||||
payment_method_billing_address,
|
||||
)
|
||||
))
|
||||
.await
|
||||
}
|
||||
api::PaymentMethodCreateData::ProxyCard(_) => {
|
||||
|
||||
@ -2674,7 +2674,7 @@ pub async fn payments_core<F, Res, Req, Op, FData, D>(
|
||||
where
|
||||
F: Send + Clone + Sync,
|
||||
Req: Send + Sync + Authenticate,
|
||||
FData: Send + Sync + Clone,
|
||||
FData: Send + Sync + Clone + serde::Serialize,
|
||||
Op: Operation<F, Req, Data = D> + ValidateStatusForOperation + Send + Sync + Clone,
|
||||
Req: Debug,
|
||||
D: OperationSessionGetters<F>
|
||||
@ -4934,47 +4934,62 @@ where
|
||||
)
|
||||
.await?;
|
||||
|
||||
let (connector_request, should_continue_further) = if !should_call_unified_connector_service {
|
||||
let mut should_continue_further = true;
|
||||
// Early return for shadow UCS - not implemented in v2
|
||||
if matches!(
|
||||
should_call_unified_connector_service,
|
||||
GatewaySystem::ShadowUnifiedConnectorService
|
||||
) {
|
||||
router_env::logger::info!(
|
||||
"Shadow UCS mode not implemented in v2 - payment_id={}, attempt_id={}",
|
||||
payment_data.get_payment_intent().id.get_string_repr(),
|
||||
payment_data.get_payment_attempt().id.get_string_repr()
|
||||
);
|
||||
return Ok(router_data);
|
||||
}
|
||||
|
||||
let should_continue = match router_data
|
||||
.create_order_at_connector(state, &connector, should_continue_further)
|
||||
.await?
|
||||
{
|
||||
Some(create_order_response) => {
|
||||
if let Ok(order_id) = create_order_response.clone().create_order_result {
|
||||
payment_data.set_connector_response_reference_id(Some(order_id))
|
||||
let (connector_request, should_continue_further) =
|
||||
if matches!(should_call_unified_connector_service, GatewaySystem::Direct) {
|
||||
let mut should_continue_further = true;
|
||||
|
||||
let should_continue = match router_data
|
||||
.create_order_at_connector(state, &connector, should_continue_further)
|
||||
.await?
|
||||
{
|
||||
Some(create_order_response) => {
|
||||
if let Ok(order_id) = create_order_response.clone().create_order_result {
|
||||
payment_data.set_connector_response_reference_id(Some(order_id))
|
||||
}
|
||||
|
||||
// Set the response in routerdata response to carry forward
|
||||
router_data.update_router_data_with_create_order_response(
|
||||
create_order_response.clone(),
|
||||
);
|
||||
create_order_response.create_order_result.ok().map(|_| ())
|
||||
}
|
||||
// If create order is not required, then we can proceed with further processing
|
||||
None => Some(()),
|
||||
};
|
||||
|
||||
// Set the response in routerdata response to carry forward
|
||||
router_data
|
||||
.update_router_data_with_create_order_response(create_order_response.clone());
|
||||
create_order_response.create_order_result.ok().map(|_| ())
|
||||
}
|
||||
// If create order is not required, then we can proceed with further processing
|
||||
None => Some(()),
|
||||
let should_continue: (Option<common_utils::request::Request>, bool) =
|
||||
match should_continue {
|
||||
Some(_) => {
|
||||
router_data
|
||||
.build_flow_specific_connector_request(
|
||||
state,
|
||||
&connector,
|
||||
call_connector_action.clone(),
|
||||
)
|
||||
.await?
|
||||
}
|
||||
None => (None, false),
|
||||
};
|
||||
should_continue
|
||||
} else {
|
||||
// If unified connector service is called, these values are not used
|
||||
// as the request is built in the unified connector service call
|
||||
(None, false)
|
||||
};
|
||||
|
||||
let should_continue: (Option<common_utils::request::Request>, bool) = match should_continue
|
||||
{
|
||||
Some(_) => {
|
||||
router_data
|
||||
.build_flow_specific_connector_request(
|
||||
state,
|
||||
&connector,
|
||||
call_connector_action.clone(),
|
||||
)
|
||||
.await?
|
||||
}
|
||||
None => (None, false),
|
||||
};
|
||||
should_continue
|
||||
} else {
|
||||
// If unified connector service is called, these values are not used
|
||||
// as the request is built in the unified connector service call
|
||||
(None, false)
|
||||
};
|
||||
|
||||
(_, *payment_data) = operation
|
||||
.to_update_tracker()?
|
||||
.update_trackers(
|
||||
@ -4991,7 +5006,7 @@ where
|
||||
.await?;
|
||||
|
||||
record_time_taken_with(|| async {
|
||||
if should_call_unified_connector_service {
|
||||
if matches!(should_call_unified_connector_service, GatewaySystem::UnifiedConnectorService) {
|
||||
router_env::logger::info!(
|
||||
"Processing payment through UCS gateway system- payment_id={}, attempt_id={}",
|
||||
payment_data.get_payment_intent().id.get_string_repr(),
|
||||
@ -5006,6 +5021,7 @@ where
|
||||
lineage_ids,
|
||||
merchant_connector_account_type_details.clone(),
|
||||
merchant_context,
|
||||
false, // not shadow mode
|
||||
)
|
||||
.await?;
|
||||
|
||||
@ -5057,14 +5073,23 @@ where
|
||||
services::api::ConnectorIntegration<F, RouterDReq, router_types::PaymentsResponseData>,
|
||||
{
|
||||
record_time_taken_with(|| async {
|
||||
if should_call_unified_connector_service(
|
||||
let execution = should_call_unified_connector_service(
|
||||
state,
|
||||
merchant_context,
|
||||
&router_data,
|
||||
Some(payment_data),
|
||||
)
|
||||
.await?
|
||||
{
|
||||
.await?;
|
||||
if matches!(execution, GatewaySystem::ShadowUnifiedConnectorService) {
|
||||
router_env::logger::info!(
|
||||
"Shadow UCS mode not implemented in v2 - payment_id={}, attempt_id={}",
|
||||
payment_data.get_payment_intent().id.get_string_repr(),
|
||||
payment_data.get_payment_attempt().id.get_string_repr()
|
||||
);
|
||||
return Ok(router_data);
|
||||
}
|
||||
|
||||
if matches!(execution, GatewaySystem::UnifiedConnectorService) {
|
||||
router_env::logger::info!(
|
||||
"Executing payment through UCS gateway system - payment_id={}, attempt_id={}",
|
||||
payment_data.get_payment_intent().id.get_string_repr(),
|
||||
@ -5109,6 +5134,7 @@ where
|
||||
lineage_ids,
|
||||
merchant_connector_account_type_details.clone(),
|
||||
merchant_context,
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
@ -411,7 +411,7 @@ impl Feature<api::ExternalVaultProxy, types::ExternalVaultProxyPaymentsData>
|
||||
.flatten()
|
||||
.map(ucs_types::UcsReferenceId::Payment);
|
||||
let headers_builder = state
|
||||
.get_grpc_headers_ucs()
|
||||
.get_grpc_headers_ucs(false)
|
||||
.external_vault_proxy_metadata(Some(external_vault_proxy_metadata))
|
||||
.merchant_reference_id(merchant_order_reference_id)
|
||||
.lineage_ids(lineage_ids);
|
||||
|
||||
@ -4,12 +4,12 @@ use api_models::admin;
|
||||
#[cfg(feature = "v2")]
|
||||
use base64::Engine;
|
||||
use common_enums::{connector_enums::Connector, AttemptStatus, GatewaySystem, PaymentMethodType};
|
||||
#[cfg(feature = "v2")]
|
||||
use common_utils::consts::BASE64_ENGINE;
|
||||
use common_utils::{
|
||||
request::{Method, Request, RequestContent},
|
||||
};
|
||||
use common_utils::{
|
||||
errors::CustomResult,
|
||||
errors::CustomResult,
|
||||
ext_traits::ValueExt,
|
||||
request::{Method, Request, RequestContent},
|
||||
};
|
||||
use diesel_models::types::FeatureMetadata;
|
||||
use error_stack::ResultExt;
|
||||
@ -952,11 +952,15 @@ pub async fn send_comparison_data(
|
||||
comparison_data: ComparisonData,
|
||||
) -> RouterResult<()> {
|
||||
// Check if comparison service is enabled
|
||||
let enabled = state.conf.comparison_service
|
||||
let enabled = state
|
||||
.conf
|
||||
.comparison_service
|
||||
.as_ref()
|
||||
.map(|config| config.enabled)
|
||||
.unwrap_or_else(|| {
|
||||
tracing::warn!("Comparison service configuration missing, skipping comparison data send");
|
||||
tracing::warn!(
|
||||
"Comparison service configuration missing, skipping comparison data send"
|
||||
);
|
||||
false
|
||||
});
|
||||
|
||||
@ -965,7 +969,12 @@ pub async fn send_comparison_data(
|
||||
}
|
||||
|
||||
// Construct request
|
||||
let url = match state.conf.comparison_service.as_ref().map(|config| &config.url) {
|
||||
let url = match state
|
||||
.conf
|
||||
.comparison_service
|
||||
.as_ref()
|
||||
.map(|config| &config.url)
|
||||
{
|
||||
Some(url) => url,
|
||||
None => {
|
||||
tracing::warn!("Comparison service URL missing, skipping comparison data send");
|
||||
@ -984,7 +993,9 @@ pub async fn send_comparison_data(
|
||||
request.set_body(RequestContent::Json(Box::new(comparison_data)));
|
||||
|
||||
// Send with configurable timeout - don't block payment flow
|
||||
let timeout = state.conf.comparison_service
|
||||
let timeout = state
|
||||
.conf
|
||||
.comparison_service
|
||||
.as_ref()
|
||||
.and_then(|config| config.timeout_secs)
|
||||
.unwrap_or(2);
|
||||
|
||||
Reference in New Issue
Block a user