Skip to content

Commit

Permalink
feat(core): Constraint Graph for Payment Methods List (#5081)
Browse files Browse the repository at this point in the history
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
prajjwalkumar17 and hyperswitch-bot[bot] authored Jul 9, 2024
1 parent fdac313 commit 82c6e0e
Show file tree
Hide file tree
Showing 17 changed files with 1,286 additions and 539 deletions.
2 changes: 2 additions & 0 deletions crates/euclid/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ pub enum MandateAcceptanceType {
pub enum PaymentType {
SetupMandate,
NonMandate,
NewMandate,
UpdateMandate,
}

#[derive(
Expand Down
20 changes: 4 additions & 16 deletions crates/hyperswitch_constraint_graph/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ where
nodes: &[(NodeId, Relation, Strength)],
info: Option<&'static str>,
metadata: Option<M>,
domain: Option<String>,
domain_id: Option<DomainId>,
) -> Result<NodeId, GraphError<V>> {
nodes
.iter()
Expand All @@ -208,13 +208,7 @@ where
.push(metadata.map(|meta| -> Arc<dyn Metadata> { Arc::new(meta) }));

for (node_id, relation, strength) in nodes {
self.make_edge(
*node_id,
aggregator_id,
*strength,
*relation,
domain.clone(),
)?;
self.make_edge(*node_id, aggregator_id, *strength, *relation, domain_id)?;
}

Ok(aggregator_id)
Expand All @@ -225,7 +219,7 @@ where
nodes: &[(NodeId, Relation, Strength)],
info: Option<&'static str>,
metadata: Option<M>,
domain: Option<String>,
domain_id: Option<DomainId>,
) -> Result<NodeId, GraphError<V>> {
nodes
.iter()
Expand All @@ -239,13 +233,7 @@ where
.push(metadata.map(|meta| -> Arc<dyn Metadata> { Arc::new(meta) }));

for (node_id, relation, strength) in nodes {
self.make_edge(
*node_id,
aggregator_id,
*strength,
*relation,
domain.clone(),
)?;
self.make_edge(*node_id, aggregator_id, *strength, *relation, domain_id)?;
}

Ok(aggregator_id)
Expand Down
8 changes: 0 additions & 8 deletions crates/hyperswitch_constraint_graph/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,6 @@ impl From<String> for DomainIdentifier {
}
}

// impl Deref for DomainIdentifier {
// type Target = &String;
//
// fn deref(&self) -> Self::Target {
// self.0
// }
// }

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DomainInfo {
pub domain_identifier: DomainIdentifier,
Expand Down
2 changes: 2 additions & 0 deletions crates/kgraph_utils/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use euclid::{dssa::types::AnalysisErrorType, frontend::dir};
pub enum KgraphError {
#[error("Invalid connector name encountered: '{0}'")]
InvalidConnectorName(String),
#[error("Error in domain creation")]
DomainCreationError,
#[error("There was an error constructing the graph: {0}")]
GraphConstructionError(hyperswitch_constraint_graph::GraphError<dir::DirValue>),
#[error("There was an error constructing the context")]
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/payment_methods.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod cards;
pub mod surcharge_decision_configs;
pub mod transformers;
pub mod utils;
pub mod vault;
pub use api_models::enums::Connector;
#[cfg(feature = "payouts")]
Expand Down
Loading

0 comments on commit 82c6e0e

Please sign in to comment.