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
fix(payment_response): Set modular payment method to inactive if case of payment failure (#11412)
Gaurav Rawatb9d260ab3ddf
diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rsindex 8ada2284e5..9c6bd61fd2 100644--- a/crates/router/src/core/payments/operations/payment_response.rs+++ b/crates/router/src/core/payments/operations/payment_response.rs@@ -83,8 +83,7 @@ whereif matches!(payment_data.payment_attempt.payment_method,Some(enums::PaymentMethod::Card)- ) && resp.status.should_update_payment_method()- {+ ) {//#1 - Check if Payment method id is present in the payment datamatch payment_data.payment_method_info@@ -92,13 +91,18 @@ where.map(|pm_info| pm_info.get_id().clone()){Some(payment_method_id) => {- logger::info!("Payment method is card and eligible for modular update");+ let should_update = resp.status.should_update_payment_method();+ logger::info!(+ "Payment method is card; is eligible for modular update: {}",+ should_update+ );// #2 - Derive network transaction ID from the connector response.- let (network_transaction_id, connector_token_details) = if matches!(- payment_data.payment_attempt.setup_future_usage_applied,- Some(common_enums::FutureUsage::OffSession)- ) {+ let (network_transaction_id, connector_token_details) = if should_update+ && matches!(+ payment_data.payment_attempt.setup_future_usage_applied,+ Some(common_enums::FutureUsage::OffSession)+ ) {let network_transaction_id = resp.response.as_ref()@@ -178,11 +182,9 @@ where}_ => None,});- let acknowledgement_status = if resp.status.should_update_payment_method() {- Some(common_enums::AcknowledgementStatus::Authenticated)- } else {- None- };+ let acknowledgement_status = should_update+ .then_some(common_enums::AcknowledgementStatus::Authenticated)+ .or(Some(common_enums::AcknowledgementStatus::Failed));let payload = UpdatePaymentMethodV1Payload {payment_method_data,