-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: add routing support for v2 sdk session flow #6763
base: main
Are you sure you want to change the base?
Conversation
…trackers during session token flow
…lementation of PaymentSessionIntent
…or-v2-sdk-session-flow
…or-v2-sdk-session-flow
…or-v2-sdk-session-flow
…or-v2-sdk-session-flow
…or-v2-sdk-session-flow
let chosen_connectors = if let Some(ref algorithm_id) = algorithm_id { | ||
let cached_algorithm = ensure_algorithm_cached_v1( | ||
&session_pm_input.state.clone(), | ||
merchant_id, | ||
algorithm_id, | ||
session_pm_input.profile_id, | ||
transaction_type, | ||
) | ||
.await?; | ||
|
||
match cached_algorithm.as_ref() { | ||
CachedAlgorithm::Single(conn) => vec![(**conn).clone()], | ||
CachedAlgorithm::Priority(plist) => plist.clone(), | ||
CachedAlgorithm::VolumeSplit(splits) => perform_volume_split(splits.to_vec()) | ||
.change_context(errors::RoutingError::ConnectorSelectionFailed)?, | ||
CachedAlgorithm::Advanced(interpreter) => execute_dsl_and_get_connector_v1( | ||
session_pm_input.backend_input.clone(), | ||
interpreter, | ||
)?, | ||
} | ||
} else { | ||
profile_wrapper | ||
.get_default_fallback_list_of_connector_under_profile() | ||
.change_context(errors::RoutingError::FallbackConfigFetchFailed)? | ||
}; |
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.
Instead of writing a if else, use a function call here which return the required value and move the logic to a function. Avoid writing if else in the flows instead flow a function based approach.
.await?; | ||
|
||
if final_selection.is_empty() { | ||
let fallback = profile_wrapper |
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.
chosen_connectors
itself derived from get_default_fallback_list_of_connector_under_profile
if algorithm_id not present, how the below cases is different from that?
.payment_intent | ||
.metadata | ||
.clone() | ||
.map(|val| val.parse_value("routing_parameters")) |
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.
make this as impl based function
@@ -534,9 +534,10 @@ pub struct PaymentIntentUpdateFields { | |||
#[diesel(table_name = payment_intent)] | |||
pub struct PaymentIntentUpdateInternal { | |||
pub status: Option<storage_enums::IntentStatus>, | |||
pub active_attempt_id: Option<common_utils::id_type::GlobalAttemptId>, | |||
pub prerouting_algorithm: Option<serde_json::Value>, |
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.
What is reason for making this as algorithm instead of algorithm id?
And why we need to make this as UnTyped Value?
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.
prerouting_algorithm is actually the result after running routing algorithm.
pub state: &'a SessionState, | ||
pub country: Option<CountryAlpha2>, | ||
pub key_store: &'a domain::MerchantKeyStore, | ||
pub merchant_account: &'a domain::MerchantAccount, | ||
pub payment_intent: &'a oss_storage::PaymentIntent, | ||
pub chosen: api::SessionConnectorDatas, |
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.
only chosen, country and individual fields from payment intent should be present here.
// Store the routing results in payment intent | ||
payment_data.payment_intent.prerouting_algorithm = Some( | ||
pre_routing | ||
.encode_to_value() |
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.
should be strict type in payment intent domain type.
…or-v2-sdk-session-flow
Type of Change
Description
Added session routing support for session call in v2. And store the prerouting results in the payment_intent tabled prerouting_algorithm column.
Other changes:
MerchantConnectorAccounts
Wrapper instead ofVec<MerchantConnectorAccount>
across the codebase.Additional Changes
Motivation and Context
How did you test it?
follow the steps mentioned in this PR.
#6502
In addition to that check if
prerouting_algorithm
column inpayment_intent
is updated.use this query.
select prerouting_algorithm from payment_intent where id ='payment_id';
Checklist
cargo +nightly fmt --all
cargo clippy