Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(connectors): [Adyen] add migrated payment method check (#10094)

Mrudul Vajpayee2abb747af2df
diff --git a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
index 7535dc238d..e5ae3a399b 100644
--- a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
@@ -1875,17 +1875,28 @@ type RecurringDetails = (Option<AdyenRecurringModel>, Option<bool>, Option<Strin
fn get_recurring_processing_model(
item: &PaymentsAuthorizeRouterData,
) -> Result<RecurringDetails, Error> {
- let shopper_reference = match item.get_connector_customer_id() {
- Ok(connector_customer_id) => Some(connector_customer_id),
- Err(_) => {
+ // is_migrated_card to be changed intto is_migrated_payment_method to cover all migrated payment methods.
+ let shopper_reference = Some(match item.is_migrated_card {
+ Some(true) => match item.get_connector_customer_id() {
+ Ok(connector_customer_id) => connector_customer_id,
+ Err(_) => {
+ let customer_id = item.get_customer_id()?;
+ format!(
+ "{}_{}",
+ item.merchant_id.get_string_repr(),
+ customer_id.get_string_repr()
+ )
+ }
+ },
+ _ => {
let customer_id = item.get_customer_id()?;
- Some(format!(
+ format!(
"{}_{}",
item.merchant_id.get_string_repr(),
customer_id.get_string_repr()
- ))
+ )
}
- };
+ });
match (item.request.setup_future_usage, item.request.off_session) {
(Some(storage_enums::FutureUsage::OffSession), _) => {
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index ea1d18dfc2..e618bc9b3b 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -7014,6 +7014,7 @@ pub(crate) fn convert_payment_authorize_router_response<F1, F2, T1, T2>(
l2_l3_data: data.l2_l3_data.clone(),
minor_amount_capturable: data.minor_amount_capturable,
authorized_amount: data.authorized_amount,
+ is_migrated_card: data.is_migrated_card,
}
}
diff --git a/crates/hyperswitch_domain_models/src/payment_methods.rs b/crates/hyperswitch_domain_models/src/payment_methods.rs
index 30d8e8ef97..7b0fa8f7ff 100644
--- a/crates/hyperswitch_domain_models/src/payment_methods.rs
+++ b/crates/hyperswitch_domain_models/src/payment_methods.rs
@@ -243,6 +243,20 @@ impl PaymentMethod {
}
}
+ #[cfg(feature = "v1")]
+ pub fn is_migrated_card(&self) -> bool {
+ self.get_payment_method_type() == Some(storage_enums::PaymentMethod::Card)
+ && self.locker_id.is_none()
+ && self.connector_mandate_details.is_some()
+ }
+
+ #[cfg(feature = "v2")]
+ pub fn is_migrated_card(&self) -> bool {
+ self.get_payment_method_type() == Some(storage_enums::PaymentMethod::Card)
+ && self.locker_id.is_none()
+ && self.connector_mandate_details.is_some()
+ }
+
#[cfg(feature = "v2")]
pub fn set_payment_method_type(&mut self, payment_method_type: common_enums::PaymentMethod) {
self.payment_method_type = Some(payment_method_type);
diff --git a/crates/hyperswitch_domain_models/src/router_data.rs b/crates/hyperswitch_domain_models/src/router_data.rs
index 945f8e27b2..1d4ac813af 100644
--- a/crates/hyperswitch_domain_models/src/router_data.rs
+++ b/crates/hyperswitch_domain_models/src/router_data.rs
@@ -89,6 +89,7 @@ pub struct RouterData<Flow, Request, Response> {
/// This field is used to store various data regarding the response from connector
pub connector_response: Option<ConnectorResponseData>,
pub payment_method_status: Option<common_enums::PaymentMethodStatus>,
+ pub is_migrated_card: Option<bool>,
// minor amount for amount framework
pub minor_amount_captured: Option<MinorUnit>,
diff --git a/crates/hyperswitch_interfaces/src/conversion_impls.rs b/crates/hyperswitch_interfaces/src/conversion_impls.rs
index 884803940d..d6cf701317 100644
--- a/crates/hyperswitch_interfaces/src/conversion_impls.rs
+++ b/crates/hyperswitch_interfaces/src/conversion_impls.rs
@@ -80,6 +80,7 @@ fn get_default_router_data<F, Req, Resp>(
refund_id: None,
connector_response: None,
payment_method_status: None,
+ is_migrated_card: None,
minor_amount_captured: None,
integrity_check: Ok(()),
additional_merchant_data: None,
diff --git a/crates/router/src/core/authentication/transformers.rs b/crates/router/src/core/authentication/transformers.rs
index fb74955ab6..220f1f09c8 100644
--- a/crates/router/src/core/authentication/transformers.rs
+++ b/crates/router/src/core/authentication/transformers.rs
@@ -212,6 +212,7 @@ pub fn construct_router_data<F: Clone, Req, Res>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
})
}
diff --git a/crates/router/src/core/configs.rs b/crates/router/src/core/configs.rs
index 247ce98b00..649ab4003c 100644
--- a/crates/router/src/core/configs.rs
+++ b/crates/router/src/core/configs.rs
@@ -81,7 +81,7 @@ pub async fn get_config_bool(
};
// Use superposition result or fall back to database
- let result = if let Some(value) = superposition_result {
+ if let Some(value) = superposition_result {
Ok(value)
} else {
let config = state
@@ -93,9 +93,7 @@ pub async fn get_config_bool(
.config
.parse::<bool>()
.change_context(errors::StorageError::DeserializationFailed)
- };
-
- result
+ }
}
/// Get a string configuration value with superposition and database fallback
@@ -126,7 +124,7 @@ pub async fn get_config_string(
};
// Use superposition result or fall back to database
- let result = if let Some(value) = superposition_result {
+ if let Some(value) = superposition_result {
Ok(value)
} else {
let config = state
@@ -135,9 +133,7 @@ pub async fn get_config_string(
.await?;
Ok(config.config)
- };
-
- result
+ }
}
/// Get an integer configuration value with superposition and database fallback
@@ -168,7 +164,7 @@ pub async fn get_config_int(
};
// Use superposition result or fall back to database
- let result = if let Some(value) = superposition_result {
+ if let Some(value) = superposition_result {
Ok(value)
} else {
let config = state
@@ -180,9 +176,7 @@ pub async fn get_config_int(
.config
.parse::<i64>()
.change_context(errors::StorageError::DeserializationFailed)
- };
-
- result
+ }
}
/// Get a float configuration value with superposition and database fallback
@@ -213,7 +207,7 @@ pub async fn get_config_float(
};
// Use superposition result or fall back to database
- let result = if let Some(value) = superposition_result {
+ if let Some(value) = superposition_result {
Ok(value)
} else {
let config = state
@@ -225,9 +219,7 @@ pub async fn get_config_float(
.config
.parse::<f64>()
.change_context(errors::StorageError::DeserializationFailed)
- };
-
- result
+ }
}
/// Get an object configuration value with superposition and database fallback
@@ -264,7 +256,7 @@ where
};
// Use superposition result or fall back to database
- let result = if let Some(superposition_result) = superposition_result {
+ if let Some(superposition_result) = superposition_result {
superposition_result
} else {
let config = state
@@ -280,7 +272,5 @@ where
serde_json::from_str::<T>(&config.config)
.change_context(errors::StorageError::DeserializationFailed)
- };
-
- result
+ }
}
diff --git a/crates/router/src/core/fraud_check/flows/checkout_flow.rs b/crates/router/src/core/fraud_check/flows/checkout_flow.rs
index ec6b014f6a..e539785104 100644
--- a/crates/router/src/core/fraud_check/flows/checkout_flow.rs
+++ b/crates/router/src/core/fraud_check/flows/checkout_flow.rs
@@ -166,6 +166,7 @@ impl ConstructFlowSpecificData<frm_api::Checkout, FraudCheckCheckoutData, FraudC
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
diff --git a/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs b/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs
index 78f7140822..63337eef4a 100644
--- a/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs
+++ b/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs
@@ -137,6 +137,7 @@ pub async fn construct_fulfillment_router_data<'a>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
}
diff --git a/crates/router/src/core/fraud_check/flows/record_return.rs b/crates/router/src/core/fraud_check/flows/record_return.rs
index a1dbf4d210..ca4185d042 100644
--- a/crates/router/src/core/fraud_check/flows/record_return.rs
+++ b/crates/router/src/core/fraud_check/flows/record_return.rs
@@ -137,6 +137,7 @@ impl ConstructFlowSpecificData<RecordReturn, FraudCheckRecordReturnData, FraudCh
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
diff --git a/crates/router/src/core/fraud_check/flows/sale_flow.rs b/crates/router/src/core/fraud_check/flows/sale_flow.rs
index f564125314..73b9e59187 100644
--- a/crates/router/src/core/fraud_check/flows/sale_flow.rs
+++ b/crates/router/src/core/fraud_check/flows/sale_flow.rs
@@ -145,6 +145,7 @@ impl ConstructFlowSpecificData<frm_api::Sale, FraudCheckSaleData, FraudCheckResp
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
diff --git a/crates/router/src/core/fraud_check/flows/transaction_flow.rs b/crates/router/src/core/fraud_check/flows/transaction_flow.rs
index 084c7b6aa7..3c7ec23c9a 100644
--- a/crates/router/src/core/fraud_check/flows/transaction_flow.rs
+++ b/crates/router/src/core/fraud_check/flows/transaction_flow.rs
@@ -155,6 +155,7 @@ impl
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
diff --git a/crates/router/src/core/mandate/utils.rs b/crates/router/src/core/mandate/utils.rs
index 3981db1a67..43a7844ace 100644
--- a/crates/router/src/core/mandate/utils.rs
+++ b/crates/router/src/core/mandate/utils.rs
@@ -91,6 +91,7 @@ pub async fn construct_mandate_revoke_router_data(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs
index 578302d7e7..20a3349a52 100644
--- a/crates/router/src/core/payment_methods.rs
+++ b/crates/router/src/core/payment_methods.rs
@@ -3834,6 +3834,7 @@ async fn create_single_use_tokenization_flow(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
let payment_method_token_response = Box::pin(tokenization::add_token_for_payment_method(
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index d3972de4ff..8749538998 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -4593,6 +4593,7 @@ pub fn router_data_type_conversion<F1, F2, Req1, Req2, Res1, Res2>(
l2_l3_data: router_data.l2_l3_data,
minor_amount_capturable: router_data.minor_amount_capturable,
authorized_amount: router_data.authorized_amount,
+ is_migrated_card: router_data.is_migrated_card,
}
}
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index b212588995..882a015e30 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -199,6 +199,7 @@ where
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
}
@@ -545,6 +546,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
@@ -892,6 +894,7 @@ pub async fn construct_payment_router_data_for_capture<'a>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
@@ -1025,6 +1028,7 @@ pub async fn construct_router_data_for_psync<'a>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
@@ -1389,6 +1393,7 @@ pub async fn construct_payment_router_data_for_sdk_session<'a>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
@@ -1616,6 +1621,7 @@ pub async fn construct_payment_router_data_for_setup_mandate<'a>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
@@ -1867,7 +1873,14 @@ where
access_token: None,
session_token: None,
reference_id: None,
- payment_method_status: payment_data.payment_method_info.map(|info| info.status),
+ payment_method_status: payment_data
+ .payment_method_info
+ .as_ref()
+ .map(|info| info.status),
+ is_migrated_card: payment_data
+ .payment_method_info
+ .as_ref()
+ .map(|info| info.is_migrated_card()),
payment_method_token: payment_data
.pm_token
.map(|token| types::PaymentMethodToken::Token(Secret::new(token))),
@@ -2065,7 +2078,11 @@ pub async fn construct_payment_router_data_for_update_metadata<'a>(
access_token: None,
session_token: None,
reference_id: None,
- payment_method_status: payment_data.payment_method_info.map(|info| info.status),
+ payment_method_status: payment_data
+ .payment_method_info
+ .as_ref()
+ .map(|info| info.status),
+ is_migrated_card: None,
payment_method_token: payment_data
.pm_token
.map(|token| types::PaymentMethodToken::Token(Secret::new(token))),
diff --git a/crates/router/src/core/relay/utils.rs b/crates/router/src/core/relay/utils.rs
index b372f903ad..8c6505cc0d 100644
--- a/crates/router/src/core/relay/utils.rs
+++ b/crates/router/src/core/relay/utils.rs
@@ -149,6 +149,7 @@ pub async fn construct_relay_refund_router_data<F>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
diff --git a/crates/router/src/core/unified_authentication_service/utils.rs b/crates/router/src/core/unified_authentication_service/utils.rs
index 3cfb2d31fa..185c8c3ca3 100644
--- a/crates/router/src/core/unified_authentication_service/utils.rs
+++ b/crates/router/src/core/unified_authentication_service/utils.rs
@@ -132,6 +132,7 @@ pub fn construct_uas_router_data<F: Clone, Req, Res>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
})
}
diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rs
index baa59ff90b..841691cbfe 100644
--- a/crates/router/src/core/utils.rs
+++ b/crates/router/src/core/utils.rs
@@ -231,6 +231,7 @@ pub async fn construct_payout_router_data<'a, F>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
@@ -406,6 +407,7 @@ pub async fn construct_refund_router_data<'a, F>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
@@ -597,6 +599,7 @@ pub async fn construct_refund_router_data<'a, F>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
@@ -1043,6 +1046,7 @@ pub async fn construct_accept_dispute_router_data<'a>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
}
@@ -1149,6 +1153,7 @@ pub async fn construct_submit_evidence_router_data<'a>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
}
@@ -1264,6 +1269,7 @@ pub async fn construct_upload_file_router_data<'a>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
}
@@ -1339,6 +1345,7 @@ pub async fn construct_dispute_list_router_data<'a>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
})
}
@@ -1447,6 +1454,7 @@ pub async fn construct_dispute_sync_router_data<'a>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
}
@@ -1577,6 +1585,7 @@ pub async fn construct_payments_dynamic_tax_calculation_router_data<F: Clone>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
}
@@ -1686,6 +1695,7 @@ pub async fn construct_defend_dispute_router_data<'a>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
}
@@ -1788,6 +1798,7 @@ pub async fn construct_retrieve_file_router_data<'a>(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
}
diff --git a/crates/router/src/core/webhooks/utils.rs b/crates/router/src/core/webhooks/utils.rs
index c892adead5..fa970d199e 100644
--- a/crates/router/src/core/webhooks/utils.rs
+++ b/crates/router/src/core/webhooks/utils.rs
@@ -145,6 +145,7 @@ pub async fn construct_webhook_router_data(
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
};
Ok(router_data)
}
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index 3269a75a89..865a707175 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -1387,6 +1387,7 @@ impl<F1, F2, T1, T2> ForeignFrom<(&RouterData<F1, T1, PaymentsResponseData>, T2)
l2_l3_data: data.l2_l3_data.clone(),
minor_amount_capturable: data.minor_amount_capturable,
authorized_amount: data.authorized_amount,
+ is_migrated_card: data.is_migrated_card,
}
}
}
@@ -1459,6 +1460,7 @@ impl<F1, F2>
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
}
}
}
diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rs
index bb8a52b62d..bc0a9a21c9 100644
--- a/crates/router/src/types/api/verify_connector.rs
+++ b/crates/router/src/types/api/verify_connector.rs
@@ -139,6 +139,7 @@ impl VerifyConnectorData {
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
}
}
}
diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs
index 946035125b..6e46b160ca 100644
--- a/crates/router/tests/connectors/utils.rs
+++ b/crates/router/tests/connectors/utils.rs
@@ -565,6 +565,7 @@ pub trait ConnectorActions: Connector {
l2_l3_data: None,
minor_amount_capturable: None,
authorized_amount: None,
+ is_migrated_card: None,
}
}