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(revenue_recovery): use network decline code and card network for hard decline gsm lookup (#15001)
CHALLA NISHANTH BABU1308d3e867c4
diff --git a/crates/router/src/core/revenue_recovery/types.rs b/crates/router/src/core/revenue_recovery/types.rsindex c3094ef0aa..b8c7b6ffaa 100644--- a/crates/router/src/core/revenue_recovery/types.rs+++ b/crates/router/src/core/revenue_recovery/types.rs@@ -1308,6 +1308,10 @@ impl Action {.error.as_ref().map(|details| details.code.clone());+ let network_decline_code = payment_attempt+ .error+ .as_ref()+ .and_then(|details| details.network_decline_code.clone());let connector_name = payment_attempt.connector.clone()@@ -1320,8 +1324,8 @@ impl Action {consts::DEFAULT_SUBFLOW_STR,error_code,error_message,- None, // issuer_error_code not available in recovery context- None, // card_network+ network_decline_code,+ payment_attempt.extract_card_network(),).await;let is_hard_decline = gsm_recorddiff --git a/crates/router/src/core/webhooks/recovery_incoming.rs b/crates/router/src/core/webhooks/recovery_incoming.rsindex 84140001dd..4a225aa9d3 100644--- a/crates/router/src/core/webhooks/recovery_incoming.rs+++ b/crates/router/src/core/webhooks/recovery_incoming.rs@@ -1055,6 +1055,13 @@ impl RevenueRecoveryAttempt {.attach_printable("unable to derive payment connector")?.to_string();+ // The recorded attempt is synced with the payment connector, so prefer the decline code+ // it carries and fall back to the one the caller sent.+ let network_decline_code = recovery_attempt+ .network_decline_code+ .clone()+ .or_else(|| revenue_recovery_attempt_data.network_decline_code.clone());+let gsm_record = helpers::get_gsm_record(state,connector_name,@@ -1062,8 +1069,8 @@ impl RevenueRecoveryAttempt {consts::DEFAULT_SUBFLOW_STR,error_code.clone(),error_message,- None, // issuer_error_code- None, // card_network+ network_decline_code,+ revenue_recovery_attempt_data.card_info.card_network.clone(),).await;diff --git a/crates/router/src/types/storage/revenue_recovery_redis_operation.rs b/crates/router/src/types/storage/revenue_recovery_redis_operation.rsindex c84609a3ae..6a1c5625b1 100644--- a/crates/router/src/types/storage/revenue_recovery_redis_operation.rs+++ b/crates/router/src/types/storage/revenue_recovery_redis_operation.rs@@ -627,8 +627,21 @@ impl RedisTokenManager {.or_insert(value);}existing_token.account_update_history = token_data.account_update_history.clone();+ // Keep the stored network when the incoming data does not carry one, as the retry+ // config and gsm lookups read it back from here.+ let card_network = token_data+ .payment_processor_token_details+ .card_network+ .clone()+ .or_else(|| {+ existing_token+ .payment_processor_token_details+ .card_network+ .clone()+ });existing_token.payment_processor_token_details =token_data.payment_processor_token_details.clone();+ existing_token.payment_processor_token_details.card_network = card_network;existing_token.modified_at@@ -1362,7 +1375,12 @@ impl AccountUpdaterAction {card_issuer: None,last_four_digits: None,card_type: None,- card_network: updated_mandate_details.card_network.clone(),+ card_network: updated_mandate_details.card_network.clone().or_else(|| {+ scheduled_token+ .payment_processor_token_details+ .card_network+ .clone()+ }),card_isin: updated_mandate_details.card_isin.clone(),},inserted_by_attempt_id: attempt_id.to_owned(),@@ -1402,8 +1420,10 @@ impl AccountUpdaterAction {updated_mandate_details.card_exp_month.clone();updated_token.payment_processor_token_details.expiry_year =updated_mandate_details.card_exp_year.clone();- updated_token.payment_processor_token_details.card_network =- updated_mandate_details.card_network.clone();+ if updated_mandate_details.card_network.is_some() {+ updated_token.payment_processor_token_details.card_network =+ updated_mandate_details.card_network.clone();+ }updated_token.payment_processor_token_details.card_isin =updated_mandate_details.card_isin.clone();updated_token.modified_at = Some(date_time::now());diff --git a/crates/router/src/workflows/revenue_recovery.rs b/crates/router/src/workflows/revenue_recovery.rsindex f4ec1f925c..513d938e48 100644--- a/crates/router/src/workflows/revenue_recovery.rs+++ b/crates/router/src/workflows/revenue_recovery.rs@@ -1533,6 +1533,10 @@ pub async fn check_hard_decline(.error.as_ref().map(|details| details.code.clone());+ let network_decline_code = payment_attempt+ .error+ .as_ref()+ .and_then(|details| details.network_decline_code.clone());let connector_name = payment_attempt.connector@@ -1562,8 +1566,8 @@ pub async fn check_hard_decline(consts::DEFAULT_SUBFLOW_STR,error_code,error_message,- None, // issuer_error_code not available in recovery context- None, // card_network+ network_decline_code,+ payment_attempt.extract_card_network(),).await;