Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sai-harsha-vardhan committed Oct 5, 2023
1 parent 79d4cc2 commit e60339e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
6 changes: 2 additions & 4 deletions crates/api_models/src/webhooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ pub enum WebhookResponseTracker {
},
Mandate {
mandate_id: String,
payment_id: String,
status: common_enums::MandateStatus,
},
NoEffect,
Expand All @@ -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,
}
}
}
Expand Down
39 changes: 0 additions & 39 deletions crates/router/src/core/webhooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,26 +426,6 @@ pub async fn mandates_incoming_webhook_flow<W: types::OutgoingWebhookType>(
.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()
Expand All @@ -459,24 +439,6 @@ pub async fn mandates_incoming_webhook_flow<W: types::OutgoingWebhookType>(
)
.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?,
Expand All @@ -497,7 +459,6 @@ pub async fn mandates_incoming_webhook_flow<W: types::OutgoingWebhookType>(
}
Ok(WebhookResponseTracker::Mandate {
mandate_id: updated_mandate.mandate_id,
payment_id: payment_intent.payment_id,
status: updated_mandate.mandate_status,
})
} else {
Expand Down

0 comments on commit e60339e

Please sign in to comment.