Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat: Implement UCS granular flows with gateway context refactoring (#10420)

Hrithikesh1b2bd68288f6
diff --git a/Cargo.lock b/Cargo.lock
index a180c565e0..a1002eef66 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3789,14 +3789,14 @@ dependencies = [
[[package]]
name = "grpc-api-types"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=b5a367c1c775c32503feb00cdc6cd063cc97ea3b#b5a367c1c775c32503feb00cdc6cd063cc97ea3b"
+source = "git+https://github.com/juspay/connector-service?rev=7f28be871568f5937975a99bde14ce47736fd81e#7f28be871568f5937975a99bde14ce47736fd81e"
dependencies = [
"axum 0.8.4",
"error-stack 0.5.0",
"g2h",
"heck 0.5.0",
"http 1.3.1",
- "masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=2025.09.24.0)",
+ "masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=2025.11.24.0)",
"prost",
"prost-build",
"prost-types",
@@ -4402,7 +4402,7 @@ dependencies = [
"http 0.2.12",
"hyperswitch_domain_models",
"masking 0.1.0",
- "masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=2025.09.24.0)",
+ "masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=2025.11.24.0)",
"mime",
"reqwest 0.11.27",
"router_env",
@@ -5161,7 +5161,7 @@ dependencies = [
[[package]]
name = "masking"
version = "0.1.0"
-source = "git+https://github.com/juspay/hyperswitch?tag=2025.09.24.0#85da1b2bc80d4befd392cf7a9d2060d1e2f5cbe9"
+source = "git+https://github.com/juspay/hyperswitch?tag=2025.11.24.0#19723f8c9c6c89057624061fef429f6f574dd358"
dependencies = [
"bytes 1.10.1",
"diesel",
@@ -7312,7 +7312,7 @@ dependencies = [
"jsonwebtoken",
"kgraph_utils",
"masking 0.1.0",
- "masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=2025.09.24.0)",
+ "masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=2025.11.24.0)",
"maud",
"mimalloc",
"mime",
@@ -7448,7 +7448,7 @@ dependencies = [
[[package]]
name = "rust-grpc-client"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=b5a367c1c775c32503feb00cdc6cd063cc97ea3b#b5a367c1c775c32503feb00cdc6cd063cc97ea3b"
+source = "git+https://github.com/juspay/connector-service?rev=7f28be871568f5937975a99bde14ce47736fd81e#7f28be871568f5937975a99bde14ce47736fd81e"
dependencies = [
"grpc-api-types",
]
@@ -10238,11 +10238,11 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"
[[package]]
name = "ucs_cards"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=b5a367c1c775c32503feb00cdc6cd063cc97ea3b#b5a367c1c775c32503feb00cdc6cd063cc97ea3b"
+source = "git+https://github.com/juspay/connector-service?rev=7f28be871568f5937975a99bde14ce47736fd81e#7f28be871568f5937975a99bde14ce47736fd81e"
dependencies = [
"bytes 1.10.1",
"error-stack 0.4.1",
- "masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=2025.09.24.0)",
+ "masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=2025.11.24.0)",
"prost",
"regex",
"serde",
@@ -10254,7 +10254,7 @@ dependencies = [
[[package]]
name = "ucs_common_enums"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=b5a367c1c775c32503feb00cdc6cd063cc97ea3b#b5a367c1c775c32503feb00cdc6cd063cc97ea3b"
+source = "git+https://github.com/juspay/connector-service?rev=7f28be871568f5937975a99bde14ce47736fd81e#7f28be871568f5937975a99bde14ce47736fd81e"
dependencies = [
"serde",
"strum 0.26.3",
@@ -10265,7 +10265,7 @@ dependencies = [
[[package]]
name = "ucs_common_utils"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=b5a367c1c775c32503feb00cdc6cd063cc97ea3b#b5a367c1c775c32503feb00cdc6cd063cc97ea3b"
+source = "git+https://github.com/juspay/connector-service?rev=7f28be871568f5937975a99bde14ce47736fd81e#7f28be871568f5937975a99bde14ce47736fd81e"
dependencies = [
"anyhow",
"base64 0.21.7",
@@ -10275,7 +10275,7 @@ dependencies = [
"error-stack 0.4.1",
"hex",
"http 1.3.1",
- "masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=2025.09.24.0)",
+ "masking 0.1.0 (git+https://github.com/juspay/hyperswitch?tag=2025.11.24.0)",
"md5",
"nanoid",
"once_cell",
diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.toml
index 67d9263477..770bb8728d 100644
--- a/crates/external_services/Cargo.toml
+++ b/crates/external_services/Cargo.toml
@@ -69,7 +69,7 @@ reqwest = { version = "0.11.27", features = ["rustls-tls"] }
http = "0.2.12"
url = { version = "2.5.4", features = ["serde"] }
quick-xml = { version = "0.31.0", features = ["serialize"] }
-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "b5a367c1c775c32503feb00cdc6cd063cc97ea3b", package = "rust-grpc-client" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "7f28be871568f5937975a99bde14ce47736fd81e", package = "rust-grpc-client" }
open-feature = { version = "0.2.5", optional = true }
superposition_provider = { version = "0.88.1", optional = true }
diff --git a/crates/hyperswitch_connectors/src/connectors/nuvei.rs b/crates/hyperswitch_connectors/src/connectors/nuvei.rs
index c15d73a9a2..125335de3f 100644
--- a/crates/hyperswitch_connectors/src/connectors/nuvei.rs
+++ b/crates/hyperswitch_connectors/src/connectors/nuvei.rs
@@ -1586,4 +1586,8 @@ impl ConnectorSpecifications for Nuvei {
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&NUVEI_SUPPORTED_WEBHOOK_FLOWS)
}
+
+ fn is_authorize_session_token_call_required(&self) -> bool {
+ true
+ }
}
diff --git a/crates/hyperswitch_connectors/src/connectors/paytm.rs b/crates/hyperswitch_connectors/src/connectors/paytm.rs
index 76ac0dc28c..f78d75db32 100644
--- a/crates/hyperswitch_connectors/src/connectors/paytm.rs
+++ b/crates/hyperswitch_connectors/src/connectors/paytm.rs
@@ -643,4 +643,8 @@ impl ConnectorSpecifications for Paytm {
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&*PAYTM_SUPPORTED_WEBHOOK_FLOWS)
}
+
+ fn is_authorize_session_token_call_required(&self) -> bool {
+ true
+ }
}
diff --git a/crates/hyperswitch_connectors/src/connectors/square.rs b/crates/hyperswitch_connectors/src/connectors/square.rs
index 1d65e1578d..61a16fb042 100644
--- a/crates/hyperswitch_connectors/src/connectors/square.rs
+++ b/crates/hyperswitch_connectors/src/connectors/square.rs
@@ -1000,4 +1000,7 @@ impl ConnectorSpecifications for Square {
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&*SQUARE_SUPPORTED_WEBHOOK_FLOWS)
}
+ fn is_authorize_session_token_call_required(&self) -> bool {
+ true
+ }
}
diff --git a/crates/hyperswitch_domain_models/src/router_flow_types/access_token_auth.rs b/crates/hyperswitch_domain_models/src/router_flow_types/access_token_auth.rs
index 66c940e5ec..31590f9c9e 100644
--- a/crates/hyperswitch_domain_models/src/router_flow_types/access_token_auth.rs
+++ b/crates/hyperswitch_domain_models/src/router_flow_types/access_token_auth.rs
@@ -1,5 +1,6 @@
+use serde;
#[derive(Clone, Debug)]
pub struct AccessTokenAuthentication;
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, serde::Serialize)]
pub struct AccessTokenAuth;
diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs
index 846bc3d591..355c395e43 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs
@@ -1191,7 +1191,7 @@ impl TryFrom<router_data::ConnectorAuthType> for AccessTokenAuthenticationReques
}
}
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Serialize)]
pub struct AccessTokenRequestData {
pub app_id: Secret<String>,
pub id: Option<Secret<String>>,
diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.toml
index 453fceee7d..32834294bf 100644
--- a/crates/hyperswitch_interfaces/Cargo.toml
+++ b/crates/hyperswitch_interfaces/Cargo.toml
@@ -29,8 +29,8 @@ serde_json = "1.0.140"
strum = { version = "0.26", features = ["derive"] }
thiserror = "1.0.69"
time = "0.3.41"
-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "b5a367c1c775c32503feb00cdc6cd063cc97ea3b", package = "rust-grpc-client" }
-unified-connector-service-masking = { git = "https://github.com/juspay/hyperswitch", tag = "2025.09.24.0", package = "masking" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "7f28be871568f5937975a99bde14ce47736fd81e", package = "rust-grpc-client" }
+unified-connector-service-masking = { git = "https://github.com/juspay/hyperswitch", tag = "2025.11.24.0", package = "masking" }
tokio = { version = "1.45.1", features = ["macros", "rt-multi-thread"] }
# First party crates
hyperswitch_domain_models = { version = "0.1.0", path = "../hyperswitch_domain_models", default-features = false }
diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs
index 1703658ae5..eb9bc4dacc 100644
--- a/crates/hyperswitch_interfaces/src/api.rs
+++ b/crates/hyperswitch_interfaces/src/api.rs
@@ -542,6 +542,11 @@ pub trait ConnectorSpecifications {
.unwrap_or_else(|| payment_attempt.id.get_string_repr().to_owned())
}
+ /// Is Authorize session token required before authorize
+ fn is_authorize_session_token_call_required(&self) -> bool {
+ false
+ }
+
#[cfg(feature = "v1")]
/// Generate connector customer reference ID for payments
fn generate_connector_customer_id(
diff --git a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
index 06b10df957..f3589037a3 100644
--- a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
+++ b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
@@ -636,6 +636,14 @@ impl ConnectorSpecifications for ConnectorEnum {
}
}
+ /// Check if the connector needs authorize session token call
+ fn is_authorize_session_token_call_required(&self) -> bool {
+ match self {
+ Self::Old(connector) => connector.is_authorize_session_token_call_required(),
+ Self::New(connector) => connector.is_authorize_session_token_call_required(),
+ }
+ }
+
#[cfg(feature = "v1")]
fn generate_connector_request_reference_id(
&self,
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index 4a4ba4987c..97e5ea7eeb 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -89,9 +89,9 @@ reqwest = { version = "0.11.27", features = ["json", "rustls-tls", "gzip", "mult
ring = "0.17.14"
rust_decimal = { version = "1.37.1", features = ["serde-with-float", "serde-with-str"] }
rust-i18n = { git = "https://github.com/kashif-m/rust-i18n", rev = "f2d8096aaaff7a87a847c35a5394c269f75e077a" }
-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "b5a367c1c775c32503feb00cdc6cd063cc97ea3b", package = "rust-grpc-client" }
-unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "b5a367c1c775c32503feb00cdc6cd063cc97ea3b", package = "ucs_cards" }
-unified-connector-service-masking = { git = "https://github.com/juspay/hyperswitch", tag = "2025.09.24.0", package = "masking" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "7f28be871568f5937975a99bde14ce47736fd81e", package = "rust-grpc-client" }
+unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "7f28be871568f5937975a99bde14ce47736fd81e", package = "ucs_cards" }
+unified-connector-service-masking = { git = "https://github.com/juspay/hyperswitch", tag = "2025.11.24.0", package = "masking" }
rustc-hash = "1.1.0"
rustls = "0.22"
rustls-pemfile = "2"
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 9f59a365ce..82edba0806 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -5,6 +5,7 @@ pub mod flows;
pub mod gateway;
pub mod helpers;
pub mod operations;
+pub mod session_token;
#[cfg(feature = "retry")]
pub mod retry;
@@ -4098,10 +4099,13 @@ where
&connector,
platform,
payment_data.get_creds_identifier(),
+ &context,
)
.await?;
- router_data = router_data.add_session_token(state, &connector).await?;
+ router_data
+ .add_session_token(state, &connector, &context)
+ .await?;
let should_continue_further = access_token::update_router_data_with_access_token_result(
&add_access_token_result,
@@ -4110,7 +4114,7 @@ where
);
let should_continue_further = match router_data
- .create_order_at_connector(state, &connector, should_continue_further)
+ .create_order_at_connector(state, &connector, should_continue_further, &context)
.await?
{
Some(create_order_response) => {
@@ -4134,6 +4138,7 @@ where
&merchant_connector_account,
payment_data,
router_data.access_token.as_ref(),
+ &context,
)
.await?;
@@ -4159,6 +4164,7 @@ where
&connector,
&tokenization_action,
should_continue_further,
+ &context,
)
.await?;
@@ -4659,16 +4665,26 @@ where
+ Send
+ Sync,
{
+ let gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account_type_details,
+ business_profile.merchant_id.clone(),
+ business_profile.get_id().clone(),
+ payment_data.get_creds_identifier().map(|id| id.to_string()),
+ );
let add_access_token_result = router_data
.add_access_token(
state,
&connector,
platform,
payment_data.get_creds_identifier(),
+ &gateway_context,
)
.await?;
- router_data = router_data.add_session_token(state, &connector).await?;
+ router_data
+ .add_session_token(state, &connector, &gateway_context)
+ .await?;
let should_continue_further = access_token::update_router_data_with_access_token_result(
&add_access_token_result,
@@ -4681,6 +4697,7 @@ where
&connector,
&tokenization_action,
should_continue_further,
+ &gateway_context,
)
.await?;
let should_continue_further = tokenization::update_router_data_with_payment_method_token_result(
@@ -4690,7 +4707,7 @@ where
should_continue_further,
);
let should_continue = match router_data
- .create_order_at_connector(state, &connector, should_continue_further)
+ .create_order_at_connector(state, &connector, should_continue_further, &gateway_context)
.await?
{
Some(create_order_response) => {
@@ -4747,19 +4764,6 @@ where
// and rely on previous status set in router_data
// TODO: status is already set when constructing payment data, why should this be done again?
// router_data.status = payment_data.get_payment_attempt().status;
- let lineage_ids = grpc_client::LineageIds::new(
- business_profile.merchant_id.clone(),
- business_profile.get_id().clone(),
- );
- let gateway_context = gateway_context::RouterGatewayContext {
- creds_identifier: payment_data.get_creds_identifier().map(|id| id.to_string()),
- platform: platform.clone(),
- header_payload: header_payload.clone(),
- lineage_ids,
- merchant_connector_account: merchant_connector_account_type_details,
- execution_path: ExecutionPath::Direct,
- execution_mode: ExecutionMode::NotApplicable,
- };
router_data
.decide_flows(
state,
@@ -5066,12 +5070,26 @@ where
)
.await?;
+ let profile_id = payment_data.get_payment_intent().profile_id.clone();
+ let default_gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account_type_details.clone(),
+ payment_data.get_payment_intent().merchant_id.clone(),
+ profile_id,
+ payment_data.get_creds_identifier().map(|id| id.to_string()),
+ );
+
let (connector_request, should_continue_further) =
if matches!(execution_path, ExecutionPath::Direct) {
let mut should_continue_further = true;
let should_continue = match router_data
- .create_order_at_connector(state, &connector, should_continue_further)
+ .create_order_at_connector(
+ state,
+ &connector,
+ should_continue_further,
+ &default_gateway_context,
+ )
.await?
{
Some(create_order_response) => {
@@ -5488,16 +5506,28 @@ where
)
.await?;
+ let gateway_context = gateway_context::RouterGatewayContext::new(
+ platform.clone(),
+ header_payload.clone(),
+ business_profile,
+ merchant_connector_account.clone(),
+ ExecutionPath::Direct,
+ None,
+ );
+
let add_access_token_result = router_data
.add_access_token(
state,
&connector,
platform,
payment_data.get_creds_identifier(),
+ &gateway_context,
)
.await?;
- router_data = router_data.add_session_token(state, &connector).await?;
+ router_data
+ .add_session_token(state, &connector, &gateway_context)
+ .await?;
let mut should_continue_further = access_token::update_router_data_with_access_token_result(
&add_access_token_result,
@@ -5564,26 +5594,6 @@ where
)
.await?;
- let lineage_ids = grpc_client::LineageIds::new(
- business_profile.merchant_id.clone(),
- business_profile.get_id().clone(),
- );
-
- // TODO: determine execution path for proxy call connector service
- let execution_path = ExecutionPath::Direct;
- // Execution mode is irrelevant for Direct execution path
- let execution_mode = ExecutionMode::NotApplicable;
-
- let gateway_context = gateway_context::RouterGatewayContext {
- creds_identifier: payment_data.get_creds_identifier().map(|id| id.to_string()),
- platform: platform.clone(),
- header_payload: header_payload.clone(),
- lineage_ids,
- merchant_connector_account: merchant_connector_account.clone(),
- execution_path,
- execution_mode,
- };
-
let router_data = if should_continue_further {
// The status of payment_attempt and intent will be updated in the previous step
// update this in router_data.
@@ -5651,6 +5661,14 @@ where
)
.await?,
));
+ let profile_id = payment_data.get_payment_intent().profile_id.clone();
+ let default_gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account.clone(),
+ payment_data.get_payment_intent().merchant_id.clone(),
+ profile_id,
+ payment_data.get_creds_identifier().map(|id| id.to_string()),
+ );
operation
.to_domain()?
.populate_payment_data(state, payment_data, platform, business_profile, &connector)
@@ -5674,10 +5692,13 @@ where
&connector,
platform,
payment_data.get_creds_identifier(),
+ &default_gateway_context,
)
.await?;
- router_data = router_data.add_session_token(state, &connector).await?;
+ router_data
+ .add_session_token(state, &connector, &default_gateway_context)
+ .await?;
let mut should_continue_further = access_token::update_router_data_with_access_token_result(
&add_access_token_result,
@@ -5707,20 +5728,6 @@ where
header_payload.clone(),
)
.await?;
- let lineage_ids = grpc_client::LineageIds::new(
- business_profile.merchant_id.clone(),
- business_profile.get_id().clone(),
- );
-
- let gateway_context = gateway_context::RouterGatewayContext {
- creds_identifier: payment_data.get_creds_identifier().map(|id| id.to_string()),
- platform: platform.clone(),
- header_payload: header_payload.clone(),
- lineage_ids,
- merchant_connector_account: merchant_connector_account.clone(),
- execution_path: ExecutionPath::Direct,
- execution_mode: ExecutionMode::NotApplicable,
- };
let router_data = if should_continue_further {
router_data
@@ -5732,7 +5739,7 @@ where
business_profile,
header_payload.clone(),
return_raw_connector_response,
- gateway_context,
+ default_gateway_context,
)
.await
} else {
@@ -5841,21 +5848,15 @@ where
header_payload.clone(),
)
.await?;
- let lineage_ids = grpc_client::LineageIds::new(
+
+ let gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account.clone(),
business_profile.merchant_id.clone(),
business_profile.get_id().clone(),
+ payment_data.get_creds_identifier().map(|id| id.to_string()),
);
- let gateway_context = gateway_context::RouterGatewayContext {
- creds_identifier: payment_data.get_creds_identifier().map(|id| id.to_string()),
- platform: platform.clone(),
- header_payload: header_payload.clone(),
- lineage_ids,
- merchant_connector_account: merchant_connector_account.clone(),
- execution_path: ExecutionPath::Direct,
- execution_mode: ExecutionMode::NotApplicable,
- };
-
let router_data = if should_continue_further {
router_data
.decide_flows(
@@ -6392,19 +6393,13 @@ where
Some(header_payload.clone()),
)
.await?;
- let lineage_ids = grpc_client::LineageIds::new(
+ let gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account.clone(),
business_profile.merchant_id.clone(),
business_profile.get_id().clone(),
+ payment_data.get_creds_identifier().map(|id| id.to_string()),
);
- let gateway_context = gateway_context::RouterGatewayContext {
- creds_identifier: payment_data.get_creds_identifier().map(|id| id.to_string()),
- platform: platform.clone(),
- header_payload: header_payload.clone(),
- lineage_ids,
- merchant_connector_account: merchant_connector_account.clone(),
- execution_path: ExecutionPath::Direct,
- execution_mode: ExecutionMode::NotApplicable,
- };
let res = router_data.decide_flows(
state,
@@ -6531,25 +6526,14 @@ where
)
.await?;
- let lineage_ids = grpc_client::LineageIds::new(
+ let gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account.clone(),
business_profile.merchant_id.clone(),
business_profile.get_id().clone(),
+ payment_data.get_creds_identifier().map(|id| id.to_string()),
);
- // TODO: determine execution path for SDK session token call.
- let execution_path = ExecutionPath::Direct;
- let execution_mode = ExecutionMode::NotApplicable;
-
- let gateway_context = gateway_context::RouterGatewayContext {
- creds_identifier: payment_data.get_creds_identifier().map(|id| id.to_string()),
- platform: platform.clone(),
- header_payload: header_payload.clone(),
- lineage_ids,
- merchant_connector_account: merchant_connector_account.clone(),
- execution_path,
- execution_mode,
- };
-
let res = router_data.decide_flows(
state,
&session_connector_data.connector,
@@ -6799,6 +6783,7 @@ pub async fn call_create_connector_customer_if_required<F, Req, D>(
merchant_connector_account: &helpers::MerchantConnectorAccountType,
payment_data: &mut D,
access_token: Option<&AccessToken>,
+ gateway_context: &gateway::context::RouterGatewayContext,
) -> RouterResult<Option<storage::CustomerUpdate>>
where
F: Send + Clone + Sync,
@@ -6814,7 +6799,6 @@ where
services::api::ConnectorIntegration<F, Req, router_types::PaymentsResponseData>,
{
let connector_name = payment_data.get_payment_attempt().connector.clone();
-
match connector_name {
Some(connector_name) => {
let connector = api::ConnectorData::get_connector_by_name(
@@ -6861,7 +6845,7 @@ where
payment_data.get_payment_attempt(),
&label,
);
-
+ logger::debug!(should_call_connector_customer = should_call_connector);
if should_call_connector {
// Create customer at connector and update the customer table to store this data
let mut customer_router_data = payment_data
@@ -6881,7 +6865,7 @@ where
customer_router_data.access_token = access_token.cloned();
let connector_customer_id = customer_router_data
- .create_connector_customer(state, &connector)
+ .create_connector_customer(state, &connector, gateway_context)
.await?;
let customer_update = customers::update_connector_customer_in_customers(
@@ -6928,6 +6912,14 @@ where
{
let connector_name = payment_data.get_payment_attempt().connector.clone();
+ let profile_id = payment_data.get_payment_intent().profile_id.clone();
+ let default_gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account.clone(),
+ payment_data.get_payment_intent().merchant_id.clone(),
+ profile_id,
+ payment_data.get_creds_identifier().map(|id| id.to_string()),
+ );
match connector_name {
Some(connector_name) => {
let connector = api::ConnectorData::get_connector_by_name(
@@ -6960,7 +6952,7 @@ where
.await?;
let connector_customer_id = router_data
- .create_connector_customer(state, &connector)
+ .create_connector_customer(state, &connector, &default_gateway_context)
.await?;
let customer_update = customers::update_connector_customer_in_customers(
diff --git a/crates/router/src/core/payments/access_token.rs b/crates/router/src/core/payments/access_token.rs
index 56c98632ab..b3d6781a7e 100644
--- a/crates/router/src/core/payments/access_token.rs
+++ b/crates/router/src/core/payments/access_token.rs
@@ -2,13 +2,13 @@ use std::fmt::Debug;
use common_utils::ext_traits::AsyncExt;
use error_stack::ResultExt;
-use hyperswitch_interfaces::api::{ConnectorAccessTokenSuffix, ConnectorSpecifications};
+use hyperswitch_interfaces::api::{gateway, ConnectorAccessTokenSuffix, ConnectorSpecifications};
use crate::{
consts,
core::{
errors::{self, RouterResult},
- payments,
+ payments::{self, gateway::context as gateway_context},
},
routes::{metrics, SessionState},
services::{self, logger},
@@ -120,6 +120,7 @@ pub async fn add_access_token<
connector: &api_types::ConnectorData,
router_data: &types::RouterData<F, Req, Res>,
creds_identifier: Option<&str>,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
if connector
.connector_name
@@ -210,45 +211,47 @@ pub async fn add_access_token<
refresh_token_request_data,
refresh_token_response_data,
);
- refresh_connector_auth(state, connector, &refresh_token_router_data)
- .await?
- .async_map(|access_token| async move {
- let store = &*state.store;
-
- // The expiry should be adjusted for network delays from the connector
- // The access token might not have been expired when request is sent
- // But once it reaches the connector, it might expire because of the network delay
- // Subtract few seconds from the expiry in order to account for these network delays
- // This will reduce the expiry time by `REDUCE_ACCESS_TOKEN_EXPIRY_TIME` seconds
- let modified_access_token_with_expiry = types::AccessToken {
- expires: access_token
- .expires
- .saturating_sub(consts::REDUCE_ACCESS_TOKEN_EXPIRY_TIME.into()),
- ..access_token
- };
-
- logger::debug!(
- access_token_expiry_after_modification =
- modified_access_token_with_expiry.expires
- );
-
- if let Err(access_token_set_error) = store
- .set_access_token(
- key.clone(),
- modified_access_token_with_expiry.clone(),
- )
- .await
- .change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("DB error when setting the access token")
- {
- // If we are not able to set the access token in redis, the error should just be logged and proceed with the payment
- // Payments should not fail, once the access token is successfully created
- // The next request will create new access token, if required
- logger::error!(access_token_set_error=?access_token_set_error);
- }
- Some(modified_access_token_with_expiry)
- })
- .await
+ refresh_connector_auth(
+ state,
+ connector,
+ &refresh_token_router_data,
+ gateway_context,
+ )
+ .await?
+ .async_map(|access_token| async move {
+ let store = &*state.store;
+
+ // The expiry should be adjusted for network delays from the connector
+ // The access token might not have been expired when request is sent
+ // But once it reaches the connector, it might expire because of the network delay
+ // Subtract few seconds from the expiry in order to account for these network delays
+ // This will reduce the expiry time by `REDUCE_ACCESS_TOKEN_EXPIRY_TIME` seconds
+ let modified_access_token_with_expiry = types::AccessToken {
+ expires: access_token
+ .expires
+ .saturating_sub(consts::REDUCE_ACCESS_TOKEN_EXPIRY_TIME.into()),
+ ..access_token
+ };
+
+ logger::debug!(
+ access_token_expiry_after_modification =
+ modified_access_token_with_expiry.expires
+ );
+
+ if let Err(access_token_set_error) = store
+ .set_access_token(key.clone(), modified_access_token_with_expiry.clone())
+ .await
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("DB error when setting the access token")
+ {
+ // If we are not able to set the access token in redis, the error should just be logged and proceed with the payment
+ // Payments should not fail, once the access token is successfully created
+ // The next request will create new access token, if required
+ logger::error!(access_token_set_error=?access_token_set_error);
+ }
+ Some(modified_access_token_with_expiry)
+ })
+ .await
}
};
@@ -272,6 +275,7 @@ pub async fn refresh_connector_auth(
types::AccessTokenRequestData,
types::AccessToken,
>,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<Result<types::AccessToken, types::ErrorResponse>> {
let connector_integration: services::BoxedAccessTokenConnectorIntegrationInterface<
api_types::AccessTokenAuth,
@@ -279,13 +283,14 @@ pub async fn refresh_connector_auth(
types::AccessToken,
> = connector.connector.get_connector_integration();
- let access_token_router_data_result = services::execute_connector_processing_step(
+ let access_token_router_data_result = gateway::execute_payment_gateway(
state,
connector_integration,
router_data,
payments::CallConnectorAction::Trigger,
None,
None,
+ gateway_context.clone(),
)
.await;
diff --git a/crates/router/src/core/payments/customers.rs b/crates/router/src/core/payments/customers.rs
index 3edc2436b4..5905327891 100644
--- a/crates/router/src/core/payments/customers.rs
+++ b/crates/router/src/core/payments/customers.rs
@@ -1,11 +1,11 @@
pub use hyperswitch_domain_models::customer::update_connector_customer_in_customers;
-use hyperswitch_interfaces::api::ConnectorSpecifications;
+use hyperswitch_interfaces::api::{gateway, ConnectorSpecifications};
use router_env::{instrument, tracing};
use crate::{
core::{
errors::{ConnectorErrorExt, RouterResult},
- payments,
+ payments::{self, gateway::context as gateway_context},
},
logger,
routes::{metrics, SessionState},
@@ -19,6 +19,7 @@ pub async fn create_connector_customer<F: Clone, T: Clone>(
connector: &api::ConnectorData,
router_data: &types::RouterData<F, T, types::PaymentsResponseData>,
customer_request_data: types::ConnectorCustomerData,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<Option<String>> {
let connector_integration: services::BoxedPaymentConnectorIntegrationInterface<
api::CreateConnectorCustomer,
@@ -42,13 +43,14 @@ pub async fn create_connector_customer<F: Clone, T: Clone>(
customer_response_data,
);
- let resp = services::execute_connector_processing_step(
+ let resp = gateway::execute_payment_gateway(
state,
connector_integration,
&customer_router_data,
payments::CallConnectorAction::Trigger,
None,
None,
+ gateway_context.clone(),
)
.await
.to_payment_failed_response()?;
diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs
index 7c1b29208b..45142d45c7 100644
--- a/crates/router/src/core/payments/flows.rs
+++ b/crates/router/src/core/payments/flows.rs
@@ -105,6 +105,7 @@ pub trait Feature<F, T> {
connector: &api::ConnectorData,
platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult>
where
F: Clone,
@@ -112,16 +113,17 @@ pub trait Feature<F, T> {
dyn api::Connector: services::ConnectorIntegration<F, T, types::PaymentsResponseData>;
async fn add_session_token<'a>(
- self,
+ &mut self,
_state: &SessionState,
_connector: &api::ConnectorData,
- ) -> RouterResult<Self>
+ _gateway_context: &gateway_context::RouterGatewayContext,
+ ) -> RouterResult<()>
where
F: Clone,
Self: Sized,
dyn api::Connector: services::ConnectorIntegration<F, T, types::PaymentsResponseData>,
{
- Ok(self)
+ Ok(())
}
async fn add_payment_method_token<'a>(
@@ -130,6 +132,7 @@ pub trait Feature<F, T> {
_connector: &api::ConnectorData,
_tokenization_action: &payments::TokenizationAction,
_should_continue_payment: bool,
+ _gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<types::PaymentMethodTokenResult>
where
F: Clone,
@@ -173,6 +176,7 @@ pub trait Feature<F, T> {
&self,
_state: &SessionState,
_connector: &api::ConnectorData,
+ _gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<Option<String>>
where
F: Clone,
@@ -197,6 +201,7 @@ pub trait Feature<F, T> {
_state: &SessionState,
_connector: &api::ConnectorData,
_should_continue_payment: bool,
+ _gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<Option<types::CreateOrderResult>>
where
F: Clone,
diff --git a/crates/router/src/core/payments/flows/approve_flow.rs b/crates/router/src/core/payments/flows/approve_flow.rs
index 3f8a7779e6..67ba0f0980 100644
--- a/crates/router/src/core/payments/flows/approve_flow.rs
+++ b/crates/router/src/core/payments/flows/approve_flow.rs
@@ -91,12 +91,14 @@ impl Feature<api::Approve, types::PaymentsApproveData>
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs
index 824a4063d3..cb52e311ea 100644
--- a/crates/router/src/core/payments/flows/authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/authorize_flow.rs
@@ -12,7 +12,7 @@ use hyperswitch_domain_models::{
errors::api_error_response::ApiErrorResponse, payments as domain_payments,
router_response_types,
};
-use hyperswitch_interfaces::{api as api_interface, api::ConnectorSpecifications};
+use hyperswitch_interfaces::api::{self as api_interface, gateway, ConnectorSpecifications};
use masking::ExposeInterface;
use unified_connector_service_client::payments as payments_grpc;
use unified_connector_service_masking::ExposeInterface as UcsMaskingExposeInterface;
@@ -24,8 +24,8 @@ use crate::{
errors::{ConnectorErrorExt, RouterResult},
mandate,
payments::{
- self, access_token, customers, flows::gateway_context, helpers, tokenization,
- transformers, PaymentData,
+ self, access_token, customers, flows::gateway_context, helpers, session_token,
+ tokenization, transformers, PaymentData,
},
unified_connector_service::{
self, build_unified_connector_service_auth_metadata,
@@ -38,10 +38,7 @@ use crate::{
logger,
routes::{metrics, SessionState},
services::{self, api::ConnectorValidation},
- types::{
- self, api, domain,
- transformers::{ForeignFrom, ForeignTryFrom},
- },
+ types::{self, api, domain, transformers::ForeignTryFrom},
utils::OptionExt,
};
@@ -215,13 +212,14 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
if self.should_proceed_with_authorize() {
self.decide_authentication_type();
logger::debug!(auth_type=?self.auth_type);
- let mut auth_router_data = services::execute_connector_processing_step(
+ let mut auth_router_data = gateway::execute_payment_gateway(
state,
connector_integration,
&self,
call_connector_action.clone(),
connector_request,
return_raw_connector_response,
+ gateway_context.clone(),
)
.await
.to_payment_failed_response()?;
@@ -270,46 +268,31 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
async fn add_session_token<'a>(
- self,
+ &mut self,
state: &SessionState,
connector: &api::ConnectorData,
- ) -> RouterResult<Self>
+ gateway_context: &gateway_context::RouterGatewayContext,
+ ) -> RouterResult<()>
where
Self: Sized,
{
- let connector_integration: services::BoxedPaymentConnectorIntegrationInterface<
- api::AuthorizeSessionToken,
- types::AuthorizeSessionTokenData,
- types::PaymentsResponseData,
- > = connector.connector.get_connector_integration();
- let authorize_data = &types::PaymentsAuthorizeSessionTokenRouterData::foreign_from((
- &self,
- types::AuthorizeSessionTokenData::foreign_from(&self),
- ));
- let resp = services::execute_connector_processing_step(
- state,
- connector_integration,
- authorize_data,
- payments::CallConnectorAction::Trigger,
- None,
- None,
- )
- .await
- .to_payment_failed_response()?;
- let mut router_data = self;
- router_data.session_token = resp.session_token;
- Ok(router_data)
+ self.session_token =
+ session_token::add_session_token_if_needed(self, state, connector, gateway_context)
+ .await?;
+ Ok(())
}
async fn add_payment_method_token<'a>(
@@ -318,6 +301,7 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
connector: &api::ConnectorData,
tokenization_action: &payments::TokenizationAction,
should_continue_payment: bool,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<types::PaymentMethodTokenResult> {
let request = self.request.clone();
tokenization::add_payment_method_token(
@@ -327,6 +311,7 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
self,
types::PaymentMethodTokenizationData::try_from(request)?,
should_continue_payment,
+ gateway_context,
)
.await
}
@@ -351,12 +336,14 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
&self,
state: &SessionState,
connector: &api::ConnectorData,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<Option<String>> {
customers::create_connector_customer(
state,
connector,
self,
types::ConnectorCustomerData::try_from(self)?,
+ gateway_context,
)
.await
}
@@ -460,6 +447,7 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
state: &SessionState,
connector: &api::ConnectorData,
should_continue_payment: bool,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<Option<types::CreateOrderResult>> {
if connector
.connector_name
@@ -484,13 +472,14 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
response_data,
);
- let resp = services::execute_connector_processing_step(
+ let resp = gateway::execute_payment_gateway(
state,
connector_integration,
&createorder_router_data,
payments::CallConnectorAction::Trigger,
None,
None,
+ gateway_context.clone(),
)
.await
.to_payment_failed_response()?;
diff --git a/crates/router/src/core/payments/flows/cancel_flow.rs b/crates/router/src/core/payments/flows/cancel_flow.rs
index 068cc530e0..38eb2a3fca 100644
--- a/crates/router/src/core/payments/flows/cancel_flow.rs
+++ b/crates/router/src/core/payments/flows/cancel_flow.rs
@@ -132,12 +132,14 @@ impl Feature<api::Void, types::PaymentsCancelData>
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &payments::gateway::context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
diff --git a/crates/router/src/core/payments/flows/cancel_post_capture_flow.rs b/crates/router/src/core/payments/flows/cancel_post_capture_flow.rs
index 161f568d38..4a33d67429 100644
--- a/crates/router/src/core/payments/flows/cancel_post_capture_flow.rs
+++ b/crates/router/src/core/payments/flows/cancel_post_capture_flow.rs
@@ -115,12 +115,14 @@ impl Feature<api::PostCaptureVoid, types::PaymentsCancelPostCaptureData>
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &payments::gateway::context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
diff --git a/crates/router/src/core/payments/flows/capture_flow.rs b/crates/router/src/core/payments/flows/capture_flow.rs
index 9ae3780ebc..621ebf767c 100644
--- a/crates/router/src/core/payments/flows/capture_flow.rs
+++ b/crates/router/src/core/payments/flows/capture_flow.rs
@@ -141,12 +141,14 @@ impl Feature<api::Capture, types::PaymentsCaptureData>
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &payments::gateway::context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
diff --git a/crates/router/src/core/payments/flows/complete_authorize_flow.rs b/crates/router/src/core/payments/flows/complete_authorize_flow.rs
index 9c8546d539..4c4f3ec33c 100644
--- a/crates/router/src/core/payments/flows/complete_authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/complete_authorize_flow.rs
@@ -15,7 +15,10 @@ use super::{ConstructFlowSpecificData, Feature};
use crate::{
core::{
errors::{ApiErrorResponse, ConnectorErrorExt, RouterResult},
- payments::{self, access_token, helpers, transformers, PaymentData},
+ payments::{
+ self, access_token, gateway::context as gateway_context, helpers, transformers,
+ PaymentData,
+ },
unified_connector_service as ucs_core,
},
logger,
@@ -107,7 +110,7 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
business_profile: &domain::Profile,
header_payload: hyperswitch_domain_models::payments::HeaderPayload,
_return_raw_connector_response: Option<bool>,
- gateway_context: payments::flows::gateway_context::RouterGatewayContext,
+ gateway_context: gateway_context::RouterGatewayContext,
) -> RouterResult<Self> {
let connector_integration: services::BoxedPaymentConnectorIntegrationInterface<
api::CompleteAuthorize,
@@ -159,12 +162,14 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
@@ -175,6 +180,7 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
connector: &api::ConnectorData,
_tokenization_action: &payments::TokenizationAction,
should_continue_payment: bool,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<types::PaymentMethodTokenResult> {
// TODO: remove this and handle it in core
if matches!(connector.connector_name, types::Connector::Payme) {
@@ -186,6 +192,7 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
self,
types::PaymentMethodTokenizationData::try_from(request)?,
should_continue_payment,
+ gateway_context,
)
.await
} else {
@@ -966,7 +973,7 @@ async fn process_capture_flow(
call_connector_action: payments::CallConnectorAction,
business_profile: &domain::Profile,
header_payload: hyperswitch_domain_models::payments::HeaderPayload,
- gateway_context: payments::flows::gateway_context::RouterGatewayContext,
+ gateway_context: gateway_context::RouterGatewayContext,
) -> RouterResult<
types::RouterData<
api::CompleteAuthorize,
diff --git a/crates/router/src/core/payments/flows/extend_authorization_flow.rs b/crates/router/src/core/payments/flows/extend_authorization_flow.rs
index 3e1fac692b..3dadf66abe 100644
--- a/crates/router/src/core/payments/flows/extend_authorization_flow.rs
+++ b/crates/router/src/core/payments/flows/extend_authorization_flow.rs
@@ -115,12 +115,14 @@ impl Feature<api::ExtendAuthorization, types::PaymentsExtendAuthorizationData>
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &payments::gateway::context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
diff --git a/crates/router/src/core/payments/flows/external_proxy_flow.rs b/crates/router/src/core/payments/flows/external_proxy_flow.rs
index 8260d77907..60ae091477 100644
--- a/crates/router/src/core/payments/flows/external_proxy_flow.rs
+++ b/crates/router/src/core/payments/flows/external_proxy_flow.rs
@@ -10,6 +10,7 @@ use hyperswitch_domain_models::payments::PaymentConfirmData;
use hyperswitch_domain_models::{
errors::api_error_response::ApiErrorResponse, payments as domain_payments,
};
+use hyperswitch_interfaces::api::gateway;
use masking::ExposeInterface;
use unified_connector_service_client::payments as payments_grpc;
use unified_connector_service_masking::ExposeInterface as UcsMaskingExposeInterface;
@@ -21,7 +22,7 @@ use crate::{
mandate,
payments::{
self, access_token, customers, gateway::context as gateway_context, helpers,
- tokenization, transformers, PaymentData,
+ session_token, tokenization, transformers, PaymentData,
},
unified_connector_service::{self, ucs_logging_wrapper},
},
@@ -122,40 +123,25 @@ impl Feature<api::ExternalVaultProxy, types::ExternalVaultProxyPaymentsData>
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &payments::gateway::context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
- access_token::add_access_token(state, connector, self, creds_identifier).await
+ access_token::add_access_token(state, connector, self, creds_identifier, gateway_context)
+ .await
}
async fn add_session_token<'a>(
- self,
+ &mut self,
state: &SessionState,
connector: &api::ConnectorData,
- ) -> RouterResult<Self>
+ gateway_context: &gateway_context::RouterGatewayContext,
+ ) -> RouterResult<()>
where
Self: Sized,
{
- let connector_integration: services::BoxedPaymentConnectorIntegrationInterface<
- api::AuthorizeSessionToken,
- types::AuthorizeSessionTokenData,
- types::PaymentsResponseData,
- > = connector.connector.get_connector_integration();
- let authorize_data = &types::PaymentsAuthorizeSessionTokenRouterData::foreign_from((
- &self,
- types::AuthorizeSessionTokenData::foreign_from(&self),
- ));
- let resp = services::execute_connector_processing_step(
- state,
- connector_integration,
- authorize_data,
- payments::CallConnectorAction::Trigger,
- None,
- None,
- )
- .await
- .to_payment_failed_response()?;
- let mut router_data = self;
- router_data.session_token = resp.session_token;
- Ok(router_data)
+ self.session_token =
+ session_token::add_session_token_if_needed(self, state, connector, gateway_context)
+ .await?;
+ Ok(())
}
async fn add_payment_method_token<'a>(
@@ -164,6 +150,7 @@ impl Feature<api::ExternalVaultProxy, types::ExternalVaultProxyPaymentsData>
connector: &api::ConnectorData,
tokenization_action: &payments::TokenizationAction,
should_continue_payment: bool,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<types::PaymentMethodTokenResult> {
let request = self.request.clone();
tokenization::add_payment_method_token(
@@ -173,6 +160,7 @@ impl Feature<api::ExternalVaultProxy, types::ExternalVaultProxyPaymentsData>
self,
types::PaymentMethodTokenizationData::try_from(request)?,
should_continue_payment,
+ gateway_context,
)
.await
}
@@ -197,12 +185,14 @@ impl Feature<api::ExternalVaultProxy, types::ExternalVaultProxyPaymentsData>
&self,
state: &SessionState,
connector: &api::ConnectorData,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<Option<String>> {
customers::create_connector_customer(
state,
connector,
self,
types::ConnectorCustomerData::try_from(self)?,
+ gateway_context,
)
.await
}
@@ -291,6 +281,7 @@ impl Feature<api::ExternalVaultProxy, types::ExternalVaultProxyPaymentsData>
state: &SessionState,
connector: &api::ConnectorData,
should_continue_payment: bool,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<Option<types::CreateOrderResult>> {
if connector
.connector_name
@@ -315,13 +306,14 @@ impl Feature<api::ExternalVaultProxy, types::ExternalVaultProxyPaymentsData>
response_data,
);
- let resp = services::execute_connector_processing_step(
+ let resp = gateway::execute_payment_gateway(
state,
connector_integration,
&createorder_router_data,
payments::CallConnectorAction::Trigger,
None,
None,
+ gateway_context.clone(),
)
.await
.to_payment_failed_response()?;
diff --git a/crates/router/src/core/payments/flows/incremental_authorization_flow.rs b/crates/router/src/core/payments/flows/incremental_authorization_flow.rs
index 423abf5b25..49dd1cc9a3 100644
--- a/crates/router/src/core/payments/flows/incremental_authorization_flow.rs
+++ b/crates/router/src/core/payments/flows/incremental_authorization_flow.rs
@@ -110,12 +110,14 @@ impl Feature<api::IncrementalAuthorization, types::PaymentsIncrementalAuthorizat
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &payments::gateway::context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
diff --git a/crates/router/src/core/payments/flows/post_session_tokens_flow.rs b/crates/router/src/core/payments/flows/post_session_tokens_flow.rs
index bec6c844b5..46d36a8881 100644
--- a/crates/router/src/core/payments/flows/post_session_tokens_flow.rs
+++ b/crates/router/src/core/payments/flows/post_session_tokens_flow.rs
@@ -109,12 +109,14 @@ impl Feature<api::PostSessionTokens, types::PaymentsPostSessionTokensData>
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &payments::gateway::context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
diff --git a/crates/router/src/core/payments/flows/psync_flow.rs b/crates/router/src/core/payments/flows/psync_flow.rs
index a223569519..daf3652734 100644
--- a/crates/router/src/core/payments/flows/psync_flow.rs
+++ b/crates/router/src/core/payments/flows/psync_flow.rs
@@ -185,12 +185,14 @@ impl Feature<api::PSync, types::PaymentsSyncData>
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &payments::gateway::context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
diff --git a/crates/router/src/core/payments/flows/reject_flow.rs b/crates/router/src/core/payments/flows/reject_flow.rs
index ea40276517..7e82a97057 100644
--- a/crates/router/src/core/payments/flows/reject_flow.rs
+++ b/crates/router/src/core/payments/flows/reject_flow.rs
@@ -88,12 +88,14 @@ impl Feature<api::Reject, types::PaymentsRejectData>
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &payments::gateway::context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
diff --git a/crates/router/src/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rs
index 8d5bb90078..3d6dd42229 100644
--- a/crates/router/src/core/payments/flows/session_flow.rs
+++ b/crates/router/src/core/payments/flows/session_flow.rs
@@ -15,7 +15,10 @@ use crate::{
consts::PROTOCOL,
core::{
errors::{self, ConnectorErrorExt, RouterResult},
- payments::{self, access_token, customers, helpers, transformers, PaymentData},
+ payments::{
+ self, access_token, customers, gateway::context as gateway_context, helpers,
+ transformers, PaymentData,
+ },
},
headers, logger,
routes::{self, app::settings, metrics},
@@ -106,7 +109,7 @@ impl Feature<api::Session, types::PaymentsSessionData> for types::PaymentsSessio
business_profile: &domain::Profile,
header_payload: hyperswitch_domain_models::payments::HeaderPayload,
_return_raw_connector_response: Option<bool>,
- _gateway_context: payments::gateway::context::RouterGatewayContext,
+ _gateway_context: gateway_context::RouterGatewayContext,
) -> RouterResult<Self> {
metrics::SESSION_TOKEN_CREATED.add(
1,
@@ -129,12 +132,14 @@ impl Feature<api::Session, types::PaymentsSessionData> for types::PaymentsSessio
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
@@ -143,12 +148,14 @@ impl Feature<api::Session, types::PaymentsSessionData> for types::PaymentsSessio
&self,
state: &routes::SessionState,
connector: &api::ConnectorData,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<Option<String>> {
customers::create_connector_customer(
state,
connector,
self,
types::ConnectorCustomerData::try_from(self)?,
+ gateway_context,
)
.await
}
diff --git a/crates/router/src/core/payments/flows/session_update_flow.rs b/crates/router/src/core/payments/flows/session_update_flow.rs
index 7aa8c6634b..070fb20ad9 100644
--- a/crates/router/src/core/payments/flows/session_update_flow.rs
+++ b/crates/router/src/core/payments/flows/session_update_flow.rs
@@ -107,12 +107,14 @@ impl Feature<api::SdkSessionUpdate, types::SdkPaymentsSessionUpdateData>
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &payments::gateway::context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
diff --git a/crates/router/src/core/payments/flows/setup_mandate_flow.rs b/crates/router/src/core/payments/flows/setup_mandate_flow.rs
index f34cfc2d96..962cfeef46 100644
--- a/crates/router/src/core/payments/flows/setup_mandate_flow.rs
+++ b/crates/router/src/core/payments/flows/setup_mandate_flow.rs
@@ -7,7 +7,7 @@ use common_utils::{id_type, ucs_types};
use error_stack::ResultExt;
use external_services::grpc_client;
use hyperswitch_domain_models::payments as domain_payments;
-use hyperswitch_interfaces::api::ConnectorSpecifications;
+use hyperswitch_interfaces::api::{gateway, ConnectorSpecifications};
use router_env::logger;
use unified_connector_service_client::payments as payments_grpc;
@@ -17,7 +17,8 @@ use crate::{
errors::{ApiErrorResponse, ConnectorErrorExt, RouterResult},
mandate,
payments::{
- self, access_token, customers, helpers, tokenization, transformers, PaymentData,
+ self, access_token, customers, gateway::context as gateway_context, helpers,
+ session_token, tokenization, transformers, PaymentData,
},
unified_connector_service::{
build_unified_connector_service_auth_metadata, get_access_token_from_ucs_response,
@@ -27,10 +28,7 @@ use crate::{
},
routes::SessionState,
services,
- types::{
- self, api, domain,
- transformers::{ForeignFrom, ForeignTryFrom},
- },
+ types::{self, api, domain, transformers::ForeignTryFrom},
};
#[cfg(feature = "v1")]
@@ -119,7 +117,7 @@ impl Feature<api::SetupMandate, types::SetupMandateRequestData> for types::Setup
_business_profile: &domain::Profile,
_header_payload: domain_payments::HeaderPayload,
_return_raw_connector_response: Option<bool>,
- _gateway_context: payments::gateway::context::RouterGatewayContext,
+ gateway_context: gateway_context::RouterGatewayContext,
) -> RouterResult<Self> {
let connector_integration: services::BoxedPaymentConnectorIntegrationInterface<
api::SetupMandate,
@@ -141,13 +139,14 @@ impl Feature<api::SetupMandate, types::SetupMandateRequestData> for types::Setup
}
}
}
- let resp = services::execute_connector_processing_step(
+ let resp = gateway::execute_payment_gateway(
state,
connector_integration,
&self,
call_connector_action.clone(),
connector_request,
None,
+ gateway_context,
)
.await
.to_setup_mandate_failed_response()?;
@@ -160,46 +159,31 @@ impl Feature<api::SetupMandate, types::SetupMandateRequestData> for types::Setup
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
async fn add_session_token<'a>(
- self,
+ &mut self,
state: &SessionState,
connector: &api::ConnectorData,
- ) -> RouterResult<Self>
+ gateway_context: &gateway_context::RouterGatewayContext,
+ ) -> RouterResult<()>
where
Self: Sized,
{
- let connector_integration: services::BoxedPaymentConnectorIntegrationInterface<
- api::AuthorizeSessionToken,
- types::AuthorizeSessionTokenData,
- types::PaymentsResponseData,
- > = connector.connector.get_connector_integration();
- let authorize_data = &types::PaymentsAuthorizeSessionTokenRouterData::foreign_from((
- &self,
- types::AuthorizeSessionTokenData::foreign_from(&self),
- ));
- let resp = services::execute_connector_processing_step(
- state,
- connector_integration,
- authorize_data,
- payments::CallConnectorAction::Trigger,
- None,
- None,
- )
- .await
- .to_payment_failed_response()?;
- let mut router_data = self;
- router_data.session_token = resp.session_token;
- Ok(router_data)
+ self.session_token =
+ session_token::add_session_token_if_needed(self, state, connector, gateway_context)
+ .await?;
+ Ok(())
}
async fn add_payment_method_token<'a>(
@@ -208,6 +192,7 @@ impl Feature<api::SetupMandate, types::SetupMandateRequestData> for types::Setup
connector: &api::ConnectorData,
tokenization_action: &payments::TokenizationAction,
should_continue_payment: bool,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<types::PaymentMethodTokenResult> {
if connector
.connector
@@ -221,6 +206,7 @@ impl Feature<api::SetupMandate, types::SetupMandateRequestData> for types::Setup
self,
types::PaymentMethodTokenizationData::try_from(request)?,
should_continue_payment,
+ gateway_context,
)
.await
} else {
@@ -236,12 +222,14 @@ impl Feature<api::SetupMandate, types::SetupMandateRequestData> for types::Setup
&self,
state: &SessionState,
connector: &api::ConnectorData,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<Option<String>> {
customers::create_connector_customer(
state,
connector,
self,
types::ConnectorCustomerData::try_from(self.request.to_owned())?,
+ gateway_context,
)
.await
}
diff --git a/crates/router/src/core/payments/flows/update_metadata_flow.rs b/crates/router/src/core/payments/flows/update_metadata_flow.rs
index bb8738cf4e..5eb6878f2c 100644
--- a/crates/router/src/core/payments/flows/update_metadata_flow.rs
+++ b/crates/router/src/core/payments/flows/update_metadata_flow.rs
@@ -106,12 +106,14 @@ impl Feature<api::UpdateMetadata, types::PaymentsUpdateMetadataData>
connector: &api::ConnectorData,
_platform: &domain::Platform,
creds_identifier: Option<&str>,
+ gateway_context: &payments::gateway::context::RouterGatewayContext,
) -> RouterResult<types::AddAccessTokenResult> {
Box::pin(access_token::add_access_token(
state,
connector,
self,
creds_identifier,
+ gateway_context,
))
.await
}
diff --git a/crates/router/src/core/payments/gateway.rs b/crates/router/src/core/payments/gateway.rs
index 1765d26041..e54743dd34 100644
--- a/crates/router/src/core/payments/gateway.rs
+++ b/crates/router/src/core/payments/gateway.rs
@@ -6,9 +6,16 @@ pub mod create_order_gateway;
pub mod payment_method_token_create_gateway;
pub mod psync_gateway;
pub mod session_token_gateway;
+pub mod setup_mandate;
use std::sync;
use hyperswitch_domain_models::router_flow_types::payments;
pub static GRANULAR_GATEWAY_SUPPORTED_FLOWS: sync::LazyLock<Vec<&'static str>> =
- sync::LazyLock::new(|| vec![std::any::type_name::<payments::PSync>()]);
+ sync::LazyLock::new(|| {
+ vec![
+ std::any::type_name::<payments::PSync>(),
+ std::any::type_name::<payments::Authorize>(),
+ std::any::type_name::<payments::SetupMandate>(),
+ ]
+ });
diff --git a/crates/router/src/core/payments/gateway/access_token_gateway.rs b/crates/router/src/core/payments/gateway/access_token_gateway.rs
index 16dfeb22bf..0ec6f0b571 100644
--- a/crates/router/src/core/payments/gateway/access_token_gateway.rs
+++ b/crates/router/src/core/payments/gateway/access_token_gateway.rs
@@ -142,16 +142,6 @@ where
)
.attach_printable("Failed to deserialize UCS response")?;
- // Update router_data with access token
- match &access_token_result {
- Ok(access_token) => {
- router_data.access_token = Some(access_token.clone());
- }
- Err(_) => {
- // Error case - access_token remains None
- }
- }
-
router_data.response = access_token_result;
router_data.connector_http_status_code = Some(status_code);
diff --git a/crates/router/src/core/payments/gateway/authorize_gateway.rs b/crates/router/src/core/payments/gateway/authorize_gateway.rs
index 8bde689c67..d2711ca05d 100644
--- a/crates/router/src/core/payments/gateway/authorize_gateway.rs
+++ b/crates/router/src/core/payments/gateway/authorize_gateway.rs
@@ -133,6 +133,7 @@ where
response
});
router_data.response = router_data_response;
+
router_data.amount_captured = payment_authorize_response.captured_amount;
router_data.minor_amount_captured = payment_authorize_response
.minor_captured_amount
@@ -143,11 +144,6 @@ where
.map(|raw_connector_response| raw_connector_response.expose().into());
router_data.connector_http_status_code = Some(ucs_data.status_code);
- // Populate connector_customer_id if present
- ucs_data.connector_customer_id.map(|connector_customer_id| {
- router_data.connector_customer = Some(connector_customer_id);
- });
-
ucs_data.connector_response.map(|customer_response| {
router_data.connector_response = Some(customer_response);
});
diff --git a/crates/router/src/core/payments/gateway/context.rs b/crates/router/src/core/payments/gateway/context.rs
index afc0bec9c3..da2be220fb 100644
--- a/crates/router/src/core/payments/gateway/context.rs
+++ b/crates/router/src/core/payments/gateway/context.rs
@@ -5,8 +5,9 @@
//! connector integration or Unified Connector Service (UCS).
use common_enums::{ExecutionMode, ExecutionPath, GatewaySystem};
+use common_utils::id_type;
use external_services::grpc_client::LineageIds;
-use hyperswitch_domain_models::{payments::HeaderPayload, platform::Platform};
+use hyperswitch_domain_models::{business_profile, payments::HeaderPayload, platform::Platform};
use hyperswitch_interfaces::api::gateway::GatewayContext;
use crate::core::payments::helpers;
@@ -44,18 +45,26 @@ pub struct RouterGatewayContext {
}
impl RouterGatewayContext {
- /// Create a new router gateway context
pub fn new(
platform: Platform,
header_payload: HeaderPayload,
- lineage_ids: LineageIds,
+ business_profile: &business_profile::Profile,
#[cfg(feature = "v1")] merchant_connector_account: helpers::MerchantConnectorAccountType,
#[cfg(feature = "v2")]
merchant_connector_account: hyperswitch_domain_models::merchant_connector_account::MerchantConnectorAccountTypeDetails,
- execution_mode: ExecutionMode,
execution_path: ExecutionPath,
creds_identifier: Option<String>,
) -> Self {
+ let lineage_ids = LineageIds::new(
+ business_profile.merchant_id.clone(),
+ business_profile.get_id().clone(),
+ );
+ let execution_mode = match execution_path {
+ ExecutionPath::UnifiedConnectorService => ExecutionMode::Primary,
+ ExecutionPath::ShadowUnifiedConnectorService => ExecutionMode::Shadow,
+ // ExecutionMode is irrelevant for Direct path in this context
+ ExecutionPath::Direct => ExecutionMode::NotApplicable,
+ };
Self {
platform,
header_payload,
@@ -66,6 +75,26 @@ impl RouterGatewayContext {
creds_identifier,
}
}
+ pub fn direct(
+ platform: Platform,
+ #[cfg(feature = "v1")] merchant_connector_account: helpers::MerchantConnectorAccountType,
+ #[cfg(feature = "v2")]
+ merchant_connector_account: hyperswitch_domain_models::merchant_connector_account::MerchantConnectorAccountTypeDetails,
+ merchant_id: id_type::MerchantId,
+ profile_id: id_type::ProfileId,
+ creds_identifier: Option<String>,
+ ) -> Self {
+ let lineage_ids = LineageIds::new(merchant_id, profile_id);
+ Self {
+ platform,
+ header_payload: HeaderPayload::default(),
+ lineage_ids,
+ merchant_connector_account,
+ execution_mode: ExecutionMode::NotApplicable,
+ execution_path: ExecutionPath::Direct,
+ creds_identifier,
+ }
+ }
}
/// Implementation of GatewayContext trait for RouterGatewayContext
diff --git a/crates/router/src/core/payments/gateway/create_order_gateway.rs b/crates/router/src/core/payments/gateway/create_order_gateway.rs
index 8d34177920..22d315c699 100644
--- a/crates/router/src/core/payments/gateway/create_order_gateway.rs
+++ b/crates/router/src/core/payments/gateway/create_order_gateway.rs
@@ -120,17 +120,14 @@ where
let create_order_response = response.into_inner();
- let (router_data_response, _status_code) =
+ let (router_data_response, status_code) =
handle_unified_connector_service_response_for_create_order(
create_order_response.clone(),
)
.attach_printable("Failed to deserialize UCS response")?;
- let router_data_response = router_data_response.map(|(response, status)| {
- router_data.status = status;
- response
- });
router_data.response = router_data_response;
+ router_data.connector_http_status_code = Some(status_code);
Ok((router_data, create_order_response))
},
))
diff --git a/crates/router/src/core/payments/gateway/payment_method_token_create_gateway.rs b/crates/router/src/core/payments/gateway/payment_method_token_create_gateway.rs
index 854dcbff08..dab3786305 100644
--- a/crates/router/src/core/payments/gateway/payment_method_token_create_gateway.rs
+++ b/crates/router/src/core/payments/gateway/payment_method_token_create_gateway.rs
@@ -134,16 +134,7 @@ where
)
.attach_printable("Failed to deserialize UCS response")?;
- let router_data_response = router_data_response.map(|(response, status)| {
- router_data.status = status;
- response
- });
router_data.response = router_data_response;
- router_data.payment_method_token = Some(
- hyperswitch_domain_models::router_data::PaymentMethodToken::Token(
- masking::Secret::new(pm_token_create_response.payment_method_token.clone()),
- ),
- );
router_data.connector_http_status_code = Some(status_code);
Ok((router_data, pm_token_create_response))
diff --git a/crates/router/src/core/payments/gateway/session_token_gateway.rs b/crates/router/src/core/payments/gateway/session_token_gateway.rs
index 5c985e9cd4..1b3f8e6a10 100644
--- a/crates/router/src/core/payments/gateway/session_token_gateway.rs
+++ b/crates/router/src/core/payments/gateway/session_token_gateway.rs
@@ -129,11 +129,6 @@ where
payment_session_token_response.clone(),
)
.attach_printable("Failed to deserialize UCS response")?;
-
- let router_data_response = router_data_response.map(|(response, status)| {
- router_data.status = status;
- response
- });
router_data.response = router_data_response;
router_data.connector_http_status_code = Some(status_code);
diff --git a/crates/router/src/core/payments/gateway/setup_mandate.rs b/crates/router/src/core/payments/gateway/setup_mandate.rs
index 45d5f8aed5..5efae6b3cf 100644
--- a/crates/router/src/core/payments/gateway/setup_mandate.rs
+++ b/crates/router/src/core/payments/gateway/setup_mandate.rs
@@ -11,16 +11,15 @@ use hyperswitch_interfaces::{
errors::ConnectorError,
};
use unified_connector_service_client::payments as payments_grpc;
-use unified_connector_service_masking::ExposeInterface as UcsMaskingExposeInterface;
use crate::{
core::{
payments::gateway::context::RouterGatewayContext, unified_connector_service,
- unified_connector_service::handle_unified_connector_service_response_for_payment_authorize,
+ unified_connector_service::handle_unified_connector_service_response_for_payment_register,
},
routes::SessionState,
services::logger,
- types::{self, transformers::ForeignTryFrom, MinorUnit},
+ types::{self, transformers::ForeignTryFrom},
};
// =============================================================================
@@ -55,7 +54,7 @@ where
types::PaymentsResponseData,
>,
router_data: &RouterData<Self, types::SetupMandateRequestData, types::PaymentsResponseData>,
- call_connector_action: CallConnectorAction,
+ _call_connector_action: CallConnectorAction,
_connector_request: Option<Request>,
_return_raw_connector_response: Option<bool>,
context: RouterGatewayContext,
@@ -77,12 +76,9 @@ where
.attach_printable("Failed to fetch Unified Connector Service client")?;
let setup_mandate_request =
- payments_grpc::PaymentServiceAuthorizeOnlyRequest::foreign_try_from((
- router_data,
- call_connector_action,
- ))
- .change_context(ConnectorError::RequestEncodingFailed)
- .attach_printable("Failed to construct Payment Get Request")?;
+ payments_grpc::PaymentServiceRegisterRequest::foreign_try_from(router_data)
+ .change_context(ConnectorError::RequestEncodingFailed)
+ .attach_printable("Failed to construct Payment Get Request")?;
let connector_auth_metadata =
unified_connector_service::build_unified_connector_service_auth_metadata(
@@ -122,7 +118,7 @@ where
let setup_mandate_response = response.into_inner();
- let ucs_data = handle_unified_connector_service_response_for_payment_authorize(
+ let ucs_data = handle_unified_connector_service_response_for_payment_register(
setup_mandate_response.clone(),
)
.attach_printable("Failed to deserialize UCS response")?;
@@ -133,14 +129,6 @@ where
response
});
router_data.response = router_data_response;
- router_data.amount_captured = setup_mandate_response.captured_amount;
- router_data.minor_amount_captured = setup_mandate_response
- .minor_captured_amount
- .map(MinorUnit::new);
- router_data.raw_connector_response = setup_mandate_response
- .raw_connector_response
- .clone()
- .map(|raw_connector_response| raw_connector_response.expose().into());
router_data.connector_http_status_code = Some(ucs_data.status_code);
// Populate connector_customer_id if present
@@ -148,10 +136,6 @@ where
router_data.connector_customer = Some(connector_customer_id);
});
- ucs_data.connector_response.map(|customer_response| {
- router_data.connector_response = Some(customer_response);
- });
-
Ok((router_data, setup_mandate_response))
},
))
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 5c9af1db48..02330c3a74 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -12,7 +12,7 @@ use api_models::{
};
use base64::Engine;
#[cfg(feature = "v1")]
-use common_enums::enums::{CallConnectorAction, ExecutionMode, ExecutionPath, GatewaySystem};
+use common_enums::enums::{CallConnectorAction, ExecutionMode, GatewaySystem};
use common_enums::ConnectorType;
#[cfg(feature = "v2")]
use common_utils::id_type::GenerateId;
@@ -8513,19 +8513,14 @@ where
// Update feature metadata to track Direct routing usage for stickiness
update_gateway_system_in_feature_metadata(payment_data, GatewaySystem::Direct)?;
- let lineage_ids = grpc_client::LineageIds::new(
+
+ let gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account.clone(),
business_profile.merchant_id.clone(),
business_profile.get_id().clone(),
+ payment_data.get_creds_identifier().map(str::to_owned),
);
- let gateway_context = gateway_context::RouterGatewayContext {
- creds_identifier: None,
- platform: platform.clone(),
- header_payload: header_payload.clone(),
- lineage_ids,
- merchant_connector_account: merchant_connector_account.clone(),
- execution_path: ExecutionPath::Direct,
- execution_mode: ExecutionMode::NotApplicable,
- };
call_connector_service(
state,
@@ -8633,19 +8628,16 @@ where
business_profile.get_id().clone(),
);
+ let gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account.clone(),
+ business_profile.merchant_id.clone(),
+ business_profile.get_id().clone(),
+ creds_identifier,
+ );
+
// Update feature metadata to track Direct routing usage for stickiness
update_gateway_system_in_feature_metadata(payment_data, GatewaySystem::Direct)?;
- let execution_mode = ExecutionMode::NotApplicable;
-
- let gateway_context = gateway_context::RouterGatewayContext {
- creds_identifier: payment_data.get_creds_identifier().map(|id| id.to_string()),
- platform: platform.clone(),
- header_payload: header_payload.clone(),
- lineage_ids: lineage_ids.clone(),
- merchant_connector_account: merchant_connector_account.clone(),
- execution_path: ExecutionPath::Direct,
- execution_mode,
- };
// Call Direct connector service
let result = call_connector_service(
diff --git a/crates/router/src/core/payments/session_token.rs b/crates/router/src/core/payments/session_token.rs
new file mode 100644
index 0000000000..d22453cc79
--- /dev/null
+++ b/crates/router/src/core/payments/session_token.rs
@@ -0,0 +1,76 @@
+use std::fmt::Debug;
+
+use common_enums::enums;
+use error_stack::{report, ResultExt};
+use hyperswitch_interfaces::api::{gateway, ConnectorSpecifications};
+
+use crate::{
+ core::{
+ errors,
+ errors::utils::ConnectorErrorExt,
+ payments::{gateway::context as gateway_context, RouterResult},
+ },
+ logger, routes, services, types,
+ types::{api as api_types, transformers::ForeignFrom},
+};
+
+pub(crate) async fn add_session_token_if_needed<F: Clone, Req: Debug + Clone>(
+ router_data: &types::RouterData<F, Req, types::PaymentsResponseData>,
+ state: &routes::SessionState,
+ connector: &api_types::ConnectorData,
+ gateway_context: &gateway_context::RouterGatewayContext,
+) -> RouterResult<Option<String>>
+where
+ types::AuthorizeSessionTokenData:
+ for<'a> ForeignFrom<&'a types::RouterData<F, Req, types::PaymentsResponseData>>,
+{
+ if connector
+ .connector
+ .is_authorize_session_token_call_required()
+ {
+ let connector_integration: services::BoxedPaymentConnectorIntegrationInterface<
+ api_types::AuthorizeSessionToken,
+ types::AuthorizeSessionTokenData,
+ types::PaymentsResponseData,
+ > = connector.connector.get_connector_integration();
+ let authorize_session_token_router_data =
+ &types::PaymentsAuthorizeSessionTokenRouterData::foreign_from((
+ router_data,
+ types::AuthorizeSessionTokenData::foreign_from(router_data),
+ ));
+ let resp = gateway::execute_payment_gateway(
+ state,
+ connector_integration,
+ authorize_session_token_router_data,
+ enums::CallConnectorAction::Trigger,
+ None,
+ None,
+ gateway_context.clone(),
+ )
+ .await
+ .to_payment_failed_response()?;
+ let session_token_respone = resp
+ .response
+ .map_err(|error| {
+ logger::error!(session_token_create_error = error.reason);
+ report!(errors::ApiErrorResponse::PreconditionFailed {
+ message: "Faied to perform session token call".to_string()
+ })
+ })
+ .attach_printable(format!(
+ "Failed to create session token for connector: {:?}",
+ connector.connector
+ ))?;
+ let session_token = match session_token_respone {
+ types::PaymentsResponseData::SessionTokenResponse { session_token } => {
+ Ok(session_token)
+ }
+ _ => Err(report!(errors::ApiErrorResponse::InternalServerError)).attach_printable(
+ "Found Unexpected Response for Authorize Session Token Response from Connector",
+ ),
+ }?;
+ Ok(Some(session_token))
+ } else {
+ Ok(None)
+ }
+}
diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs
index 9881e64b11..6221b087b4 100644
--- a/crates/router/src/core/payments/tokenization.rs
+++ b/crates/router/src/core/payments/tokenization.rs
@@ -23,6 +23,7 @@ use hyperswitch_domain_models::{
mandates::{CommonMandateReference, PaymentsMandateReference, PaymentsMandateReferenceRecord},
payment_method_data,
};
+use hyperswitch_interfaces::api::gateway;
use masking::{ExposeInterface, Secret};
use router_env::{instrument, tracing};
@@ -41,7 +42,7 @@ use crate::{
cards::{create_encrypted_data, PmCards},
network_tokenization,
},
- payments,
+ payments::{self, gateway::context as gateway_context},
},
logger,
routes::{metrics, SessionState},
@@ -1400,6 +1401,7 @@ pub async fn add_payment_method_token<F: Clone, T: types::Tokenizable + Clone>(
router_data: &mut types::RouterData<F, T, types::PaymentsResponseData>,
pm_token_request_data: types::PaymentMethodTokenizationData,
should_continue_payment: bool,
+ gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<types::PaymentMethodTokenResult> {
if should_continue_payment {
match tokenization_action {
@@ -1426,13 +1428,14 @@ pub async fn add_payment_method_token<F: Clone, T: types::Tokenizable + Clone>(
.request
.set_session_token(pm_token_router_data.session_token.clone());
- let mut resp = services::execute_connector_processing_step(
+ let mut resp = gateway::execute_payment_gateway(
state,
connector_integration,
&pm_token_router_data,
payments::CallConnectorAction::Trigger,
None,
None,
+ gateway_context.clone(),
)
.await
.to_payment_failed_response()?;
diff --git a/crates/router/src/core/payments/vault_session.rs b/crates/router/src/core/payments/vault_session.rs
index b9c460c33f..fb201aecb6 100644
--- a/crates/router/src/core/payments/vault_session.rs
+++ b/crates/router/src/core/payments/vault_session.rs
@@ -26,6 +26,7 @@ use crate::{
payments::{
self as payments_core, call_multiple_connectors_service, customers,
flows::{ConstructFlowSpecificData, Feature},
+ gateway::context as gateway_context,
helpers, helpers as payment_helpers, operations,
operations::{BoxedOperation, Operation},
transformers, OperationSessionGetters, OperationSessionSetters,
@@ -149,7 +150,14 @@ where
{
let db_merchant_connector_account =
merchant_connector_account_type.get_inner_db_merchant_connector_account();
-
+ let profile_id = payment_data.get_payment_intent().profile_id.clone();
+ let default_gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account_type.clone(),
+ payment_data.get_payment_intent().merchant_id.clone(),
+ profile_id,
+ payment_data.get_creds_identifier().map(|id| id.to_string()),
+ );
match db_merchant_connector_account {
Some(merchant_connector_account) => {
let connector_name = merchant_connector_account.get_connector_name_as_string();
@@ -185,7 +193,7 @@ where
.await?;
let connector_customer_id = router_data
- .create_connector_customer(state, &connector)
+ .create_connector_customer(state, &connector, &default_gateway_context)
.await?;
let customer_update = customers::update_connector_customer_in_customers(
diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rs
index 361ade40aa..5871d9938d 100644
--- a/crates/router/src/core/refunds.rs
+++ b/crates/router/src/core/refunds.rs
@@ -25,7 +25,10 @@ use crate::{
consts,
core::{
errors::{self, ConnectorErrorExt, RouterResponse, RouterResult, StorageErrorExt},
- payments::{self, access_token, helpers, helpers::MerchantConnectorAccountType},
+ payments::{
+ self, access_token, gateway::context as gateway_context, helpers,
+ helpers::MerchantConnectorAccountType,
+ },
refunds::transformers::SplitRefundInput,
unified_connector_service,
utils::{
@@ -206,12 +209,21 @@ pub async fn trigger_refund_to_gateway(
)
.await?;
+ let gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account.clone(),
+ payment_intent.merchant_id.clone(),
+ profile_id.clone(),
+ creds_identifier.clone(),
+ );
+
// Add access token for both UCS and direct connector paths
let add_access_token_result = Box::pin(access_token::add_access_token(
state,
&connector,
&router_data,
creds_identifier.as_deref(),
+ &gateway_context,
))
.await?;
@@ -820,12 +832,21 @@ pub async fn sync_refund_with_gateway(
)
.await?;
+ let gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account.clone(),
+ payment_intent.merchant_id.clone(),
+ profile_id.clone(),
+ creds_identifier.clone(),
+ );
+
// Add access token for both UCS and direct connector paths
let add_access_token_result = Box::pin(access_token::add_access_token(
state,
&connector,
&router_data,
creds_identifier.as_deref(),
+ &gateway_context,
))
.await?;
diff --git a/crates/router/src/core/refunds_v2.rs b/crates/router/src/core/refunds_v2.rs
index ed0244966a..1c397e5067 100644
--- a/crates/router/src/core/refunds_v2.rs
+++ b/crates/router/src/core/refunds_v2.rs
@@ -20,7 +20,7 @@ use crate::{
consts,
core::{
errors::{self, ConnectorErrorExt, StorageErrorExt},
- payments::{self, access_token, helpers},
+ payments::{self, access_token, gateway::context as gateway_context, helpers},
utils::{self as core_utils, refunds_validator},
},
db, logger,
@@ -163,12 +163,21 @@ pub async fn trigger_refund_to_gateway(
&merchant_connector_account,
)
.await?;
+ let profile_id = payment_intent.profile_id.clone();
+ let default_gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account,
+ payment_intent.merchant_id.clone(),
+ profile_id,
+ None,
+ );
let add_access_token_result = Box::pin(access_token::add_access_token(
state,
&connector,
&router_data,
None,
+ &default_gateway_context,
))
.await?;
@@ -276,11 +285,21 @@ pub async fn internal_trigger_refund_to_gateway(
)
.await?;
+ let profile_id = payment_intent.profile_id.clone();
+ let default_gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account,
+ payment_intent.merchant_id.clone(),
+ profile_id,
+ None,
+ );
+
let add_access_token_result = Box::pin(access_token::add_access_token(
state,
&connector,
&router_data,
None,
+ &default_gateway_context,
))
.await?;
@@ -824,12 +843,21 @@ pub async fn sync_refund_with_gateway(
&merchant_connector_account,
)
.await?;
+ let profile_id = payment_intent.profile_id.clone();
+ let default_gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account,
+ payment_intent.merchant_id.clone(),
+ profile_id,
+ None,
+ );
let add_access_token_result = Box::pin(access_token::add_access_token(
state,
&connector,
&router_data,
None,
+ &default_gateway_context,
))
.await?;
@@ -911,12 +939,21 @@ pub async fn internal_sync_refund_with_gateway(
&merchant_connector_account,
)
.await?;
+ let profile_id = payment_intent.profile_id.clone();
+ let default_gateway_context = gateway_context::RouterGatewayContext::direct(
+ platform.clone(),
+ merchant_connector_account,
+ payment_intent.merchant_id.clone(),
+ profile_id,
+ None,
+ );
let add_access_token_result = Box::pin(access_token::add_access_token(
state,
&connector,
&router_data,
None,
+ &default_gateway_context,
))
.await?;
diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rs
index 4cc4bf5965..97b1d4b9ba 100644
--- a/crates/router/src/core/unified_connector_service.rs
+++ b/crates/router/src/core/unified_connector_service.rs
@@ -1171,11 +1171,12 @@ pub fn handle_unified_connector_service_response_for_create_connector_customer(
pub fn handle_unified_connector_service_response_for_create_order(
response: payments_grpc::PaymentServiceCreateOrderResponse,
-) -> UnifiedConnectorServiceResult {
+) -> CustomResult<(Result<PaymentsResponseData, ErrorResponse>, u16), UnifiedConnectorServiceError>
+{
let status_code = transformers::convert_connector_service_status_code(response.status_code)?;
let router_data_response =
- Result::<(PaymentsResponseData, AttemptStatus), ErrorResponse>::foreign_try_from(response)?;
+ Result::<PaymentsResponseData, ErrorResponse>::foreign_try_from(response)?;
Ok((router_data_response, status_code))
}
@@ -1193,11 +1194,12 @@ pub fn handle_unified_connector_service_response_for_payment_post_authenticate(
pub fn handle_unified_connector_service_response_for_payment_method_token_create(
response: payments_grpc::PaymentServiceCreatePaymentMethodTokenResponse,
-) -> UnifiedConnectorServiceResult {
+) -> CustomResult<(Result<PaymentsResponseData, ErrorResponse>, u16), UnifiedConnectorServiceError>
+{
let status_code = transformers::convert_connector_service_status_code(response.status_code)?;
let router_data_response =
- Result::<(PaymentsResponseData, AttemptStatus), ErrorResponse>::foreign_try_from(response)?;
+ Result::<PaymentsResponseData, ErrorResponse>::foreign_try_from(response)?;
Ok((router_data_response, status_code))
}
@@ -1260,11 +1262,12 @@ pub fn handle_unified_connector_service_response_for_payment_register(
pub fn handle_unified_connector_service_response_for_session_token_create(
response: payments_grpc::PaymentServiceCreateSessionTokenResponse,
-) -> UnifiedConnectorServiceResult {
+) -> CustomResult<(Result<PaymentsResponseData, ErrorResponse>, u16), UnifiedConnectorServiceError>
+{
let status_code = transformers::convert_connector_service_status_code(response.status_code)?;
let router_data_response =
- Result::<(PaymentsResponseData, AttemptStatus), ErrorResponse>::foreign_try_from(response)?;
+ Result::<PaymentsResponseData, ErrorResponse>::foreign_try_from(response)?;
Ok((router_data_response, status_code))
}
diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rs
index 2b15c7b02b..dd7370ba25 100644
--- a/crates/router/src/core/unified_connector_service/transformers.rs
+++ b/crates/router/src/core/unified_connector_service/transformers.rs
@@ -280,6 +280,7 @@ impl
.map(ConnectorState::foreign_from);
Ok(Self {
+ order_id: router_data.request.order_id.clone(),
amount: router_data.request.amount,
currency: currency.into(),
payment_method,
@@ -345,7 +346,6 @@ impl
.as_ref()
.and_then(|pmt| pmt.get_payment_method_token())
.map(ExposeInterface::expose),
- access_token: None,
merchant_account_metadata,
description: router_data.description.clone(),
setup_mandate_details: router_data
@@ -425,7 +425,7 @@ impl
),
) -> Result<Self, Self::Error> {
let request_ref_id = router_data.connector_request_reference_id.clone();
-
+ let address = payments_grpc::PaymentAddress::foreign_try_from(router_data.address.clone())?;
Ok(Self {
request_ref_id: Some(Identifier {
id_type: Some(payments_grpc::identifier::IdType::Id(request_ref_id)),
@@ -446,7 +446,7 @@ impl
.phone
.as_ref()
.map(|phone| phone.peek().to_string()),
- address: None,
+ address: Some(address),
metadata: HashMap::new(),
})
}
@@ -846,6 +846,7 @@ impl transformers::ForeignTryFrom<&RouterData<Capture, PaymentsCaptureData, Paym
.transpose()?;
Ok(Self {
+ merchant_reference_payment_id: None,
transaction_id: Some(Identifier {
id_type: Some(payments_grpc::identifier::IdType::Id(
connector_transaction_id,
@@ -1375,6 +1376,14 @@ impl
.map(ConnectorState::foreign_from);
Ok(Self {
+ payment_method_token: router_data.payment_method_token.as_ref().and_then(|payment_method_token|{
+ match payment_method_token {
+ hyperswitch_domain_models::router_data::PaymentMethodToken::Token(secret_token) => Some(secret_token.peek().clone()),
+ hyperswitch_domain_models::router_data::PaymentMethodToken::ApplePayDecrypt(_) |
+ hyperswitch_domain_models::router_data::PaymentMethodToken::GooglePayDecrypt(_) |
+ hyperswitch_domain_models::router_data::PaymentMethodToken::PazeDecrypt(_) => None
+ }
+ }),
request_ref_id: Some(Identifier {
id_type: Some(payments_grpc::identifier::IdType::Id(
router_data.connector_request_reference_id.clone(),
@@ -1429,6 +1438,7 @@ impl
request_extended_authorization: None,
customer_acceptance,
browser_info,
+ order_id: None,
payment_experience: None,
merchant_account_metadata: router_data
.connector_meta_data
@@ -2827,7 +2837,7 @@ impl ForeignFrom<common_enums::TransactionStatus> for payments_grpc::Transaction
}
impl transformers::ForeignTryFrom<payments_grpc::PaymentServiceCreateOrderResponse>
- for Result<(PaymentsResponseData, AttemptStatus), ErrorResponse>
+ for Result<PaymentsResponseData, ErrorResponse>
{
type Error = error_stack::Report<UnifiedConnectorServiceError>;
@@ -2864,10 +2874,7 @@ impl transformers::ForeignTryFrom<payments_grpc::PaymentServiceCreateOrderRespon
// For order creation, we typically return a successful response with the order_id
// Since this is not a standard payment response, we'll create a simple success response
- Ok((
- PaymentsResponseData::PaymentsCreateOrderResponse { order_id },
- AttemptStatus::Charged, // Assuming successful creation
- ))
+ Ok(PaymentsResponseData::PaymentsCreateOrderResponse { order_id })
};
Ok(response)
@@ -2875,7 +2882,7 @@ impl transformers::ForeignTryFrom<payments_grpc::PaymentServiceCreateOrderRespon
}
impl transformers::ForeignTryFrom<payments_grpc::PaymentServiceCreatePaymentMethodTokenResponse>
- for Result<(PaymentsResponseData, AttemptStatus), ErrorResponse>
+ for Result<PaymentsResponseData, ErrorResponse>
{
type Error = error_stack::Report<UnifiedConnectorServiceError>;
@@ -2898,14 +2905,9 @@ impl transformers::ForeignTryFrom<payments_grpc::PaymentServiceCreatePaymentMeth
connector_metadata: None,
})
} else {
- // For connector PM token creation, we typically return a successful response with the connector payment method
- // Since this is not a standard payment response, we'll create a simple success response
- Ok((
- PaymentsResponseData::TokenizationResponse {
- token: response.payment_method_token,
- },
- AttemptStatus::Charged, // Assuming successful creation
- ))
+ Ok(PaymentsResponseData::TokenizationResponse {
+ token: response.payment_method_token,
+ })
};
Ok(response)
@@ -3071,7 +3073,7 @@ impl transformers::ForeignTryFrom<&MandateData> for payments_grpc::SetupMandateD
}
impl transformers::ForeignTryFrom<payments_grpc::PaymentServiceCreateSessionTokenResponse>
- for Result<(PaymentsResponseData, AttemptStatus), ErrorResponse>
+ for Result<PaymentsResponseData, ErrorResponse>
{
type Error = error_stack::Report<UnifiedConnectorServiceError>;
@@ -3094,14 +3096,9 @@ impl transformers::ForeignTryFrom<payments_grpc::PaymentServiceCreateSessionToke
connector_metadata: None,
})
} else {
- // For session token creation, we typically return a successful response with the session token
- // Since this is not a standard payment response, we'll create a simple success response
- Ok((
- PaymentsResponseData::SessionTokenResponse {
- session_token: response.session_token.clone(),
- },
- AttemptStatus::Charged, // Assuming successful creation
- ))
+ Ok(PaymentsResponseData::SessionTokenResponse {
+ session_token: response.session_token.clone(),
+ })
};
Ok(response)