Skip to content

Commit

Permalink
refactor(constraint_graph): add setup_future_usage for mandate check …
Browse files Browse the repository at this point in the history
…in payments
  • Loading branch information
prajjwalkumar17 committed Dec 4, 2024
1 parent 3a3e93c commit 41206ef
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion crates/router/src/core/payment_methods/cards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4559,6 +4559,12 @@ pub async fn filter_payment_methods(
if payment_attempt
.and_then(|attempt| attempt.mandate_details.as_ref())
.is_some()
|| payment_intent
.and_then(|intent| intent.setup_future_usage)
.map(|future_usage| {
future_usage == common_enums::FutureUsage::OffSession
})
.unwrap_or(false)
{
context_values.push(dir::DirValue::PaymentType(
euclid::enums::PaymentType::NewMandate,
Expand All @@ -4577,7 +4583,14 @@ pub async fn filter_payment_methods(

payment_attempt
.map(|attempt| {
attempt.mandate_data.is_none() && attempt.mandate_details.is_none()
attempt.mandate_data.is_none()
&& attempt.mandate_details.is_none()
&& payment_intent
.and_then(|intent| intent.setup_future_usage)
.map(|future_usage| {
future_usage == common_enums::FutureUsage::OnSession
})
.unwrap_or(false)
})
.and_then(|res| {
res.then(|| {
Expand Down

0 comments on commit 41206ef

Please sign in to comment.