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

feat(router): Add Review status to Payments (#11859)

Anurag Thakur526e2902044c
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 438b0059cc..9ce80bc8e4 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -10136,7 +10136,8 @@
"confirmation_awaited",
"device_data_collection_pending",
"integrity_failure",
- "expired"
+ "expired",
+ "capture_review"
]
},
"AuthenticationAuthenticateRequest": {
@@ -22845,7 +22846,8 @@
"partially_authorized_and_requires_capture",
"partially_captured_and_processing",
"conflicted",
- "expired"
+ "expired",
+ "review"
]
},
"Interac": {
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 55b3e74c39..e633f17068 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -6711,7 +6711,8 @@
"confirmation_awaited",
"device_data_collection_pending",
"integrity_failure",
- "expired"
+ "expired",
+ "capture_review"
]
},
"AuthenticationConnectorDetails": {
@@ -16398,7 +16399,8 @@
"partially_authorized_and_requires_capture",
"partially_captured_and_processing",
"conflicted",
- "expired"
+ "expired",
+ "review"
]
},
"Interac": {
diff --git a/crates/api_models/src/webhooks.rs b/crates/api_models/src/webhooks.rs
index 384aa62269..58b2d444b7 100644
--- a/crates/api_models/src/webhooks.rs
+++ b/crates/api_models/src/webhooks.rs
@@ -326,6 +326,15 @@ impl From<IncomingWebhookEvent> for WebhookFlow {
}
}
+impl From<IncomingWebhookEvent> for common_enums::IncomingWebhookEventType {
+ fn from(value: IncomingWebhookEvent) -> Self {
+ match value {
+ IncomingWebhookEvent::PaymentIntentCaptureFailure => Self::PaymentIntentCaptureFailure,
+ _ => Self::Other,
+ }
+ }
+}
+
pub type MerchantWebhookConfig = std::collections::HashSet<IncomingWebhookEvent>;
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index 70b6bfba73..31109e17a8 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -172,6 +172,7 @@ pub enum AttemptStatus {
DeviceDataCollectionPending,
IntegrityFailure,
Expired,
+ CaptureReview,
}
impl AttemptStatus {
@@ -204,7 +205,8 @@ impl AttemptStatus {
| Self::ConfirmationAwaited
| Self::DeviceDataCollectionPending
| Self::IntegrityFailure
- | Self::VoidedPostCharge => false,
+ | Self::VoidedPostCharge
+ | Self::CaptureReview => false,
}
}
@@ -237,7 +239,8 @@ impl AttemptStatus {
| Self::PaymentMethodAwaited
| Self::ConfirmationAwaited
| Self::DeviceDataCollectionPending
- | Self::IntegrityFailure => false,
+ | Self::IntegrityFailure
+ | Self::CaptureReview => false,
}
}
@@ -274,7 +277,8 @@ impl AttemptStatus {
| Self::ConfirmationAwaited
| Self::DeviceDataCollectionPending
| Self::IntegrityFailure
- | Self::Expired => false,
+ | Self::Expired
+ | Self::CaptureReview => false,
}
}
}
@@ -801,11 +805,21 @@ pub enum CallConnectorAction {
error_code: Option<String>,
error_message: Option<String>,
},
- HandleResponse(Vec<u8>),
+ HandleResponse {
+ resource_object: Vec<u8>,
+ event_type: Option<IncomingWebhookEventType>,
+ },
UCSConsumeResponse(Vec<u8>),
HandleResponseWithoutBuildRequest,
}
+/// For denoting the webhook event type in CallConnectorAction,
+#[derive(Clone, Copy, PartialEq, Debug)]
+pub enum IncomingWebhookEventType {
+ PaymentIntentCaptureFailure,
+ Other,
+}
+
/// The three-letter ISO 4217 currency code (e.g., "USD", "EUR") for the payment amount. This field is mandatory for creating a payment.
#[allow(clippy::upper_case_acronyms)]
#[derive(
@@ -1984,6 +1998,11 @@ pub enum IntentStatus {
Conflicted,
/// The payment expired before it could be captured.
Expired,
+ /// The payment has been marked for manual review due to anomalous response from the connector.
+ /// This can occur when a capture fails after the payment was initially marked as successful
+ /// (e.g., Adyen CAPTURE_FAILED webhook after successful CAPTURE).
+ /// The merchant can explicitly resolve this status via the API or a webhook from the connector can update the status
+ Review,
}
impl IntentStatus {
@@ -2005,7 +2024,8 @@ impl IntentStatus {
| Self::PartiallyCapturedAndCapturable
| Self::PartiallyAuthorizedAndRequiresCapture
| Self::Conflicted
- | Self::PartiallyCapturedAndProcessing => false,
+ | Self::PartiallyCapturedAndProcessing
+ | Self::Review => false,
}
}
@@ -2021,7 +2041,7 @@ impl IntentStatus {
| Self::Cancelled
| Self::CancelledPostCapture
| Self::PartiallyCaptured
- | Self::RequiresCapture | Self::Conflicted | Self::Expired=> false,
+ | Self::RequiresCapture | Self::Conflicted | Self::Expired | Self::Review => false,
Self::Processing
| Self::RequiresCustomerAction
| Self::RequiresMerchantAction
@@ -2225,7 +2245,8 @@ impl From<AttemptStatus> for PaymentMethodStatus {
| AttemptStatus::ConfirmationAwaited
| AttemptStatus::DeviceDataCollectionPending
| AttemptStatus::IntegrityFailure
- | AttemptStatus::Expired => Self::Inactive,
+ | AttemptStatus::Expired
+ | AttemptStatus::CaptureReview => Self::Inactive,
AttemptStatus::Charged | AttemptStatus::Authorized => Self::Active,
}
}
@@ -3037,7 +3058,8 @@ impl RelayStatus {
| AttemptStatus::Authorizing
| AttemptStatus::CaptureInitiated
| AttemptStatus::AuthenticationPending
- | AttemptStatus::Started => Self::Pending,
+ | AttemptStatus::Started
+ | AttemptStatus::CaptureReview => Self::Pending,
AttemptStatus::Voided | AttemptStatus::VoidedPostCharge => Self::Success,
}
}
@@ -10183,7 +10205,8 @@ impl From<AttemptStatus> for RelayStatus {
| AttemptStatus::Authorizing
| AttemptStatus::CaptureInitiated
| AttemptStatus::AuthenticationPending
- | AttemptStatus::Started => Self::Pending,
+ | AttemptStatus::Started
+ | AttemptStatus::CaptureReview => Self::Pending,
AttemptStatus::Charged
| AttemptStatus::PartialCharged
| AttemptStatus::PartialChargedAndChargeable => Self::Success,
@@ -10912,7 +10935,8 @@ impl From<IntentStatus> for InvoiceStatus {
| IntentStatus::Processing
| IntentStatus::RequiresCustomerAction
| IntentStatus::RequiresConfirmation
- | IntentStatus::RequiresPaymentMethod => Self::PaymentPending,
+ | IntentStatus::RequiresPaymentMethod
+ | IntentStatus::Review => Self::PaymentPending,
IntentStatus::RequiresMerchantAction => Self::ManualReview,
IntentStatus::Cancelled | IntentStatus::CancelledPostCapture => Self::PaymentCanceled,
IntentStatus::Expired => Self::PaymentPendingTimeout,
diff --git a/crates/common_enums/src/transformers.rs b/crates/common_enums/src/transformers.rs
index 41d1fc443c..98513b104e 100644
--- a/crates/common_enums/src/transformers.rs
+++ b/crates/common_enums/src/transformers.rs
@@ -2138,6 +2138,7 @@ impl From<AttemptStatus> for IntentStatus {
AttemptStatus::VoidedPostCharge => Self::CancelledPostCapture,
AttemptStatus::Expired => Self::Expired,
AttemptStatus::PartiallyAuthorized => Self::PartiallyAuthorizedAndRequiresCapture,
+ AttemptStatus::CaptureReview => Self::Review,
}
}
}
@@ -2152,7 +2153,8 @@ impl From<IntentStatus> for Option<EventType> {
}
IntentStatus::RequiresMerchantAction
| IntentStatus::RequiresCustomerAction
- | IntentStatus::Conflicted => Some(EventType::ActionRequired),
+ | IntentStatus::Conflicted
+ | IntentStatus::Review => Some(EventType::ActionRequired),
IntentStatus::Cancelled => Some(EventType::PaymentCancelled),
IntentStatus::CancelledPostCapture => Some(EventType::PaymentCancelledPostCapture),
IntentStatus::Expired => Some(EventType::PaymentExpired),
diff --git a/crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs b/crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs
index 2ba77313d4..7b9440063f 100644
--- a/crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs
@@ -926,7 +926,8 @@ impl TryFrom<enums::AttemptStatus> for ChargebeeRecordStatus {
| enums::AttemptStatus::ConfirmationAwaited
| enums::AttemptStatus::DeviceDataCollectionPending
| enums::AttemptStatus::IntegrityFailure
- | enums::AttemptStatus::Expired => Err(errors::ConnectorError::NotSupported {
+ | enums::AttemptStatus::Expired
+ | enums::AttemptStatus::CaptureReview => Err(errors::ConnectorError::NotSupported {
message: "Record back flow is only supported for terminal status".to_string(),
connector: "chargebee",
}
diff --git a/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs b/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
index 67151dd7f0..2d5401fbf0 100644
--- a/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
@@ -3220,7 +3220,8 @@ impl TryFrom<PaymentsCaptureResponseRouterData<PaypalCaptureResponse>>
| storage_enums::AttemptStatus::Voided
| storage_enums::AttemptStatus::VoidedPostCharge
| storage_enums::AttemptStatus::Expired
- | storage_enums::AttemptStatus::PartiallyAuthorized => 0,
+ | storage_enums::AttemptStatus::PartiallyAuthorized
+ | storage_enums::AttemptStatus::CaptureReview => 0,
storage_enums::AttemptStatus::Charged
| storage_enums::AttemptStatus::PartialCharged
| storage_enums::AttemptStatus::PartialChargedAndChargeable
diff --git a/crates/hyperswitch_connectors/src/connectors/recurly/transformers.rs b/crates/hyperswitch_connectors/src/connectors/recurly/transformers.rs
index fef42141bf..d7598d641f 100644
--- a/crates/hyperswitch_connectors/src/connectors/recurly/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/recurly/transformers.rs
@@ -299,7 +299,8 @@ impl TryFrom<enums::AttemptStatus> for RecurlyRecordStatus {
| enums::AttemptStatus::ConfirmationAwaited
| enums::AttemptStatus::DeviceDataCollectionPending
| enums::AttemptStatus::IntegrityFailure
- | enums::AttemptStatus::Expired => Err(errors::ConnectorError::NotSupported {
+ | enums::AttemptStatus::Expired
+ | enums::AttemptStatus::CaptureReview => Err(errors::ConnectorError::NotSupported {
message: "Record back flow is only supported for terminal status".to_string(),
connector: "recurly",
}
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index 481a7b57a0..335e89500f 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -493,7 +493,8 @@ pub(crate) fn is_successful_terminal_status(status: AttemptStatus) -> bool {
| AttemptStatus::DeviceDataCollectionPending
| AttemptStatus::IntegrityFailure
| AttemptStatus::VoidFailed
- | AttemptStatus::Expired => false,
+ | AttemptStatus::Expired
+ | AttemptStatus::CaptureReview => false,
}
}
@@ -526,7 +527,8 @@ pub(crate) fn is_payment_failure(status: AttemptStatus) -> bool {
| AttemptStatus::ConfirmationAwaited
| AttemptStatus::DeviceDataCollectionPending
| AttemptStatus::IntegrityFailure
- | AttemptStatus::PartiallyAuthorized => false,
+ | AttemptStatus::PartiallyAuthorized
+ | AttemptStatus::CaptureReview => false,
}
}
@@ -7758,7 +7760,8 @@ impl FrmTransactionRouterDataRequest for FrmTransactionRouterData {
| AttemptStatus::Pending
| AttemptStatus::PaymentMethodAwaited
| AttemptStatus::ConfirmationAwaited
- | AttemptStatus::DeviceDataCollectionPending => None,
+ | AttemptStatus::DeviceDataCollectionPending
+ | AttemptStatus::CaptureReview => None,
}
}
}
diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rs
index 888d16a5b8..1e6ebbaac8 100644
--- a/crates/hyperswitch_domain_models/src/payments.rs
+++ b/crates/hyperswitch_domain_models/src/payments.rs
@@ -1202,7 +1202,8 @@ impl PaymentIntent {
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
| common_enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture
| common_enums::IntentStatus::PartiallyCapturedAndProcessing
- | common_enums::IntentStatus::Conflicted => false,
+ | common_enums::IntentStatus::Conflicted
+ | common_enums::IntentStatus::Review => false,
}
}
}
diff --git a/crates/hyperswitch_domain_models/src/router_data.rs b/crates/hyperswitch_domain_models/src/router_data.rs
index 72dea02708..4fec25e8db 100644
--- a/crates/hyperswitch_domain_models/src/router_data.rs
+++ b/crates/hyperswitch_domain_models/src/router_data.rs
@@ -1184,7 +1184,8 @@ impl
common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
| common_enums::IntentStatus::Processing
- | common_enums::IntentStatus::PartiallyCapturedAndProcessing => None,
+ | common_enums::IntentStatus::PartiallyCapturedAndProcessing
+ | common_enums::IntentStatus::Review => None,
// Invalid states for this flow
common_enums::IntentStatus::RequiresPaymentMethod
| common_enums::IntentStatus::RequiresConfirmation
@@ -1229,9 +1230,11 @@ impl
| common_enums::IntentStatus::RequiresMerchantAction
| common_enums::IntentStatus::Processing
| common_enums::IntentStatus::PartiallyCapturedAndProcessing => Some(MinorUnit::zero()),
+
// Invalid states for this flow
common_enums::IntentStatus::RequiresPaymentMethod
- | common_enums::IntentStatus::RequiresConfirmation => None,
+ | common_enums::IntentStatus::RequiresConfirmation
+ | common_enums::IntentStatus::Review => None,
// No amount has been captured yet
common_enums::IntentStatus::RequiresCapture
| common_enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture => {
@@ -1430,7 +1433,8 @@ impl
common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
| common_enums::IntentStatus::Processing
- | common_enums::IntentStatus::PartiallyCapturedAndProcessing => None,
+ | common_enums::IntentStatus::PartiallyCapturedAndProcessing
+ | common_enums::IntentStatus::Review => None,
// Invalid states for this flow
common_enums::IntentStatus::RequiresPaymentMethod
| common_enums::IntentStatus::RequiresConfirmation => None,
@@ -1479,7 +1483,8 @@ impl
common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
| common_enums::IntentStatus::Processing
- | common_enums::IntentStatus::PartiallyCapturedAndProcessing => None,
+ | common_enums::IntentStatus::PartiallyCapturedAndProcessing
+ | common_enums::IntentStatus::Review => None,
// Invalid states for this flow
common_enums::IntentStatus::RequiresPaymentMethod
| common_enums::IntentStatus::RequiresConfirmation => None,
@@ -1768,7 +1773,8 @@ impl
common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
| common_enums::IntentStatus::Processing
- | common_enums::IntentStatus::PartiallyCapturedAndProcessing => None,
+ | common_enums::IntentStatus::PartiallyCapturedAndProcessing
+ | common_enums::IntentStatus::Review => None,
// Invalid states for this flow
common_enums::IntentStatus::RequiresPaymentMethod
| common_enums::IntentStatus::RequiresConfirmation => None,
@@ -1811,7 +1817,9 @@ impl
| common_enums::IntentStatus::PartiallyCapturedAndProcessing => Some(MinorUnit::zero()),
// Invalid states for this flow
common_enums::IntentStatus::RequiresPaymentMethod
- | common_enums::IntentStatus::RequiresConfirmation => None,
+ | common_enums::IntentStatus::RequiresConfirmation
+ | common_enums::IntentStatus::Review => None,
+
common_enums::IntentStatus::RequiresCapture
| common_enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture => {
Some(MinorUnit::zero())
@@ -2044,7 +2052,8 @@ impl
common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
| common_enums::IntentStatus::Processing
- | common_enums::IntentStatus::PartiallyCapturedAndProcessing => None,
+ | common_enums::IntentStatus::PartiallyCapturedAndProcessing
+ | common_enums::IntentStatus::Review => None,
common_enums::IntentStatus::RequiresPaymentMethod
| common_enums::IntentStatus::RequiresConfirmation => None,
common_enums::IntentStatus::RequiresCapture
@@ -2076,7 +2085,8 @@ impl
common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
| common_enums::IntentStatus::Processing
- | common_enums::IntentStatus::PartiallyCapturedAndProcessing => None,
+ | common_enums::IntentStatus::PartiallyCapturedAndProcessing
+ | common_enums::IntentStatus::Review => None,
common_enums::IntentStatus::RequiresPaymentMethod
| common_enums::IntentStatus::RequiresConfirmation => None,
common_enums::IntentStatus::RequiresCapture
@@ -2297,7 +2307,8 @@ impl
common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
| common_enums::IntentStatus::Processing
- | common_enums::IntentStatus::PartiallyCapturedAndProcessing => None,
+ | common_enums::IntentStatus::PartiallyCapturedAndProcessing
+ | common_enums::IntentStatus::Review => None,
// Invalid states for this flow
common_enums::IntentStatus::RequiresPaymentMethod
| common_enums::IntentStatus::RequiresConfirmation => None,
@@ -2338,7 +2349,8 @@ impl
common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
| common_enums::IntentStatus::Processing
- | common_enums::IntentStatus::PartiallyCapturedAndProcessing => None,
+ | common_enums::IntentStatus::PartiallyCapturedAndProcessing
+ | common_enums::IntentStatus::Review => None,
// Invalid states for this flow
common_enums::IntentStatus::RequiresPaymentMethod
| common_enums::IntentStatus::RequiresConfirmation => None,
diff --git a/crates/hyperswitch_interfaces/src/api_client.rs b/crates/hyperswitch_interfaces/src/api_client.rs
index 8f0742168e..9784543a0a 100644
--- a/crates/hyperswitch_interfaces/src/api_client.rs
+++ b/crates/hyperswitch_interfaces/src/api_client.rs
@@ -156,10 +156,10 @@ where
logger::debug!(connector_request=?connector_request);
let mut router_data = req.clone();
match call_connector_action {
- common_enums::CallConnectorAction::HandleResponse(res) => {
+ common_enums::CallConnectorAction::HandleResponse{ resource_object, event_type: _ } => {
let response = types::Response {
headers: None,
- response: res.into(),
+ response: resource_object.into(),
status_code: 200,
};
connector_integration.handle_response(req, None, response)
diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs
index 9ed09bbb2d..1731b87b82 100644
--- a/crates/router/src/compatibility/stripe/payment_intents/types.rs
+++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs
@@ -429,7 +429,8 @@ impl From<api_enums::IntentStatus> for StripePaymentStatus {
| api_enums::IntentStatus::PartiallyCapturedAndProcessing => Self::Processing,
api_enums::IntentStatus::RequiresCustomerAction
| api_enums::IntentStatus::RequiresMerchantAction
- | api_enums::IntentStatus::Conflicted => Self::RequiresAction,
+ | api_enums::IntentStatus::Conflicted
+ | api_enums::IntentStatus::Review => Self::RequiresAction,
api_enums::IntentStatus::RequiresPaymentMethod => Self::RequiresPaymentMethod,
api_enums::IntentStatus::RequiresConfirmation => Self::RequiresConfirmation,
api_enums::IntentStatus::RequiresCapture
diff --git a/crates/router/src/compatibility/stripe/setup_intents/types.rs b/crates/router/src/compatibility/stripe/setup_intents/types.rs
index 7e729782da..6874ea0d91 100644
--- a/crates/router/src/compatibility/stripe/setup_intents/types.rs
+++ b/crates/router/src/compatibility/stripe/setup_intents/types.rs
@@ -320,7 +320,8 @@ impl From<api_enums::IntentStatus> for StripeSetupStatus {
| api_enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture => Self::Processing,
api_enums::IntentStatus::RequiresCustomerAction => Self::RequiresAction,
api_enums::IntentStatus::RequiresMerchantAction
- | api_enums::IntentStatus::Conflicted => Self::RequiresAction,
+ | api_enums::IntentStatus::Conflicted
+ | api_enums::IntentStatus::Review => Self::RequiresAction,
api_enums::IntentStatus::RequiresPaymentMethod => Self::RequiresPaymentMethod,
api_enums::IntentStatus::RequiresConfirmation => Self::RequiresConfirmation,
api_enums::IntentStatus::RequiresCapture
diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs
index 4891908ccb..c861240c15 100644
--- a/crates/router/src/connector/utils.rs
+++ b/crates/router/src/connector/utils.rs
@@ -255,6 +255,14 @@ where
Ok(self.status)
}
}
+ enums::AttemptStatus::CaptureFailed => {
+ // If the intent has already been marked successful but we receive a CaptureFailed event for the payment attempt (via webhook), mark it as Review
+ if payment_data.payment_intent.status == enums::IntentStatus::Succeeded {
+ Ok(enums::AttemptStatus::CaptureReview)
+ } else {
+ Ok(self.status)
+ }
+ }
_ => Ok(self.status),
}
}
@@ -2325,7 +2333,8 @@ impl FrmTransactionRouterDataRequest for fraud_check::FrmTransactionRouterData {
| storage_enums::AttemptStatus::PaymentMethodAwaited
| storage_enums::AttemptStatus::ConfirmationAwaited
| storage_enums::AttemptStatus::DeviceDataCollectionPending
- | storage_enums::AttemptStatus::IntegrityFailure => None,
+ | storage_enums::AttemptStatus::IntegrityFailure
+ | storage_enums::AttemptStatus::CaptureReview => None,
}
}
}
@@ -2359,7 +2368,8 @@ pub fn is_payment_failure(status: enums::AttemptStatus) -> bool {
| common_enums::AttemptStatus::ConfirmationAwaited
| common_enums::AttemptStatus::DeviceDataCollectionPending
| common_enums::AttemptStatus::IntegrityFailure
- | common_enums::AttemptStatus::PartiallyAuthorized => false,
+ | common_enums::AttemptStatus::PartiallyAuthorized
+ | common_enums::AttemptStatus::CaptureReview => false,
}
}
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index f27a6d5b95..e271b338ec 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -772,6 +772,7 @@ where
eligible_connectors,
mandate_type,
&dimensions,
+ call_connector_action.clone(),
)
.await?;
@@ -1567,11 +1568,14 @@ where
&payment_data.get_payment_intent().clone(),
)?;
- common_utils::fp_utils::when(!should_call_connector(&operation, &payment_data), || {
- Err(errors::ApiErrorResponse::IncorrectPaymentMethodConfiguration).attach_printable(format!(
+ common_utils::fp_utils::when(
+ !should_call_connector(&operation, &payment_data, call_connector_action.clone()),
+ || {
+ Err(errors::ApiErrorResponse::IncorrectPaymentMethodConfiguration).attach_printable(format!(
"Nti and card details based mit flow is not support for this {operation:?} payment operation"
))
- })?;
+ },
+ )?;
let connector_choice = operation
.to_domain()?
@@ -4036,7 +4040,8 @@ impl ValidateStatusForOperation for &PaymentRedirectSync {
| common_enums::IntentStatus::PartiallyCapturedAndProcessing
| common_enums::IntentStatus::RequiresConfirmation
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
- | common_enums::IntentStatus::Expired => {
+ | common_enums::IntentStatus::Expired
+ | common_enums::IntentStatus::Review => {
Err(errors::ApiErrorResponse::PaymentUnexpectedState {
current_flow: format!("{self:?}"),
field_name: "status".to_string(),
@@ -9011,7 +9016,11 @@ where
}
#[cfg(feature = "v1")]
-pub fn should_call_connector<Op: Debug, F: Clone, D>(operation: &Op, payment_data: &D) -> bool
+pub fn should_call_connector<Op: Debug, F: Clone, D>(
+ operation: &Op,
+ payment_data: &D,
+ call_connector_action: CallConnectorAction,
+) -> bool
where
D: OperationSessionGetters<F> + Send + Sync + Clone,
{
@@ -9027,15 +9036,36 @@ where
.is_none()
}
"PaymentStatus" => {
+ let in_progress = matches!(
+ payment_data.get_payment_intent().status,
+ storage_enums::IntentStatus::Processing
+ | storage_enums::IntentStatus::RequiresCustomerAction
+ | storage_enums::IntentStatus::RequiresMerchantAction
+ | storage_enums::IntentStatus::RequiresCapture
+ | storage_enums::IntentStatus::PartiallyCapturedAndCapturable
+ );
+
+ // Allow only capture failure webhooks to be processed over succeeded payments.
+ // This prevents out-of-order processing issues where other webhooks (e.g., pending)
+ // could interfere with settled payments.
+ let capture_failure_webhook_over_success_payment = matches!(
+ payment_data.get_payment_intent().status,
+ storage_enums::IntentStatus::Succeeded
+ ) && matches!(
+ call_connector_action,
+ CallConnectorAction::HandleResponse {
+ event_type: Some(
+ storage_enums::IncomingWebhookEventType::PaymentIntentCaptureFailure
+ ),
+ ..
+ }
+ );
+
+ let force_sync = payment_data.get_force_sync().unwrap_or(false);
+
payment_data.get_all_keys_required().unwrap_or(false)
- || matches!(
- payment_data.get_payment_intent().status,
- storage_enums::IntentStatus::Processing
- | storage_enums::IntentStatus::RequiresCustomerAction
- | storage_enums::IntentStatus::RequiresMerchantAction
- | storage_enums::IntentStatus::RequiresCapture
- | storage_enums::IntentStatus::PartiallyCapturedAndCapturable
- ) && payment_data.get_force_sync().unwrap_or(false)
+ || (in_progress && force_sync)
+ || capture_failure_webhook_over_success_payment
}
"PaymentCancel" => matches!(
payment_data.get_payment_intent().status,
@@ -9785,6 +9815,7 @@ pub async fn choose_connector<F, Req, D>(
eligible_connectors: Option<Vec<enums::RoutableConnectors>>,
mandate_type: Option<api::MandateTransactionType>,
dimensions: &DimensionsWithProcessorAndProviderMerchantIdAndProfileId,
+ call_connector_action: CallConnectorAction,
) -> RouterResult<Option<ConnectorCallType>>
where
F: Send + Clone,
@@ -9828,7 +9859,7 @@ where
Ok(backend_input) => {
let transaction_type = enums::TransactionType::Payment;
- if should_call_connector(operation, payment_data) {
+ if should_call_connector(operation, payment_data, call_connector_action) {
Some(match connector_choice {
api::ConnectorChoice::SessionMultiple(connectors) => {
let routing_output = perform_session_token_routing(
diff --git a/crates/router/src/core/payments/flows/psync_flow.rs b/crates/router/src/core/payments/flows/psync_flow.rs
index f16e1e953a..ad78ca9a8c 100644
--- a/crates/router/src/core/payments/flows/psync_flow.rs
+++ b/crates/router/src/core/payments/flows/psync_flow.rs
@@ -263,7 +263,7 @@ impl RouterDataPSync
gateway_context: payments::flows::gateway_context::RouterGatewayContext,
) -> RouterResult<Self> {
let mut capture_sync_response_map = HashMap::new();
- if let payments::CallConnectorAction::HandleResponse(_) = call_connector_action {
+ if let payments::CallConnectorAction::HandleResponse { .. } = call_connector_action {
// webhook consume flow, only call connector once. Since there will only be a single event in every webhook
let resp = services::execute_connector_processing_step(
state,
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 610787d3c5..e21f7d2542 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -5161,7 +5161,8 @@ pub fn get_attempt_type(
| enums::AttemptStatus::DeviceDataCollectionPending
| enums::AttemptStatus::IntegrityFailure
| enums::AttemptStatus::Expired
- | enums::AttemptStatus::PartiallyAuthorized => {
+ | enums::AttemptStatus::PartiallyAuthorized
+ | enums::AttemptStatus::CaptureReview => {
metrics::MANUAL_RETRY_VALIDATION_FAILED.add(
1,
router_env::metric_attributes!((
@@ -5221,7 +5222,8 @@ pub fn get_attempt_type(
| enums::IntentStatus::Succeeded
| enums::IntentStatus::Conflicted
| enums::IntentStatus::Expired
- | enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture => {
+ | enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture
+ | enums::IntentStatus::Review => {
Err(report!(errors::ApiErrorResponse::PreconditionFailed {
message: format!(
"You cannot {action} this payment because it has status {}",
@@ -5511,7 +5513,8 @@ pub fn is_manual_retry_allowed(
| enums::AttemptStatus::DeviceDataCollectionPending
| enums::AttemptStatus::IntegrityFailure
| enums::AttemptStatus::Expired
- | enums::AttemptStatus::PartiallyAuthorized => {
+ | enums::AttemptStatus::PartiallyAuthorized
+ | enums::AttemptStatus::CaptureReview => {
logger::error!("Payment Attempt should not be in this state because Attempt to Intent status mapping doesn't allow it");
None
}
@@ -5534,7 +5537,8 @@ pub fn is_manual_retry_allowed(
| enums::IntentStatus::Succeeded
| enums::IntentStatus::Conflicted
| enums::IntentStatus::Expired
- | enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture => Some(false),
+ | enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture
+ | enums::IntentStatus::Review => Some(false),
enums::IntentStatus::RequiresCustomerAction
| enums::IntentStatus::RequiresMerchantAction
diff --git a/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs b/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs
index 9637d33ca1..abc6189472 100644
--- a/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs
+++ b/crates/router/src/core/payments/operations/external_vault_proxy_payment_intent.rs
@@ -61,7 +61,8 @@ impl ValidateStatusForOperation for ExternalVaultProxyPaymentIntent {
| common_enums::IntentStatus::CancelledPostCapture
| common_enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture
| common_enums::IntentStatus::PartiallyCapturedAndProcessing
- | common_enums::IntentStatus::Expired => {
+ | common_enums::IntentStatus::Expired
+ | common_enums::IntentStatus::Review => {
Err(errors::ApiErrorResponse::PaymentUnexpectedState {
current_flow: format!("{self:?}"),
field_name: "status".to_string(),
diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rs
index 85d838ed7a..6c6fadae90 100644
--- a/crates/router/src/core/payments/operations/payment_approve.rs
+++ b/crates/router/src/core/payments/operations/payment_approve.rs
@@ -69,7 +69,11 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCaptureR
helpers::validate_payment_status_against_not_allowed_statuses(
payment_intent.status,
- &[IntentStatus::Failed, IntentStatus::Succeeded],
+ &[
+ IntentStatus::Failed,
+ IntentStatus::Succeeded,
+ IntentStatus::Review,
+ ],
"approve",
)?;
diff --git a/crates/router/src/core/payments/operations/payment_attempt_record.rs b/crates/router/src/core/payments/operations/payment_attempt_record.rs
index c11b4aaca5..22e236fb95 100644
--- a/crates/router/src/core/payments/operations/payment_attempt_record.rs
+++ b/crates/router/src/core/payments/operations/payment_attempt_record.rs
@@ -91,7 +91,8 @@ impl ValidateStatusForOperation for PaymentAttemptRecord {
| common_enums::IntentStatus::PartiallyCaptured
| common_enums::IntentStatus::RequiresConfirmation
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
- | common_enums::IntentStatus::Expired => {
+ | common_enums::IntentStatus::Expired
+ | common_enums::IntentStatus::Review => {
Err(errors::ApiErrorResponse::PaymentUnexpectedState {
current_flow: format!("{self:?}"),
field_name: "status".to_string(),
diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rs
index e6d8c7f327..7edaaab610 100644
--- a/crates/router/src/core/payments/operations/payment_cancel.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel.rs
@@ -76,6 +76,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRe
enums::IntentStatus::Cancelled,
enums::IntentStatus::Processing,
enums::IntentStatus::RequiresMerchantAction,
+ enums::IntentStatus::Review,
],
"cancel",
)?;
diff --git a/crates/router/src/core/payments/operations/payment_cancel_v2.rs b/crates/router/src/core/payments/operations/payment_cancel_v2.rs
index 0354a5df31..d044098074 100644
--- a/crates/router/src/core/payments/operations/payment_cancel_v2.rs
+++ b/crates/router/src/core/payments/operations/payment_cancel_v2.rs
@@ -328,7 +328,8 @@ impl ValidateStatusForOperation for PaymentsCancel {
| common_enums::IntentStatus::RequiresConfirmation
| common_enums::IntentStatus::PartiallyCaptured
| common_enums::IntentStatus::Conflicted
- | common_enums::IntentStatus::Expired => {
+ | common_enums::IntentStatus::Expired
+ | common_enums::IntentStatus::Review => {
Err(errors::ApiErrorResponse::PaymentUnexpectedState {
current_flow: format!("{self:?}"),
field_name: "status".to_string(),
diff --git a/crates/router/src/core/payments/operations/payment_capture_v2.rs b/crates/router/src/core/payments/operations/payment_capture_v2.rs
index 8281810b34..324871e1bf 100644
--- a/crates/router/src/core/payments/operations/payment_capture_v2.rs
+++ b/crates/router/src/core/payments/operations/payment_capture_v2.rs
@@ -48,7 +48,8 @@ impl ValidateStatusForOperation for PaymentsCapture {
| common_enums::IntentStatus::RequiresPaymentMethod
| common_enums::IntentStatus::PartiallyCaptured
| common_enums::IntentStatus::RequiresConfirmation
- | common_enums::IntentStatus::Expired => {
+ | common_enums::IntentStatus::Expired
+ | common_enums::IntentStatus::Review => {
Err(errors::ApiErrorResponse::PaymentUnexpectedState {
current_flow: format!("{self:?}"),
field_name: "status".to_string(),
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 670b7f34dc..07de33da39 100644
--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs
+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
@@ -86,6 +86,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
&[
storage_enums::IntentStatus::Failed,
storage_enums::IntentStatus::Succeeded,
+ storage_enums::IntentStatus::Review,
],
"confirm",
)?;
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index 9994aeea47..12ac72307e 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -146,6 +146,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
storage_enums::IntentStatus::Processing,
storage_enums::IntentStatus::RequiresCapture,
storage_enums::IntentStatus::RequiresMerchantAction,
+ storage_enums::IntentStatus::Review,
],
"confirm",
)?;
@@ -159,6 +160,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
storage_enums::IntentStatus::RequiresCapture,
storage_enums::IntentStatus::RequiresMerchantAction,
storage_enums::IntentStatus::RequiresCustomerAction,
+ storage_enums::IntentStatus::Review,
],
"confirm",
)?;
diff --git a/crates/router/src/core/payments/operations/payment_confirm_intent.rs b/crates/router/src/core/payments/operations/payment_confirm_intent.rs
index ade6a41678..8348d2e9c7 100644
--- a/crates/router/src/core/payments/operations/payment_confirm_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm_intent.rs
@@ -58,7 +58,8 @@ impl ValidateStatusForOperation for PaymentIntentConfirm {
| common_enums::IntentStatus::PartiallyCaptured
| common_enums::IntentStatus::RequiresConfirmation
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
- | common_enums::IntentStatus::Expired => {
+ | common_enums::IntentStatus::Expired
+ | common_enums::IntentStatus::Review => {
Err(errors::ApiErrorResponse::PaymentUnexpectedState {
current_flow: format!("{self:?}"),
field_name: "status".to_string(),
diff --git a/crates/router/src/core/payments/operations/payment_get.rs b/crates/router/src/core/payments/operations/payment_get.rs
index f76c08d6ca..ca487d14c5 100644
--- a/crates/router/src/core/payments/operations/payment_get.rs
+++ b/crates/router/src/core/payments/operations/payment_get.rs
@@ -47,7 +47,8 @@ impl ValidateStatusForOperation for PaymentGet {
| common_enums::IntentStatus::Cancelled
| common_enums::IntentStatus::CancelledPostCapture
| common_enums::IntentStatus::Conflicted
- | common_enums::IntentStatus::Expired => Ok(()),
+ | common_enums::IntentStatus::Expired
+ | common_enums::IntentStatus::Review => Ok(()),
// These statuses are not valid for this operation
common_enums::IntentStatus::RequiresConfirmation
| common_enums::IntentStatus::RequiresPaymentMethod => {
@@ -66,6 +67,7 @@ impl ValidateStatusForOperation for PaymentGet {
common_enums::IntentStatus::PartiallyCapturedAndCapturable,
common_enums::IntentStatus::PartiallyCaptured,
common_enums::IntentStatus::Cancelled,
+ common_enums::IntentStatus::Review,
]
.map(|enum_value| enum_value.to_string())
.join(", "),
diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rs
index 84c825a2ff..e8b90e8192 100644
--- a/crates/router/src/core/payments/operations/payment_reject.rs
+++ b/crates/router/src/core/payments/operations/payment_reject.rs
@@ -71,6 +71,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, PaymentsCancelRequest
enums::IntentStatus::Failed,
enums::IntentStatus::Succeeded,
enums::IntentStatus::Processing,
+ enums::IntentStatus::Review,
],
"reject",
)?;
diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs
index e37eb116f6..4f1ec7d1a5 100644
--- a/crates/router/src/core/payments/operations/payment_response.rs
+++ b/crates/router/src/core/payments/operations/payment_response.rs
@@ -3314,7 +3314,8 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor
| common_enums::AttemptStatus::Unresolved
| common_enums::AttemptStatus::Pending
| common_enums::AttemptStatus::Failure
- | common_enums::AttemptStatus::Expired => (),
+ | common_enums::AttemptStatus::Expired
+ | common_enums::AttemptStatus::CaptureReview => (),
common_enums::AttemptStatus::Started
| common_enums::AttemptStatus::AuthenticationPending
diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rs
index 128500ca67..6e337ab70d 100644
--- a/crates/router/src/core/payments/operations/payment_session.rs
+++ b/crates/router/src/core/payments/operations/payment_session.rs
@@ -76,6 +76,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsSessionR
&[
storage_enums::IntentStatus::Failed,
storage_enums::IntentStatus::Succeeded,
+ storage_enums::IntentStatus::Review,
],
"create a session token for",
)?;
diff --git a/crates/router/src/core/payments/operations/payment_session_intent.rs b/crates/router/src/core/payments/operations/payment_session_intent.rs
index 8b85f46ade..39ed19574a 100644
--- a/crates/router/src/core/payments/operations/payment_session_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_session_intent.rs
@@ -45,7 +45,7 @@ impl ValidateStatusForOperation for PaymentSessionIntent {
| common_enums::IntentStatus::RequiresConfirmation
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
| common_enums::IntentStatus::Succeeded
- | common_enums::IntentStatus::Failed | common_enums::IntentStatus::Conflicted | common_enums::IntentStatus::Expired => {
+ | common_enums::IntentStatus::Failed | common_enums::IntentStatus::Conflicted | common_enums::IntentStatus::Expired | common_enums::IntentStatus::Review=> {
Err(errors::ApiErrorResponse::PreconditionFailed {
message: format!(
"You cannot create session token for this payment because it has status {intent_status}. Expected status is requires_payment_method.",
diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rs
index 6619246452..38b1c2ba9c 100644
--- a/crates/router/src/core/payments/operations/payment_start.rs
+++ b/crates/router/src/core/payments/operations/payment_start.rs
@@ -75,6 +75,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsStartReq
&[
storage_enums::IntentStatus::Failed,
storage_enums::IntentStatus::Succeeded,
+ storage_enums::IntentStatus::Review,
],
"update",
)?;
diff --git a/crates/router/src/core/payments/operations/payment_update_intent.rs b/crates/router/src/core/payments/operations/payment_update_intent.rs
index a83bb24b2c..541f90c8b8 100644
--- a/crates/router/src/core/payments/operations/payment_update_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_update_intent.rs
@@ -65,7 +65,8 @@ impl ValidateStatusForOperation for PaymentUpdateIntent {
| common_enums::IntentStatus::PartiallyCapturedAndProcessing
| common_enums::IntentStatus::RequiresConfirmation
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
- | common_enums::IntentStatus::Expired => {
+ | common_enums::IntentStatus::Expired
+ | common_enums::IntentStatus::Review => {
Err(errors::ApiErrorResponse::PaymentUnexpectedState {
current_flow: format!("{self:?}"),
field_name: "status".to_string(),
diff --git a/crates/router/src/core/payments/operations/proxy_payments_intent.rs b/crates/router/src/core/payments/operations/proxy_payments_intent.rs
index c46c9dfb6e..d8655965b9 100644
--- a/crates/router/src/core/payments/operations/proxy_payments_intent.rs
+++ b/crates/router/src/core/payments/operations/proxy_payments_intent.rs
@@ -60,7 +60,8 @@ impl ValidateStatusForOperation for PaymentProxyIntent {
| common_enums::IntentStatus::RequiresConfirmation
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
| common_enums::IntentStatus::PartiallyCapturedAndProcessing
- | common_enums::IntentStatus::Expired => {
+ | common_enums::IntentStatus::Expired
+ | common_enums::IntentStatus::Review => {
Err(errors::ApiErrorResponse::PaymentUnexpectedState {
current_flow: format!("{self:?}"),
field_name: "status".to_string(),
diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rs
index 5099f0cf23..b241c96a87 100644
--- a/crates/router/src/core/payments/operations/tax_calculation.rs
+++ b/crates/router/src/core/payments/operations/tax_calculation.rs
@@ -84,6 +84,7 @@ impl<F: Send + Clone + Sync>
&[
storage_enums::IntentStatus::Failed,
storage_enums::IntentStatus::Succeeded,
+ storage_enums::IntentStatus::Review,
],
"create a session update for",
)?;
diff --git a/crates/router/src/core/payments/payment_methods.rs b/crates/router/src/core/payments/payment_methods.rs
index aa1c1a4672..3399deaf7a 100644
--- a/crates/router/src/core/payments/payment_methods.rs
+++ b/crates/router/src/core/payments/payment_methods.rs
@@ -792,7 +792,8 @@ fn validate_payment_status_for_payment_method_list(
| common_enums::IntentStatus::PartiallyCapturedAndProcessing
| common_enums::IntentStatus::RequiresConfirmation
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
- | common_enums::IntentStatus::Expired => {
+ | common_enums::IntentStatus::Expired
+ | common_enums::IntentStatus::Review => {
Err(errors::ApiErrorResponse::PaymentUnexpectedState {
current_flow: "list_payment_methods".to_string(),
field_name: "status".to_string(),
diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rs
index 82e057bdde..f93886233e 100644
--- a/crates/router/src/core/payments/retry.rs
+++ b/crates/router/src/core/payments/retry.rs
@@ -937,7 +937,8 @@ impl<F: Send + Clone + Sync, FData: Send + Sync>
| storage_enums::AttemptStatus::DeviceDataCollectionPending
| storage_enums::AttemptStatus::IntegrityFailure
| storage_enums::AttemptStatus::Expired
- | storage_enums::AttemptStatus::PartiallyAuthorized => false,
+ | storage_enums::AttemptStatus::PartiallyAuthorized
+ | storage_enums::AttemptStatus::CaptureReview => false,
storage_enums::AttemptStatus::AuthenticationFailed
| storage_enums::AttemptStatus::AuthorizationFailed
diff --git a/crates/router/src/core/revenue_recovery.rs b/crates/router/src/core/revenue_recovery.rs
index 21670e237c..0dc6206512 100644
--- a/crates/router/src/core/revenue_recovery.rs
+++ b/crates/router/src/core/revenue_recovery.rs
@@ -1198,11 +1198,10 @@ pub async fn resume_revenue_recovery_process_tracker(
| IntentStatus::PartiallyCapturedAndProcessing
| IntentStatus::Conflicted
| IntentStatus::Expired
- | IntentStatus::PartiallyCapturedAndProcessing => {
- Err(report!(errors::ApiErrorResponse::NotSupported {
- message: "Invalid Payment Status ".to_owned(),
- }))
- }
+ | IntentStatus::PartiallyCapturedAndProcessing
+ | IntentStatus::Review => Err(report!(errors::ApiErrorResponse::NotSupported {
+ message: "Invalid Payment Status ".to_owned(),
+ })),
}
}
pub async fn get_payment_response_using_payment_get_operation(
@@ -1454,7 +1453,8 @@ pub fn map_recovery_status(
IntentStatus::Cancelled
| IntentStatus::CancelledPostCapture
| IntentStatus::Conflicted
- | IntentStatus::Expired => RecoveryStatus::Terminated,
+ | IntentStatus::Expired
+ | IntentStatus::Review => RecoveryStatus::Terminated,
// For statuses that don't need recovery
IntentStatus::RequiresCustomerAction
diff --git a/crates/router/src/core/revenue_recovery/transformers.rs b/crates/router/src/core/revenue_recovery/transformers.rs
index 178241d3a4..605d09d2f4 100644
--- a/crates/router/src/core/revenue_recovery/transformers.rs
+++ b/crates/router/src/core/revenue_recovery/transformers.rs
@@ -26,7 +26,8 @@ impl ForeignFrom<IntentStatus> for RevenueRecoveryPaymentIntentStatus {
| IntentStatus::RequiresCapture
| IntentStatus::PartiallyAuthorizedAndRequiresCapture
| IntentStatus::Conflicted
- | IntentStatus::Expired => Self::InvalidStatus(status.to_string()),
+ | IntentStatus::Expired
+ | IntentStatus::Review => Self::InvalidStatus(status.to_string()),
}
}
}
diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rs
index cedf1096c8..cabd061e0c 100644
--- a/crates/router/src/core/routing/helpers.rs
+++ b/crates/router/src/core/routing/helpers.rs
@@ -1710,7 +1710,8 @@ fn get_desired_payment_status_for_dynamic_routing_metrics(
| common_enums::AttemptStatus::PaymentMethodAwaited
| common_enums::AttemptStatus::ConfirmationAwaited
| common_enums::AttemptStatus::DeviceDataCollectionPending
- | common_enums::AttemptStatus::Expired => common_enums::AttemptStatus::Pending,
+ | common_enums::AttemptStatus::Expired
+ | common_enums::AttemptStatus::CaptureReview => common_enums::AttemptStatus::Pending,
}
}
@@ -1740,13 +1741,14 @@ impl ForeignFrom<common_enums::AttemptStatus> for open_router::TxnStatus {
common_enums::AttemptStatus::AutoRefunded => Self::AutoRefunded,
common_enums::AttemptStatus::PartialCharged => Self::PartialCharged,
common_enums::AttemptStatus::PartialChargedAndChargeable => Self::ToBeCharged,
- common_enums::AttemptStatus::Unresolved => Self::Pending,
- common_enums::AttemptStatus::Pending
- | common_enums::AttemptStatus::IntegrityFailure => Self::Pending,
common_enums::AttemptStatus::Failure => Self::Failure,
- common_enums::AttemptStatus::PaymentMethodAwaited => Self::Pending,
- common_enums::AttemptStatus::ConfirmationAwaited => Self::Pending,
- common_enums::AttemptStatus::DeviceDataCollectionPending => Self::Pending,
+ common_enums::AttemptStatus::Unresolved
+ | common_enums::AttemptStatus::Pending
+ | common_enums::AttemptStatus::IntegrityFailure
+ | common_enums::AttemptStatus::PaymentMethodAwaited
+ | common_enums::AttemptStatus::ConfirmationAwaited
+ | common_enums::AttemptStatus::DeviceDataCollectionPending
+ | common_enums::AttemptStatus::CaptureReview => Self::Pending,
}
}
}
diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rs
index 825928a520..57698a8ef0 100644
--- a/crates/router/src/core/unified_connector_service.rs
+++ b/crates/router/src/core/unified_connector_service.rs
@@ -345,7 +345,7 @@ where
}
CallConnectorAction::Avoid
| CallConnectorAction::Trigger
- | CallConnectorAction::HandleResponse(_)
+ | CallConnectorAction::HandleResponse { .. }
| CallConnectorAction::HandleResponseWithoutBuildRequest
| CallConnectorAction::StatusUpdate { .. } => {
router_env::logger::debug!("UCS is disabled, using Direct gateway");
@@ -363,7 +363,7 @@ where
ExecutionPath::UnifiedConnectorService,
)
}
- CallConnectorAction::HandleResponse(_) => {
+ CallConnectorAction::HandleResponse { .. } => {
router_env::logger::info!(
"CallConnectorAction HandleResponse received, using Direct gateway"
);
diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rs
index 6800924d77..b2ba95cade 100644
--- a/crates/router/src/core/webhooks/incoming.rs
+++ b/crates/router/src/core/webhooks/incoming.rs
@@ -857,7 +857,10 @@ async fn payments_incoming_webhook_flow(
let resource_object = webhook_details.resource_object.clone();
match content {
super::gateway::WebhookContent::Direct(_) => {
- payments::CallConnectorAction::HandleResponse(resource_object)
+ payments::CallConnectorAction::HandleResponse {
+ resource_object,
+ event_type: Some(event_type.into()),
+ }
}
super::gateway::WebhookContent::UnifiedConnectorService(_) => {
payments::CallConnectorAction::UCSConsumeResponse(resource_object)
diff --git a/crates/router/src/core/webhooks/incoming_v2.rs b/crates/router/src/core/webhooks/incoming_v2.rs
index e970e852b5..211fb5480b 100644
--- a/crates/router/src/core/webhooks/incoming_v2.rs
+++ b/crates/router/src/core/webhooks/incoming_v2.rs
@@ -440,7 +440,10 @@ async fn payments_incoming_webhook_flow(
source_verified: bool,
) -> CustomResult<WebhookResponseTracker, errors::ApiErrorResponse> {
let consume_or_trigger_flow = if source_verified {
- payments::CallConnectorAction::HandleResponse(webhook_details.resource_object)
+ payments::CallConnectorAction::HandleResponse {
+ resource_object: webhook_details.resource_object,
+ event_type: None,
+ }
} else {
payments::CallConnectorAction::Trigger
};
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index 377350180c..98cecbcade 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -362,7 +362,8 @@ impl Capturable for PaymentsAuthorizeData {
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
| common_enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture
| common_enums::IntentStatus::PartiallyCapturedAndProcessing
- | common_enums::IntentStatus::Processing => None,
+ | common_enums::IntentStatus::Processing
+ | common_enums::IntentStatus::Review => None,
}
},
common_enums::CaptureMethod::Manual => Some(payment_data.payment_attempt.get_total_amount().get_amount_as_i64()),
@@ -420,7 +421,8 @@ impl Capturable for PaymentsCaptureData {
| common_enums::IntentStatus::RequiresConfirmation
| common_enums::IntentStatus::RequiresCapture
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
- | common_enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture => None,
+ | common_enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture
+ | common_enums::IntentStatus::Review => None,
}
}
}
@@ -472,7 +474,8 @@ impl Capturable for CompleteAuthorizeData {
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
| common_enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture
| common_enums::IntentStatus::Processing
- | common_enums::IntentStatus::PartiallyCapturedAndProcessing => None,
+ | common_enums::IntentStatus::PartiallyCapturedAndProcessing
+ | common_enums::IntentStatus::Review => None,
}
},
common_enums::CaptureMethod::Manual => Some(payment_data.payment_attempt.get_total_amount().get_amount_as_i64()),
@@ -538,7 +541,8 @@ impl Capturable for PaymentsCancelData {
| common_enums::IntentStatus::RequiresCapture
| common_enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
- | common_enums::IntentStatus::PartiallyCapturedAndProcessing => None,
+ | common_enums::IntentStatus::PartiallyCapturedAndProcessing
+ | common_enums::IntentStatus::Review => None,
}
}
}
@@ -700,7 +704,8 @@ impl Capturable for PaymentsExtendAuthorizationData {
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
| common_enums::IntentStatus::Processing
| common_enums::IntentStatus::PartiallyCapturedAndProcessing
- | common_enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture => None,
+ | common_enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture
+ | common_enums::IntentStatus::Review => None,
}
}
}
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 5e3a8032fb..7f389110fb 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -200,7 +200,8 @@ impl ForeignTryFrom<storage_enums::AttemptStatus> for storage_enums::CaptureStat
| storage_enums::AttemptStatus::ConfirmationAwaited
| storage_enums::AttemptStatus::DeviceDataCollectionPending
| storage_enums::AttemptStatus::PartiallyAuthorized
- | storage_enums::AttemptStatus::PartialChargedAndChargeable | storage_enums::AttemptStatus::Expired => {
+ | storage_enums::AttemptStatus::PartialChargedAndChargeable | storage_enums::AttemptStatus::Expired
+ | storage_enums::AttemptStatus::CaptureReview => {
Err(errors::ApiErrorResponse::PreconditionFailed {
message: "AttemptStatus must be one of these for multiple partial captures [Charged, PartialCharged, Pending, CaptureInitiated, Failure, CaptureFailed]".into(),
}.into())
diff --git a/migrations/2026-05-08-112325_add_capture_review_to_attempt_status/down.sql b/migrations/2026-05-08-112325_add_capture_review_to_attempt_status/down.sql
new file mode 100644
index 0000000000..e0ac49d1ec
--- /dev/null
+++ b/migrations/2026-05-08-112325_add_capture_review_to_attempt_status/down.sql
@@ -0,0 +1 @@
+SELECT 1;
diff --git a/migrations/2026-05-08-112325_add_capture_review_to_attempt_status/up.sql b/migrations/2026-05-08-112325_add_capture_review_to_attempt_status/up.sql
new file mode 100644
index 0000000000..8b121b6098
--- /dev/null
+++ b/migrations/2026-05-08-112325_add_capture_review_to_attempt_status/up.sql
@@ -0,0 +1,3 @@
+-- Add CaptureReview variant to AttemptStatus enum
+-- Represents the attempt-level status when capture fails after initial success
+ALTER TYPE "AttemptStatus" ADD VALUE IF NOT EXISTS 'capture_review';
diff --git a/migrations/2026-05-08-141100_add_review_to_intent_status/down.sql b/migrations/2026-05-08-141100_add_review_to_intent_status/down.sql
new file mode 100644
index 0000000000..e0ac49d1ec
--- /dev/null
+++ b/migrations/2026-05-08-141100_add_review_to_intent_status/down.sql
@@ -0,0 +1 @@
+SELECT 1;
diff --git a/migrations/2026-05-08-141100_add_review_to_intent_status/up.sql b/migrations/2026-05-08-141100_add_review_to_intent_status/up.sql
new file mode 100644
index 0000000000..8ff4c4c87a
--- /dev/null
+++ b/migrations/2026-05-08-141100_add_review_to_intent_status/up.sql
@@ -0,0 +1,4 @@
+-- Add Review variant to IntentStatus enum
+-- This status is used when a connector sends anomalous response
+-- (e.g., Adyen CAPTURE_FAILED webhook after successful CAPTURE)
+ALTER TYPE "IntentStatus" ADD VALUE IF NOT EXISTS 'review';