Skip to content

Commit 73b8988

Browse files
authored
refactor(router): include payment method type in connector choice for session flow (#1036)
1 parent ab55d21 commit 73b8988

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/router/src/core/payments.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,8 +1032,13 @@ where
10321032

10331033
let connector = if should_call_connector(operation, payment_data) {
10341034
Some(match connector_choice {
1035-
api::ConnectorChoice::SessionMultiple(connectors) => {
1036-
api::ConnectorCallType::Multiple(connectors)
1035+
api::ConnectorChoice::SessionMultiple(session_connectors) => {
1036+
api::ConnectorCallType::Multiple(
1037+
session_connectors
1038+
.into_iter()
1039+
.map(|c| c.connector)
1040+
.collect(),
1041+
)
10371042
}
10381043

10391044
api::ConnectorChoice::StraightThrough(straight_through) => connector_selection(

crates/router/src/core/payments/operations/payment_session.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,10 @@ where
350350
connector_and_payment_method_type.0.as_str(),
351351
api::GetToken::from(connector_and_payment_method_type.1),
352352
)?;
353-
connectors_data.push(connector_details);
353+
connectors_data.push(api::SessionConnectorData {
354+
payment_method_type,
355+
connector: connector_details,
356+
});
354357
}
355358
}
356359
}
@@ -364,7 +367,10 @@ where
364367
connector_and_payment_method_type.0.as_str(),
365368
api::GetToken::from(connector_and_payment_method_type.1),
366369
)?;
367-
connectors_data.push(connector_details);
370+
connectors_data.push(api::SessionConnectorData {
371+
payment_method_type: connector_and_payment_method_type.1,
372+
connector: connector_details,
373+
});
368374
}
369375
connectors_data
370376
};

crates/router/src/types/api.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,14 @@ pub struct ConnectorData {
150150
pub get_token: GetToken,
151151
}
152152

153+
#[derive(Clone)]
154+
pub struct SessionConnectorData {
155+
pub payment_method_type: api_enums::PaymentMethodType,
156+
pub connector: ConnectorData,
157+
}
158+
153159
pub enum ConnectorChoice {
154-
SessionMultiple(Vec<ConnectorData>),
160+
SessionMultiple(Vec<SessionConnectorData>),
155161
StraightThrough(serde_json::Value),
156162
Decide,
157163
}

0 commit comments

Comments
 (0)