-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat: list for dynamic routing #8111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Changed Files
|
…/hyperswitch into feat_dynamic_routing_requirements
let dynamic_routing_ref: routing_types::DynamicRoutingAlgorithmRef = business_profile | ||
.dynamic_routing_algorithm | ||
.clone() | ||
.map(|val| val.parse_value("DynamicRoutingAlgorithmRef")) | ||
.transpose() | ||
.change_context(errors::ApiErrorResponse::InternalServerError) | ||
.attach_printable( | ||
"unable to deserialize dynamic routing algorithm ref from business profile", | ||
)? | ||
.unwrap_or_default(); | ||
|
||
// Collect all dynamic algorithm IDs | ||
let mut dynamic_algorithm_ids = Vec::new(); | ||
|
||
if let Some(sba) = &dynamic_routing_ref.success_based_algorithm { | ||
if let Some(id) = &sba.algorithm_id_with_timestamp.algorithm_id { | ||
dynamic_algorithm_ids.push(id.clone()); | ||
} | ||
} | ||
if let Some(era) = &dynamic_routing_ref.elimination_routing_algorithm { | ||
if let Some(id) = &era.algorithm_id_with_timestamp.algorithm_id { | ||
dynamic_algorithm_ids.push(id.clone()); | ||
} | ||
} | ||
if let Some(cbr) = &dynamic_routing_ref.contract_based_routing { | ||
if let Some(id) = &cbr.algorithm_id_with_timestamp.algorithm_id { | ||
dynamic_algorithm_ids.push(id.clone()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be made parallel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure this can be taken up in another PR.
cc: @GauravRawat369
…/hyperswitch into feat_dynamic_routing_requirements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compatibility api changes LGTM!
…ordea-sepa * 'main' of github.com:juspay/hyperswitch: (30 commits) chore(version): 2025.05.30.0 chore(ci): update postman ci credentials (#8172) chore(docs): remove old add_connector.md file (#8143) refactor: Payment Attempt as mandatory field in PaymentStatusData (#8126) fix(payment_link): sanitize embedded payment link data (#7736) chore(version): 2025.05.29.0 feat(analytics): Add ckh columns for 3ds intelligence analytics (#8136) refactor(debit_routing): Handle missing merchant_business_country by defaulting to US (#8141) chore(version): 2025.05.28.0 refactor(success_based): add support for exploration (#8158) feat(dynamic_routing): add get api for dynamic routing volume split (#8114) fix: incorrect payout_method_id in payouts table (#8107) feat(router): Enable client_secret auth for payments_get_intent [v2] (#8119) chore: address Rust 1.87.0 clippy lints (#8130) feat: list for dynamic routing (#8111) ci(cypress): fix mandates unsupported connectors (#8086) feat(connector): [Barclaycard] Implement Cards - Non 3DS flow (#8068) fix(authentication): add Organization context validation in `Merchant Create` and `Merchant List` APIs (#8103) feat(connector): [Worldpayxml] add card payment (#8076) feat(connector): Stripe revolut pay wallet integration (#8066) ...
Type of Change
Description
This PR introduces support for listing both static and dynamic routing algorithms under a unified API interface. To accomplish this, it refactors how routing algorithms are represented and parsed, introducing clear separation between
StaticRoutingAlgorithm
andDynamicRoutingAlgorithm
. The new enumRoutingAlgorithmWrapper
is used to encapsulate both types.Dynamic routing strategies like
EliminationBasedAlgorithm
,SuccessBasedAlgorithm
, andContractBasedAlgorithm
are now modeled and tracked similarly to static rules, allowing for consistent listing and configuration.Outcomes
Diff Hunk Explanation
api_models/src/routing.rs
StaticRoutingAlgorithm
,DynamicRoutingAlgorithm
, andRoutingAlgorithmWrapper
enums to distinguish algorithm types.StaticRoutingAlgorithm
instead of the genericRoutingAlgorithm
.#[serde(untagged)]
for backward-compatible JSON parsing.api_models/src/events/routing.rs
RoutingVolumeSplit
for event logging viaApiEventMetric
.router/src/core/routing.rs
retrieve_linked_routing_config
, extended logic to resolve dynamic routing references and list their metadata.router/src/core/routing/helpers.rs
StaticRoutingAlgorithm
.router/src/core/payments/routing.rs
StaticRoutingAlgorithm
.transformers.rs
,admin.rs
,payments.rs
, andstripe/types.rs
StaticRoutingAlgorithm
.Additional Changes
Motivation and Context
How did you test it?
Curls for testing the flows:
Response
Response:
Response:
Response:
Response
toggle SR, toggle ER
create a static rule and activate it
Response
3 values should come
Checklist
cargo +nightly fmt --all
cargo clippy