Skip to content

Commit 29f8732

Browse files
fix(payment_methods): set requires_cvv to false when either connector_mandate_details or network_transaction_id is present during MITs (#5331)
1 parent 23bfceb commit 29f8732

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

crates/router/src/core/payment_methods/cards.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3744,6 +3744,11 @@ pub async fn list_customer_payment_method(
37443744
)
37453745
.await?;
37463746

3747+
let is_connector_agnostic_mit_enabled = business_profile
3748+
.as_ref()
3749+
.and_then(|business_profile| business_profile.is_connector_agnostic_mit_enabled)
3750+
.unwrap_or(false);
3751+
37473752
for pm in resp.into_iter() {
37483753
let parent_payment_method_token = generate_id(consts::ID_LENGTH, "token");
37493754

@@ -3861,9 +3866,20 @@ pub async fn list_customer_payment_method(
38613866
state,
38623867
&key_store,
38633868
&merchant_account.merchant_id,
3869+
is_connector_agnostic_mit_enabled,
38643870
connector_mandate_details,
3871+
pm.network_transaction_id.as_ref(),
38653872
)
38663873
.await?;
3874+
3875+
let requires_cvv = if is_connector_agnostic_mit_enabled {
3876+
requires_cvv
3877+
&& !(off_session_payment_flag
3878+
&& (pm.connector_mandate_details.is_some()
3879+
|| pm.network_transaction_id.is_some()))
3880+
} else {
3881+
requires_cvv && !(off_session_payment_flag && pm.connector_mandate_details.is_some())
3882+
};
38673883
// Need validation for enabled payment method ,querying MCA
38683884
let pma = api::CustomerPaymentMethod {
38693885
payment_token: parent_payment_method_token.to_owned(),
@@ -3883,8 +3899,7 @@ pub async fn list_customer_payment_method(
38833899
bank_transfer: payment_method_retrieval_context.bank_transfer_details,
38843900
bank: bank_details,
38853901
surcharge_details: None,
3886-
requires_cvv: requires_cvv
3887-
&& !(off_session_payment_flag && pm.connector_mandate_details.is_some()),
3902+
requires_cvv,
38883903
last_used_at: Some(pm.last_used_at),
38893904
default_payment_method_set: customer.default_payment_method_id.is_some()
38903905
&& customer.default_payment_method_id == Some(pm.payment_method_id),
@@ -3982,8 +3997,13 @@ pub async fn get_mca_status(
39823997
state: &routes::SessionState,
39833998
key_store: &domain::MerchantKeyStore,
39843999
merchant_id: &str,
4000+
is_connector_agnostic_mit_enabled: bool,
39854001
connector_mandate_details: Option<storage::PaymentsMandateReference>,
4002+
network_transaction_id: Option<&String>,
39864003
) -> errors::RouterResult<bool> {
4004+
if is_connector_agnostic_mit_enabled && network_transaction_id.is_some() {
4005+
return Ok(true);
4006+
}
39874007
if let Some(connector_mandate_details) = connector_mandate_details {
39884008
let mcas = state
39894009
.store

crates/router/src/core/payments.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3503,7 +3503,8 @@ pub async fn decide_multiplex_connector_for_normal_or_recurring_payment<F: Clone
35033503
let merchant_connector_id = connector_data
35043504
.merchant_connector_id
35053505
.as_ref()
3506-
.ok_or(errors::ApiErrorResponse::InternalServerError)?;
3506+
.ok_or(errors::ApiErrorResponse::InternalServerError)
3507+
.attach_printable("Failed to find the merchant connector id")?;
35073508

35083509
if is_network_transaction_id_flow(
35093510
state,

0 commit comments

Comments
 (0)