From e60339ea472568e8748098b2352e3e67bd242f33 Mon Sep 17 00:00:00 2001 From: sai-harsha-vardhan Date: Thu, 5 Oct 2023 23:52:33 +0530 Subject: [PATCH] resolve comments --- crates/api_models/src/webhooks.rs | 6 ++--- crates/router/src/core/webhooks.rs | 39 ------------------------------ 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/crates/api_models/src/webhooks.rs b/crates/api_models/src/webhooks.rs index bad7206e7e94..da5d8a6567d7 100644 --- a/crates/api_models/src/webhooks.rs +++ b/crates/api_models/src/webhooks.rs @@ -61,7 +61,6 @@ pub enum WebhookResponseTracker { }, Mandate { mandate_id: String, - payment_id: String, status: common_enums::MandateStatus, }, NoEffect, @@ -72,9 +71,8 @@ impl WebhookResponseTracker { match self { Self::Payment { payment_id, .. } | Self::Refund { payment_id, .. } - | Self::Dispute { payment_id, .. } - | Self::Mandate { payment_id, .. } => Some(payment_id.to_string()), - Self::NoEffect => None, + | Self::Dispute { payment_id, .. } => Some(payment_id.to_string()), + Self::NoEffect | Self::Mandate { .. } => None, } } } diff --git a/crates/router/src/core/webhooks.rs b/crates/router/src/core/webhooks.rs index a8bacf3bb9a7..b647c8a97d7b 100644 --- a/crates/router/src/core/webhooks.rs +++ b/crates/router/src/core/webhooks.rs @@ -426,26 +426,6 @@ pub async fn mandates_incoming_webhook_flow( .into_report() .attach_printable("received a non-mandate id for retrieving mandate")?, }; - let payment_intent = db - .find_payment_intent_by_payment_id_merchant_id( - &mandate - .original_payment_id - .ok_or(errors::ApiErrorResponse::InternalServerError) - .into_report() - .attach_printable("original_payment_id not present in mandate record")?, - &merchant_account.merchant_id, - merchant_account.storage_scheme, - ) - .await - .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; - let payment_attempt = db - .find_payment_attempt_by_attempt_id_merchant_id( - &payment_intent.active_attempt_id.clone(), - &merchant_account.merchant_id, - merchant_account.storage_scheme, - ) - .await - .change_context(errors::ApiErrorResponse::PaymentNotFound)?; let mandate_status = event_type .foreign_try_into() .into_report() @@ -459,24 +439,6 @@ pub async fn mandates_incoming_webhook_flow( ) .await .to_not_found_response(errors::ApiErrorResponse::MandateNotFound)?; - db.update_payment_intent( - payment_intent.clone(), - storage::PaymentIntentUpdate::PGStatusUpdate { - status: api_models::enums::IntentStatus::Succeeded, - }, - merchant_account.storage_scheme, - ) - .await - .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; - db.update_payment_attempt_with_attempt_id( - payment_attempt, - storage::PaymentAttemptUpdate::StatusUpdate { - status: api_models::enums::AttemptStatus::Charged, - }, - merchant_account.storage_scheme, - ) - .await - .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; let mandates_response = Box::new( api::mandates::MandateResponse::from_db_mandate(&state, updated_mandate.clone()) .await?, @@ -497,7 +459,6 @@ pub async fn mandates_incoming_webhook_flow( } Ok(WebhookResponseTracker::Mandate { mandate_id: updated_mandate.mandate_id, - payment_id: payment_intent.payment_id, status: updated_mandate.mandate_status, }) } else {