mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 21:07:58 +08:00
chore: added fork and headers
This commit is contained in:
@ -1381,3 +1381,9 @@ encryption_key = ""
|
|||||||
proxy_connector_http_status_code = false # If enabled, the http status code of the connector will be proxied in the response
|
proxy_connector_http_status_code = false # If enabled, the http status code of the connector will be proxied in the response
|
||||||
[list_dispute_supported_connectors]
|
[list_dispute_supported_connectors]
|
||||||
connector_list = "worldpayvantiv"
|
connector_list = "worldpayvantiv"
|
||||||
|
|
||||||
|
[proxy]
|
||||||
|
http_url = "http://127.0.0.1:8081" # Proxy all HTTP traffic via this proxy
|
||||||
|
https_url = "http://127.0.0.1:8081" # Proxy all HTTPS traffic via this proxy
|
||||||
|
idle_pool_connection_timeout = 90 # Timeout for idle pool connections (defaults to 90s)
|
||||||
|
bypass_proxy_urls = ""
|
||||||
@ -157,6 +157,12 @@ pub const APPLEPAY_VALIDATION_URL: &str =
|
|||||||
/// Request ID
|
/// Request ID
|
||||||
pub const X_REQUEST_ID: &str = "x-request-id";
|
pub const X_REQUEST_ID: &str = "x-request-id";
|
||||||
|
|
||||||
|
/// Flow name
|
||||||
|
pub const X_FLOW: &str = "x-flow";
|
||||||
|
|
||||||
|
/// Connector name
|
||||||
|
pub const X_CONNECTOR: &str = "x-connector";
|
||||||
|
|
||||||
/// Chat Session ID
|
/// Chat Session ID
|
||||||
pub const X_CHAT_SESSION_ID: &str = "x-chat-session-id";
|
pub const X_CHAT_SESSION_ID: &str = "x-chat-session-id";
|
||||||
|
|
||||||
|
|||||||
@ -162,16 +162,20 @@ pub struct GrpcHeadersUcs {
|
|||||||
external_vault_proxy_metadata: Option<String>,
|
external_vault_proxy_metadata: Option<String>,
|
||||||
/// Merchant Reference Id
|
/// Merchant Reference Id
|
||||||
merchant_reference_id: Option<ucs_types::UcsReferenceId>,
|
merchant_reference_id: Option<ucs_types::UcsReferenceId>,
|
||||||
|
|
||||||
|
request_id: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type aliase for GrpcHeaders builder in initial stage
|
/// Type aliase for GrpcHeaders builder in initial stage
|
||||||
pub type GrpcHeadersUcsBuilderInitial = GrpcHeadersUcsBuilder<((String,), (), (), ())>;
|
pub type GrpcHeadersUcsBuilderInitial =
|
||||||
|
GrpcHeadersUcsBuilder<((String,), (), (), (), (Option<String>,))>;
|
||||||
/// Type aliase for GrpcHeaders builder in intermediate stage
|
/// Type aliase for GrpcHeaders builder in intermediate stage
|
||||||
pub type GrpcHeadersUcsBuilderIntermediate = GrpcHeadersUcsBuilder<(
|
pub type GrpcHeadersUcsBuilderIntermediate = GrpcHeadersUcsBuilder<(
|
||||||
(String,),
|
(String,),
|
||||||
(),
|
(),
|
||||||
(Option<String>,),
|
(Option<String>,),
|
||||||
(Option<ucs_types::UcsReferenceId>,),
|
(Option<ucs_types::UcsReferenceId>,),
|
||||||
|
(Option<String>,),
|
||||||
)>;
|
)>;
|
||||||
|
|
||||||
/// struct to represent set of Lineage ids
|
/// struct to represent set of Lineage ids
|
||||||
|
|||||||
@ -456,6 +456,13 @@ pub fn build_unified_connector_service_grpc_headers(
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Some(request_id) = grpc_headers.request_id {
|
||||||
|
metadata.append(
|
||||||
|
common_utils_consts::X_REQUEST_ID,
|
||||||
|
parse(common_utils_consts::X_REQUEST_ID, &request_id)?,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
if let Err(err) = grpc_headers
|
if let Err(err) = grpc_headers
|
||||||
.tenant_id
|
.tenant_id
|
||||||
.parse()
|
.parse()
|
||||||
|
|||||||
@ -4075,12 +4075,13 @@ pub async fn call_connector_service_prerequisites<F, RouterDReq, ApiRequest, D>(
|
|||||||
)>
|
)>
|
||||||
where
|
where
|
||||||
F: Send + Clone + Sync,
|
F: Send + Clone + Sync,
|
||||||
RouterDReq: Send + Sync,
|
RouterDReq: Send + Clone + Sync,
|
||||||
|
|
||||||
// To create connector flow specific interface data
|
// To create connector flow specific interface data
|
||||||
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
|
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
|
||||||
D: ConstructFlowSpecificData<F, RouterDReq, router_types::PaymentsResponseData>,
|
D: ConstructFlowSpecificData<F, RouterDReq, router_types::PaymentsResponseData>,
|
||||||
RouterData<F, RouterDReq, router_types::PaymentsResponseData>: Feature<F, RouterDReq> + Send,
|
RouterData<F, RouterDReq, router_types::PaymentsResponseData>:
|
||||||
|
Feature<F, RouterDReq> + Send + Clone,
|
||||||
// To construct connector flow specific api
|
// To construct connector flow specific api
|
||||||
dyn api::Connector:
|
dyn api::Connector:
|
||||||
services::api::ConnectorIntegration<F, RouterDReq, router_types::PaymentsResponseData>,
|
services::api::ConnectorIntegration<F, RouterDReq, router_types::PaymentsResponseData>,
|
||||||
@ -4237,16 +4238,18 @@ pub async fn decide_unified_connector_service_call<F, RouterDReq, ApiRequest, D>
|
|||||||
)>
|
)>
|
||||||
where
|
where
|
||||||
F: Send + Clone + Sync,
|
F: Send + Clone + Sync,
|
||||||
RouterDReq: Send + Sync,
|
RouterDReq: Send + Sync + Clone,
|
||||||
|
|
||||||
// To create connector flow specific interface data
|
// To create connector flow specific interface data
|
||||||
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
|
D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,
|
||||||
D: ConstructFlowSpecificData<F, RouterDReq, router_types::PaymentsResponseData>,
|
D: ConstructFlowSpecificData<F, RouterDReq, router_types::PaymentsResponseData>,
|
||||||
RouterData<F, RouterDReq, router_types::PaymentsResponseData>: Feature<F, RouterDReq> + Send,
|
RouterData<F, RouterDReq, router_types::PaymentsResponseData>:
|
||||||
|
Feature<F, RouterDReq> + Send + Clone,
|
||||||
// To construct connector flow specific api
|
// To construct connector flow specific api
|
||||||
dyn api::Connector:
|
dyn api::Connector:
|
||||||
services::api::ConnectorIntegration<F, RouterDReq, router_types::PaymentsResponseData>,
|
services::api::ConnectorIntegration<F, RouterDReq, router_types::PaymentsResponseData>,
|
||||||
{
|
{
|
||||||
|
let mut rd = router_data.clone();
|
||||||
record_time_taken_with(|| async {
|
record_time_taken_with(|| async {
|
||||||
if !matches!(
|
if !matches!(
|
||||||
call_connector_action,
|
call_connector_action,
|
||||||
@ -4326,6 +4329,13 @@ where
|
|||||||
|
|
||||||
// Update feature metadata to track Direct routing usage for stickiness
|
// Update feature metadata to track Direct routing usage for stickiness
|
||||||
update_gateway_system_in_feature_metadata(payment_data, GatewaySystem::Direct)?;
|
update_gateway_system_in_feature_metadata(payment_data, GatewaySystem::Direct)?;
|
||||||
|
let _result = rd
|
||||||
|
.call_unified_connector_service(
|
||||||
|
state,
|
||||||
|
merchant_connector_account.clone(),
|
||||||
|
merchant_context,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
call_connector_service(
|
call_connector_service(
|
||||||
state,
|
state,
|
||||||
|
|||||||
@ -49,7 +49,7 @@ pub async fn do_gsm_actions<F, ApiRequest, FData, D>(
|
|||||||
) -> RouterResult<types::RouterData<F, FData, types::PaymentsResponseData>>
|
) -> RouterResult<types::RouterData<F, FData, types::PaymentsResponseData>>
|
||||||
where
|
where
|
||||||
F: Clone + Send + Sync,
|
F: Clone + Send + Sync,
|
||||||
FData: Send + Sync + types::Capturable,
|
FData: Send + Sync + types::Capturable + Clone,
|
||||||
payments::PaymentResponse: operations::Operation<F, FData>,
|
payments::PaymentResponse: operations::Operation<F, FData>,
|
||||||
D: payments::OperationSessionGetters<F>
|
D: payments::OperationSessionGetters<F>
|
||||||
+ payments::OperationSessionSetters<F>
|
+ payments::OperationSessionSetters<F>
|
||||||
@ -357,7 +357,7 @@ pub async fn do_retry<F, ApiRequest, FData, D>(
|
|||||||
) -> RouterResult<types::RouterData<F, FData, types::PaymentsResponseData>>
|
) -> RouterResult<types::RouterData<F, FData, types::PaymentsResponseData>>
|
||||||
where
|
where
|
||||||
F: Clone + Send + Sync,
|
F: Clone + Send + Sync,
|
||||||
FData: Send + Sync + types::Capturable,
|
FData: Send + Sync + types::Capturable + Clone,
|
||||||
payments::PaymentResponse: operations::Operation<F, FData>,
|
payments::PaymentResponse: operations::Operation<F, FData>,
|
||||||
D: payments::OperationSessionGetters<F>
|
D: payments::OperationSessionGetters<F>
|
||||||
+ payments::OperationSessionSetters<F>
|
+ payments::OperationSessionSetters<F>
|
||||||
|
|||||||
@ -157,7 +157,10 @@ impl SessionState {
|
|||||||
}
|
}
|
||||||
pub fn get_grpc_headers_ucs(&self) -> GrpcHeadersUcsBuilderInitial {
|
pub fn get_grpc_headers_ucs(&self) -> GrpcHeadersUcsBuilderInitial {
|
||||||
let tenant_id = self.tenant.tenant_id.get_string_repr().to_string();
|
let tenant_id = self.tenant.tenant_id.get_string_repr().to_string();
|
||||||
GrpcHeadersUcs::builder().tenant_id(tenant_id)
|
let request_id = self.request_id.map(|req_id| (*req_id).to_string());
|
||||||
|
GrpcHeadersUcs::builder()
|
||||||
|
.tenant_id(tenant_id)
|
||||||
|
.request_id(request_id)
|
||||||
}
|
}
|
||||||
#[cfg(all(feature = "revenue_recovery", feature = "v2"))]
|
#[cfg(all(feature = "revenue_recovery", feature = "v2"))]
|
||||||
pub fn get_recovery_grpc_headers(&self) -> GrpcRecoveryHeaders {
|
pub fn get_recovery_grpc_headers(&self) -> GrpcRecoveryHeaders {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ pub use client::{ApiClient, MockApiClient, ProxyClient};
|
|||||||
pub use common_enums::enums::PaymentAction;
|
pub use common_enums::enums::PaymentAction;
|
||||||
pub use common_utils::request::{ContentType, Method, Request, RequestBuilder};
|
pub use common_utils::request::{ContentType, Method, Request, RequestBuilder};
|
||||||
use common_utils::{
|
use common_utils::{
|
||||||
consts::{DEFAULT_TENANT, TENANT_HEADER, X_HS_LATENCY},
|
consts::{DEFAULT_TENANT, TENANT_HEADER, X_CONNECTOR, X_FLOW, X_HS_LATENCY, X_REQUEST_ID},
|
||||||
errors::{ErrorSwitch, ReportSwitchExt},
|
errors::{ErrorSwitch, ReportSwitchExt},
|
||||||
request::RequestContent,
|
request::RequestContent,
|
||||||
};
|
};
|
||||||
@ -326,7 +326,7 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
match connector_request {
|
match connector_request {
|
||||||
Some(request) => {
|
Some(mut request) => {
|
||||||
let masked_request_body = match &request.body {
|
let masked_request_body = match &request.body {
|
||||||
Some(request) => match request {
|
Some(request) => match request {
|
||||||
RequestContent::Json(i)
|
RequestContent::Json(i)
|
||||||
@ -339,6 +339,29 @@ where
|
|||||||
},
|
},
|
||||||
None => serde_json::Value::Null,
|
None => serde_json::Value::Null,
|
||||||
};
|
};
|
||||||
|
let flow_name = std::any::type_name::<T>()
|
||||||
|
.split("::")
|
||||||
|
.last()
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
request.headers.insert((
|
||||||
|
X_FLOW.to_string(),
|
||||||
|
Maskable::Masked(Secret::new(flow_name.clone().to_string())),
|
||||||
|
));
|
||||||
|
|
||||||
|
let connector_name = req.connector.clone();
|
||||||
|
request.headers.insert((
|
||||||
|
X_CONNECTOR.to_string(),
|
||||||
|
Maskable::Masked(Secret::new(connector_name.clone().to_string())),
|
||||||
|
));
|
||||||
|
state.request_id.as_ref().map(|id| {
|
||||||
|
let request_id = id.to_string();
|
||||||
|
request.headers.insert((
|
||||||
|
X_REQUEST_ID.to_string(),
|
||||||
|
Maskable::Masked(Secret::new(request_id.clone())),
|
||||||
|
));
|
||||||
|
request_id
|
||||||
|
});
|
||||||
let request_url = request.url.clone();
|
let request_url = request.url.clone();
|
||||||
let request_method = request.method;
|
let request_method = request.method;
|
||||||
let current_time = Instant::now();
|
let current_time = Instant::now();
|
||||||
|
|||||||
Reference in New Issue
Block a user