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

Refactor(core): remove payment_method_id from RouterData struct (#4485)

Prajjwal Kumar3077a0d31e8d
diff --git a/crates/router/src/core/authentication/transformers.rs b/crates/router/src/core/authentication/transformers.rs
index abefd12c77..d4cad2fbed 100644
--- a/crates/router/src/core/authentication/transformers.rs
+++ b/crates/router/src/core/authentication/transformers.rs
@@ -168,7 +168,6 @@ pub fn construct_router_data<F: Clone, Req, Res>(
connector_api_version: None,
request: request_data,
response: Err(types::ErrorResponse::default()),
- payment_method_id: None,
connector_request_reference_id:
IRRELEVANT_CONNECTOR_REQUEST_REFERENCE_ID_IN_AUTHENTICATION_FLOW.to_owned(),
#[cfg(feature = "payouts")]
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 f17a173008..58e82ec21c 100644
--- a/crates/router/src/core/fraud_check/flows/checkout_flow.rs
+++ b/crates/router/src/core/fraud_check/flows/checkout_flow.rs
@@ -63,7 +63,6 @@ impl ConstructFlowSpecificData<frm_api::Checkout, FraudCheckCheckoutData, FraudC
connector_auth_type: auth_type,
description: None,
return_url: None,
- payment_method_id: None,
payment_method_status: None,
address: self.address.clone(),
auth_type: storage_enums::AuthenticationType::NoThreeDs,
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 a76408b5d3..50ebea2487 100644
--- a/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs
+++ b/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs
@@ -71,7 +71,6 @@ pub async fn construct_fulfillment_router_data<'a>(
connector_auth_type: auth_type,
description: None,
return_url: payment_intent.return_url.clone(),
- payment_method_id: payment_attempt.payment_method_id.clone(),
address: PaymentAddress::default(),
auth_type: payment_attempt.authentication_type.unwrap_or_default(),
connector_meta_data: merchant_connector_account.get_metadata(),
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 cba19769d5..ad74f7f702 100644
--- a/crates/router/src/core/fraud_check/flows/record_return.rs
+++ b/crates/router/src/core/fraud_check/flows/record_return.rs
@@ -62,7 +62,6 @@ impl ConstructFlowSpecificData<RecordReturn, FraudCheckRecordReturnData, FraudCh
connector_auth_type: auth_type,
description: None,
return_url: None,
- payment_method_id: None,
address: self.address.clone(),
auth_type: storage_enums::AuthenticationType::NoThreeDs,
connector_meta_data: None,
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 c9f5e4dac0..0ce0c89bd3 100644
--- a/crates/router/src/core/fraud_check/flows/sale_flow.rs
+++ b/crates/router/src/core/fraud_check/flows/sale_flow.rs
@@ -58,7 +58,6 @@ impl ConstructFlowSpecificData<frm_api::Sale, FraudCheckSaleData, FraudCheckResp
connector_auth_type: auth_type,
description: None,
return_url: None,
- payment_method_id: None,
address: self.address.clone(),
auth_type: storage_enums::AuthenticationType::NoThreeDs,
connector_meta_data: None,
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 dc385093f2..5634916b21 100644
--- a/crates/router/src/core/fraud_check/flows/transaction_flow.rs
+++ b/crates/router/src/core/fraud_check/flows/transaction_flow.rs
@@ -69,7 +69,6 @@ impl
connector_auth_type: auth_type,
description: None,
return_url: None,
- payment_method_id: None,
address: self.address.clone(),
auth_type: storage_enums::AuthenticationType::NoThreeDs,
connector_meta_data: None,
diff --git a/crates/router/src/core/mandate/utils.rs b/crates/router/src/core/mandate/utils.rs
index 7b4933812e..ec438ee6d7 100644
--- a/crates/router/src/core/mandate/utils.rs
+++ b/crates/router/src/core/mandate/utils.rs
@@ -59,7 +59,6 @@ pub async fn construct_mandate_revoke_router_data(
connector_mandate_id: mandate.connector_mandate_id,
},
response: Err(types::ErrorResponse::get_not_implemented()),
- payment_method_id: None,
connector_request_reference_id:
IRRELEVANT_CONNECTOR_REQUEST_REFERENCE_ID_IN_MANDATE_REVOKE_FLOW.to_string(),
test_mode: None,
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 6a1a779fd1..bcc911e497 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -3244,7 +3244,6 @@ pub fn router_data_type_conversion<F1, F2, Req1, Req2, Res1, Res2>(
description: router_data.description,
payment_id: router_data.payment_id,
payment_method: router_data.payment_method,
- payment_method_id: router_data.payment_method_id,
return_url: router_data.return_url,
status: router_data.status,
attempt_id: router_data.attempt_id,
diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs
index 4580181d39..47d659b5ed 100644
--- a/crates/router/src/core/payments/operations/payment_response.rs
+++ b/crates/router/src/core/payments/operations/payment_response.rs
@@ -966,7 +966,10 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
status: updated_attempt_status,
connector: None,
connector_transaction_id,
- payment_method_id: router_data.payment_method_id,
+ payment_method_id: payment_data
+ .payment_attempt
+ .payment_method_id
+ .clone(),
error_code: Some(reason.clone().map(|cd| cd.code)),
error_message: Some(reason.clone().map(|cd| cd.message)),
error_reason: Some(reason.map(|cd| cd.message)),
diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rs
index 71cded04e1..58c58ffaef 100644
--- a/crates/router/src/core/payments/retry.rs
+++ b/crates/router/src/core/payments/retry.rs
@@ -384,7 +384,7 @@ where
.connector_response_reference_id
.clone(),
authentication_type: None,
- payment_method_id: router_data.payment_method_id,
+ payment_method_id: payment_data.payment_attempt.payment_method_id.clone(),
mandate_id: payment_data
.mandate_id
.clone()
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index eba5768a9c..b891998dae 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -141,7 +141,6 @@ where
connector_auth_type: auth_type,
description: payment_data.payment_intent.description.clone(),
return_url: payment_data.payment_intent.return_url.clone(),
- payment_method_id: payment_data.payment_attempt.payment_method_id.clone(),
address: payment_data
.address
.unify_with_payment_method_data_billing(payment_method_data_billing),
diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rs
index c67aafe938..c7a22e5689 100644
--- a/crates/router/src/core/utils.rs
+++ b/crates/router/src/core/utils.rs
@@ -160,7 +160,6 @@ pub async fn construct_payout_router_data<'a, F>(
connector_auth_type,
description: None,
return_url: payouts.return_url.to_owned(),
- payment_method_id: None,
address,
auth_type: enums::AuthenticationType::default(),
connector_meta_data: merchant_connector_account.get_metadata(),
@@ -311,7 +310,6 @@ pub async fn construct_refund_router_data<'a, F>(
connector_auth_type: auth_type,
description: None,
return_url: payment_intent.return_url.clone(),
- payment_method_id: payment_attempt.payment_method_id.clone(),
// Does refund need shipping/billing address ?
address: PaymentAddress::default(),
auth_type: payment_attempt.authentication_type.unwrap_or_default(),
@@ -557,7 +555,6 @@ pub async fn construct_accept_dispute_router_data<'a>(
connector_auth_type: auth_type,
description: None,
return_url: payment_intent.return_url.clone(),
- payment_method_id: payment_attempt.payment_method_id.clone(),
address: PaymentAddress::default(),
auth_type: payment_attempt.authentication_type.unwrap_or_default(),
connector_meta_data: merchant_connector_account.get_metadata(),
@@ -652,7 +649,6 @@ pub async fn construct_submit_evidence_router_data<'a>(
connector_auth_type: auth_type,
description: None,
return_url: payment_intent.return_url.clone(),
- payment_method_id: payment_attempt.payment_method_id.clone(),
address: PaymentAddress::default(),
auth_type: payment_attempt.authentication_type.unwrap_or_default(),
connector_meta_data: merchant_connector_account.get_metadata(),
@@ -745,7 +741,6 @@ pub async fn construct_upload_file_router_data<'a>(
connector_auth_type: auth_type,
description: None,
return_url: payment_intent.return_url.clone(),
- payment_method_id: payment_attempt.payment_method_id.clone(),
address: PaymentAddress::default(),
auth_type: payment_attempt.authentication_type.unwrap_or_default(),
connector_meta_data: merchant_connector_account.get_metadata(),
@@ -842,7 +837,6 @@ pub async fn construct_defend_dispute_router_data<'a>(
connector_auth_type: auth_type,
description: None,
return_url: payment_intent.return_url.clone(),
- payment_method_id: payment_attempt.payment_method_id.clone(),
address: PaymentAddress::default(),
auth_type: payment_attempt.authentication_type.unwrap_or_default(),
connector_meta_data: merchant_connector_account.get_metadata(),
@@ -930,7 +924,6 @@ pub async fn construct_retrieve_file_router_data<'a>(
connector_auth_type: auth_type,
description: None,
return_url: None,
- payment_method_id: None,
address: PaymentAddress::default(),
auth_type: diesel_models::enums::AuthenticationType::default(),
connector_meta_data: merchant_connector_account.get_metadata(),
diff --git a/crates/router/src/core/webhooks/utils.rs b/crates/router/src/core/webhooks/utils.rs
index 739d7b20fd..3bf8c7c7f2 100644
--- a/crates/router/src/core/webhooks/utils.rs
+++ b/crates/router/src/core/webhooks/utils.rs
@@ -83,7 +83,6 @@ pub async fn construct_webhook_router_data<'a>(
connector_auth_type: auth_type,
description: None,
return_url: None,
- payment_method_id: None,
address: PaymentAddress::default(),
auth_type: diesel_models::enums::AuthenticationType::default(),
connector_meta_data: None,
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index 639efe3f06..77d53584da 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -303,9 +303,6 @@ pub struct RouterData<Flow, Request, Response> {
/// Contains flow-specific data that the connector responds with.
pub response: Result<Response, ErrorResponse>,
- /// Contains any error response that the connector returns.
- pub payment_method_id: Option<String>,
-
/// Contains a reference ID that should be sent in the connector request
pub connector_request_reference_id: String,
@@ -1541,7 +1538,6 @@ impl<F1, F2, T1, T2> From<(&RouterData<F1, T1, PaymentsResponseData>, T2)>
amount_captured: data.amount_captured,
access_token: data.access_token.clone(),
response: data.response.clone(),
- payment_method_id: data.payment_method_id.clone(),
payment_id: data.payment_id.clone(),
session_token: data.session_token.clone(),
reference_id: data.reference_id.clone(),
@@ -1602,7 +1598,6 @@ impl<F1, F2>
amount_captured: data.amount_captured,
access_token: data.access_token.clone(),
response: data.response.clone(),
- payment_method_id: data.payment_method_id.clone(),
payment_id: data.payment_id.clone(),
session_token: data.session_token.clone(),
reference_id: data.reference_id.clone(),
diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rs
index 55dc4a2bf0..39891a7075 100644
--- a/crates/router/src/types/api/verify_connector.rs
+++ b/crates/router/src/types/api/verify_connector.rs
@@ -81,7 +81,6 @@ impl VerifyConnectorData {
payment_method: storage_enums::PaymentMethod::Card,
amount_captured: None,
preprocessing_id: None,
- payment_method_id: None,
connector_customer: None,
connector_auth_type: self.connector_auth.clone(),
connector_meta_data: None,
diff --git a/crates/router/tests/connectors/aci.rs b/crates/router/tests/connectors/aci.rs
index 4da849c4e2..710d90a4ea 100644
--- a/crates/router/tests/connectors/aci.rs
+++ b/crates/router/tests/connectors/aci.rs
@@ -33,7 +33,6 @@ fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData {
description: Some("This is a test".to_string()),
return_url: None,
payment_method_status: None,
- payment_method_id: None,
request: types::PaymentsAuthorizeData {
amount: 1000,
currency: enums::Currency::USD,
@@ -133,7 +132,6 @@ fn construct_refund_router_data<F>() -> types::RefundsRouterData<F> {
connector: "aci".to_string(),
payment_id: uuid::Uuid::new_v4().to_string(),
attempt_id: uuid::Uuid::new_v4().to_string(),
- payment_method_id: None,
payment_method_status: None,
status: enums::AttemptStatus::default(),
payment_method: enums::PaymentMethod::Card,
diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs
index fd472aa941..9678eca73f 100644
--- a/crates/router/tests/connectors/utils.rs
+++ b/crates/router/tests/connectors/utils.rs
@@ -503,7 +503,6 @@ pub trait ConnectorActions: Connector {
payment_id: uuid::Uuid::new_v4().to_string(),
attempt_id: uuid::Uuid::new_v4().to_string(),
status: enums::AttemptStatus::default(),
- payment_method_id: None,
auth_type: info
.clone()
.map_or(enums::AuthenticationType::NoThreeDs, |a| {