Skip to content

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

refactor(core): accept manual retry from profile (#9302)

Sakil Mostak59870a964dd9
diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs
index c8664b4e6d..52f2b3c2e0 100644
--- a/crates/api_models/src/enums.rs
+++ b/crates/api_models/src/enums.rs
@@ -410,7 +410,7 @@ mod test {
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum RetryAction {
- /// Payment can be retried from the client side until the payment is successful or payment expires or the attempts(configured by the merchant) for payment are exhausted
+ /// Manual retry through request is being deprecated, now it is available through profile
ManualRetry,
/// Denotes that the payment is requeued
Requeue,
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 4f395f3f87..f7f445d1b6 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -7465,6 +7465,7 @@ where
pub vault_operation: Option<domain_payments::VaultOperation>,
pub threeds_method_comp_ind: Option<api_models::payments::ThreeDsCompletionIndicator>,
pub whole_connector_response: Option<Secret<String>>,
+ pub is_manual_retry_enabled: Option<bool>,
}
#[derive(Clone, serde::Serialize, Debug)]
@@ -10557,6 +10558,9 @@ pub trait OperationSessionGetters<F> {
fn get_optional_external_vault_session_details(&self) -> Option<api::VaultSessionDetails>;
#[cfg(feature = "v1")]
fn get_click_to_pay_service_details(&self) -> Option<&api_models::payments::CtpServiceDetails>;
+
+ #[cfg(feature = "v1")]
+ fn get_is_manual_retry_enabled(&self) -> Option<bool>;
}
pub trait OperationSessionSetters<F> {
@@ -10797,6 +10801,10 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentData<F> {
self.service_details.as_ref()
}
+ fn get_is_manual_retry_enabled(&self) -> Option<bool> {
+ self.is_manual_retry_enabled
+ }
+
// #[cfg(feature = "v2")]
// fn get_capture_method(&self) -> Option<enums::CaptureMethod> {
// Some(self.payment_intent.capture_method)
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index d93c627813..f2735f5596 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -4442,15 +4442,12 @@ pub fn router_data_type_conversion<F1, F2, Req1, Req2, Res1, Res2>(
pub fn get_attempt_type(
payment_intent: &PaymentIntent,
payment_attempt: &PaymentAttempt,
- request: &api_models::payments::PaymentsRequest,
+ is_manual_retry_enabled: Option<bool>,
action: &str,
) -> RouterResult<AttemptType> {
match payment_intent.status {
enums::IntentStatus::Failed => {
- if matches!(
- request.retry_action,
- Some(api_models::enums::RetryAction::ManualRetry)
- ) {
+ if matches!(is_manual_retry_enabled, Some(true)) {
metrics::MANUAL_RETRY_REQUEST_COUNT.add(
1,
router_env::metric_attributes!((
@@ -4525,7 +4522,7 @@ pub fn get_attempt_type(
} else {
Err(report!(errors::ApiErrorResponse::PreconditionFailed {
message:
- format!("You cannot {action} this payment because it has status {}, you can pass `retry_action` as `manual_retry` in request to try this payment again", payment_intent.status)
+ format!("You cannot {action} this payment because it has status {}, you can enable `manual_retry` in profile to try this payment again", payment_intent.status)
}
))
}
diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rs
index 8beac4097a..77764e1abe 100644
--- a/crates/router/src/core/payments/operations/payment_approve.rs
+++ b/crates/router/src/core/payments/operations/payment_approve.rs
@@ -204,6 +204,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCaptureR
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rs
index 92c84985c9..e6e645cfa6 100644
--- a/crates/router/src/core/payments/operations/payment_cancel.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel.rs
@@ -215,6 +215,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRe
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
index 66b8f0fc47..c02c0d7fa8 100644
--- a/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel_post_capture.rs
@@ -198,6 +198,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelPo
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rs
index 2c3349f046..51eef70f5a 100644
--- a/crates/router/src/core/payments/operations/payment_capture.rs
+++ b/crates/router/src/core/payments/operations/payment_capture.rs
@@ -270,6 +270,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, payments::PaymentData<F>, api::Paymen
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
index f22e92c112..793b3c1d3c 100644
--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs
+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
@@ -363,6 +363,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
vault_operation: None,
threeds_method_comp_ind: request.threeds_method_comp_ind.clone(),
whole_connector_response: None,
+ is_manual_retry_enabled: None,
};
let customer_details = Some(CustomerDetails {
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index 8b776bcf71..5df0d22f1a 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -326,7 +326,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
let attempt_type = helpers::get_attempt_type(
&payment_intent,
&payment_attempt,
- request,
+ business_profile.is_manual_retry_enabled,
"confirm",
)?;
@@ -830,6 +830,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: business_profile.is_manual_retry_enabled,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index a28816cc6a..e88a5d51dd 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -629,6 +629,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
index b1543be154..d4f9703bd8 100644
--- a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
+++ b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs
@@ -176,6 +176,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsPostSess
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: None,
};
let get_trackers_response = operations::GetTrackerResponse {
operation: Box::new(self),
diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rs
index f963baa87c..28f0c05e68 100644
--- a/crates/router/src/core/payments/operations/payment_reject.rs
+++ b/crates/router/src/core/payments/operations/payment_reject.rs
@@ -202,6 +202,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, PaymentsCancelRequest
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rs
index 913870ef58..09f24e5710 100644
--- a/crates/router/src/core/payments/operations/payment_session.rs
+++ b/crates/router/src/core/payments/operations/payment_session.rs
@@ -225,6 +225,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsSessionR
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rs
index 9727fb399d..c782494b56 100644
--- a/crates/router/src/core/payments/operations/payment_start.rs
+++ b/crates/router/src/core/payments/operations/payment_start.rs
@@ -212,6 +212,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsStartReq
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rs
index c6488bdb75..31d86bfcec 100644
--- a/crates/router/src/core/payments/operations/payment_status.rs
+++ b/crates/router/src/core/payments/operations/payment_status.rs
@@ -553,6 +553,7 @@ async fn get_tracker_for_sync<
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: business_profile.is_manual_retry_enabled,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs
index a468f88fed..020b7c6028 100644
--- a/crates/router/src/core/payments/operations/payment_update.rs
+++ b/crates/router/src/core/payments/operations/payment_update.rs
@@ -521,6 +521,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/payment_update_metadata.rs b/crates/router/src/core/payments/operations/payment_update_metadata.rs
index 23a300c3c8..265b4da26b 100644
--- a/crates/router/src/core/payments/operations/payment_update_metadata.rs
+++ b/crates/router/src/core/payments/operations/payment_update_metadata.rs
@@ -162,6 +162,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsUpdateMe
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: None,
};
let get_trackers_response = operations::GetTrackerResponse {
operation: Box::new(self),
diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
index 862fcd8ff1..3528b491a2 100644
--- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
+++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs
@@ -181,6 +181,7 @@ impl<F: Send + Clone + Sync>
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: None,
};
let get_trackers_response = operations::GetTrackerResponse {
diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rs
index 9f0863e676..5a3e44f053 100644
--- a/crates/router/src/core/payments/operations/tax_calculation.rs
+++ b/crates/router/src/core/payments/operations/tax_calculation.rs
@@ -191,6 +191,7 @@ impl<F: Send + Clone + Sync>
vault_operation: None,
threeds_method_comp_ind: None,
whole_connector_response: None,
+ is_manual_retry_enabled: None,
};
let get_trackers_response = operations::GetTrackerResponse {
operation: Box::new(self),
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 595b437675..0ec3845407 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -3285,6 +3285,16 @@ where
.get_connector_payment_id()
.map(ToString::to_string);
+ let manual_retry_allowed = match payment_data.get_is_manual_retry_enabled() {
+ Some(true) => helpers::is_manual_retry_allowed(
+ &payment_intent.status,
+ &payment_attempt.status,
+ connector_request_reference_id_config,
+ &merchant_id,
+ ),
+ Some(false) | None => None,
+ };
+
let payments_response = api::PaymentsResponse {
payment_id: payment_intent.payment_id,
merchant_id: payment_intent.merchant_id,
@@ -3358,12 +3368,7 @@ where
ephemeral_key: payment_data
.get_ephemeral_key()
.map(ForeignFrom::foreign_from),
- manual_retry_allowed: helpers::is_manual_retry_allowed(
- &payment_intent.status,
- &payment_attempt.status,
- connector_request_reference_id_config,
- &merchant_id,
- ),
+ manual_retry_allowed,
connector_transaction_id,
frm_message,
metadata: payment_intent.metadata,