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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(router): add merchant_id check for manual_retry_allowed flag sent in payments response (#1785)
Sai Harsha Vardhan435c93957624
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 5ca40b3985..1a2aafd272 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -258,6 +258,7 @@ whereauth_flow,&state.conf.server,operation,+ &state.conf.connector_request_reference_id_config,)}diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 17b39af344..4515063e06 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -19,7 +19,7 @@ use super::{CustomerDetails, PaymentData,};use crate::{- configs::settings::Server,+ configs::settings::{ConnectorRequestReferenceIdConfig, Server},consts,core::{errors::{self, CustomResult, RouterResult, StorageErrorExt},@@ -2431,8 +2431,10 @@ impl AttemptType {pub fn is_manual_retry_allowed(intent_status: &storage_enums::IntentStatus,attempt_status: &storage_enums::AttemptStatus,+ connector_request_reference_id_config: &ConnectorRequestReferenceIdConfig,+ merchant_id: &str,) -> Option<bool> {- match intent_status {+ let is_payment_status_eligible_for_retry = match intent_status {enums::IntentStatus::Failed => match attempt_status {enums::AttemptStatus::Started| enums::AttemptStatus::AuthenticationPending@@ -2472,7 +2474,12 @@ pub fn is_manual_retry_allowed(| enums::IntentStatus::RequiresMerchantAction| enums::IntentStatus::RequiresPaymentMethod| enums::IntentStatus::RequiresConfirmation => None,- }+ };+ let is_merchant_id_enabled_for_retries = !connector_request_reference_id_config+ .merchant_ids_send_payment_id_as_connector_request_id+ .contains(merchant_id);+ is_payment_status_eligible_for_retry+ .map(|payment_status_check| payment_status_check && is_merchant_id_enabled_for_retries)}#[cfg(test)]diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 8685a278db..54c2e1f947 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -8,7 +8,7 @@ use router_env::{instrument, tracing};use super::{flows::Feature, PaymentAddress, PaymentData};use crate::{- configs::settings::Server,+ configs::settings::{ConnectorRequestReferenceIdConfig, Server},connector::{Nexinets, Paypal},core::{errors::{self, RouterResponse, RouterResult},@@ -155,6 +155,7 @@ whereauth_flow: services::AuthFlow,server: &Server,operation: Op,+ connector_request_reference_id_config: &ConnectorRequestReferenceIdConfig,) -> RouterResponse<Self>;}@@ -170,6 +171,7 @@ whereauth_flow: services::AuthFlow,server: &Server,operation: Op,+ connector_request_reference_id_config: &ConnectorRequestReferenceIdConfig,) -> RouterResponse<Self> {payments_to_payments_response(req,@@ -188,6 +190,7 @@ wherepayment_data.ephemeral_key,payment_data.sessions_token,payment_data.setup_mandate,+ connector_request_reference_id_config,)}}@@ -205,6 +208,7 @@ where_auth_flow: services::AuthFlow,_server: &Server,_operation: Op,+ _connector_request_reference_id_config: &ConnectorRequestReferenceIdConfig,) -> RouterResponse<Self> {Ok(services::ApplicationResponse::Json(Self {session_token: payment_data.sessions_token,@@ -231,6 +235,7 @@ where_auth_flow: services::AuthFlow,_server: &Server,_operation: Op,+ _connector_request_reference_id_config: &ConnectorRequestReferenceIdConfig,) -> RouterResponse<Self> {let additional_payment_method_data: Option<api_models::payments::AdditionalPaymentData> =data.payment_attempt@@ -288,6 +293,7 @@ pub fn payments_to_payments_response<R, Op>(ephemeral_key_option: Option<ephemeral_key::EphemeralKey>,session_tokens: Vec<api::SessionToken>,mandate_data: Option<api_models::payments::MandateData>,+ connector_request_reference_id_config: &ConnectorRequestReferenceIdConfig,) -> RouterResponse<api::PaymentsResponse>whereOp: Debug,@@ -489,6 +495,8 @@ where.set_manual_retry_allowed(helpers::is_manual_retry_allowed(&payment_intent.status,&payment_attempt.status,+ connector_request_reference_id_config,+ &merchant_id,)).set_connector_transaction_id(payment_attempt.connector_transaction_id).set_feature_metadata(payment_intent.feature_metadata)@@ -536,6 +544,8 @@ wheremanual_retry_allowed: helpers::is_manual_retry_allowed(&payment_intent.status,&payment_attempt.status,+ connector_request_reference_id_config,+ &merchant_id,),order_details: payment_intent.order_details,connector_transaction_id: payment_attempt.connector_transaction_id,