diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs index ee90126a2d84..a47feaa1b51e 100644 --- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs +++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs @@ -1277,7 +1277,6 @@ impl PaymentAttemptUpdate { } } -// TODO: Add fields as necessary #[cfg(feature = "v2")] #[derive(Debug, Clone, Serialize)] pub enum PaymentAttemptUpdate { @@ -1294,11 +1293,17 @@ pub enum PaymentAttemptUpdate { connector_payment_id: Option, updated_by: String, }, + /// Update the payment attempt after force syncing with the connector + SyncUpdate { + status: storage_enums::AttemptStatus, + updated_by: String, + }, /// Update the payment attempt on confirming the intent, after calling the connector on error response - ConfirmIntentError { + ErrorUpdate { status: storage_enums::AttemptStatus, error: ErrorDetails, updated_by: String, + connector_payment_id: Option, }, } @@ -1921,9 +1926,10 @@ impl From for diesel_models::PaymentAttemptUpdateInternal connector_payment_id: None, connector: Some(connector), }, - PaymentAttemptUpdate::ConfirmIntentError { + PaymentAttemptUpdate::ErrorUpdate { status, error, + connector_payment_id, updated_by, } => Self { status: Some(status), @@ -1936,7 +1942,7 @@ impl From for diesel_models::PaymentAttemptUpdateInternal merchant_connector_id: None, unified_code: None, unified_message: None, - connector_payment_id: None, + connector_payment_id, connector: None, }, PaymentAttemptUpdate::ConfirmIntentResponse { @@ -1957,6 +1963,20 @@ impl From for diesel_models::PaymentAttemptUpdateInternal connector_payment_id, connector: None, }, + PaymentAttemptUpdate::SyncUpdate { status, updated_by } => Self { + status: Some(status), + error_message: None, + error_code: None, + modified_at: common_utils::date_time::now(), + browser_info: None, + error_reason: None, + updated_by, + merchant_connector_id: None, + unified_code: None, + unified_message: None, + connector_payment_id: None, + connector: None, + }, } } } diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs index ace326d4c776..f3027081094b 100644 --- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs +++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs @@ -278,6 +278,10 @@ pub enum PaymentIntentUpdate { status: storage_enums::IntentStatus, updated_by: String, }, + SyncUpdate { + status: storage_enums::IntentStatus, + updated_by: String, + }, } #[cfg(feature = "v2")] @@ -378,6 +382,12 @@ impl From for diesel_models::PaymentIntentUpdateInternal { modified_at: common_utils::date_time::now(), updated_by, }, + PaymentIntentUpdate::SyncUpdate { status, updated_by } => Self { + status: Some(status), + active_attempt_id: None, + modified_at: common_utils::date_time::now(), + updated_by, + }, } } } @@ -402,6 +412,11 @@ impl From for PaymentIntentUpdateInternal { updated_by, ..Default::default() }, + PaymentIntentUpdate::SyncUpdate { status, updated_by } => Self { + status: Some(status), + updated_by, + ..Default::default() + }, } } } diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs index cf78c8fb0c4c..522486f8ac30 100644 --- a/crates/router/src/core/payments/operations/payment_response.rs +++ b/crates/router/src/core/payments/operations/payment_response.rs @@ -2293,7 +2293,7 @@ impl PostUpdateTracker, types::PaymentsAuthor unified_message: None, }; - let payment_attempt_update = hyperswitch_domain_models::payments::payment_attempt::PaymentAttemptUpdate::ConfirmIntentError { status: attempt_status, error: error_details,updated_by: storage_scheme.to_string() }; + let payment_attempt_update = hyperswitch_domain_models::payments::payment_attempt::PaymentAttemptUpdate::ErrorUpdate { status: attempt_status, error: error_details, connector_payment_id: connector_transaction_id, updated_by: storage_scheme.to_string() }; let updated_payment_attempt = db .update_payment_attempt( key_manager_state, @@ -2379,7 +2379,7 @@ impl PostUpdateTracker, types::PaymentsSyncDat | types::ResponseId::EncodedData(id) => Some(id), }; - let payment_intent_update = hyperswitch_domain_models::payments::payment_intent::PaymentIntentUpdate::ConfirmIntentPostUpdate { status: intent_status, updated_by: storage_scheme.to_string() }; + let payment_intent_update = hyperswitch_domain_models::payments::payment_intent::PaymentIntentUpdate::SyncUpdate { status: intent_status, updated_by: storage_scheme.to_string() }; let updated_payment_intent = db .update_payment_intent( key_manager_state, @@ -2393,7 +2393,7 @@ impl PostUpdateTracker, types::PaymentsSyncDat .attach_printable("Unable to update payment intent")?; payment_data.payment_intent = updated_payment_intent; - let payment_attempt_update = hyperswitch_domain_models::payments::payment_attempt::PaymentAttemptUpdate::ConfirmIntentResponse { status: attempt_status, connector_payment_id, updated_by: storage_scheme.to_string() }; + let payment_attempt_update = hyperswitch_domain_models::payments::payment_attempt::PaymentAttemptUpdate::SyncUpdate { status: attempt_status, updated_by: storage_scheme.to_string() }; let updated_payment_attempt = db .update_payment_attempt( key_manager_state, @@ -2476,7 +2476,7 @@ impl PostUpdateTracker, types::PaymentsSyncDat unified_message: None, }; - let payment_attempt_update = hyperswitch_domain_models::payments::payment_attempt::PaymentAttemptUpdate::ConfirmIntentError { status: attempt_status, error: error_details,updated_by: storage_scheme.to_string() }; + let payment_attempt_update = hyperswitch_domain_models::payments::payment_attempt::PaymentAttemptUpdate::ErrorUpdate { status: attempt_status, error: error_details, connector_payment_id: connector_transaction_id, updated_by: storage_scheme.to_string() }; let updated_payment_attempt = db .update_payment_attempt( key_manager_state,