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(connector): [TRUSTPAY] Added Integrity Checks for PSync & RSync flows & Added New Variants in AttemptStatus & IntentStatus (#8096)

Sayak Bhattacharyaa76a9c1514e5
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json
index d43ddadc54..d88111cc43 100644
--- a/api-reference-v2/openapi_spec.json
+++ b/api-reference-v2/openapi_spec.json
@@ -4828,7 +4828,8 @@
"failure",
"payment_method_awaited",
"confirmation_awaited",
- "device_data_collection_pending"
+ "device_data_collection_pending",
+ "integrity_failure"
]
},
"AuthenticationConnectorDetails": {
@@ -12375,7 +12376,8 @@
"requires_confirmation",
"requires_capture",
"partially_captured",
- "partially_captured_and_capturable"
+ "partially_captured_and_capturable",
+ "conflicted"
]
},
"JCSVoucherData": {
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json
index 636f73ae21..c8ab763402 100644
--- a/api-reference/openapi_spec.json
+++ b/api-reference/openapi_spec.json
@@ -6808,7 +6808,8 @@
"failure",
"payment_method_awaited",
"confirmation_awaited",
- "device_data_collection_pending"
+ "device_data_collection_pending",
+ "integrity_failure"
]
},
"AuthenticationConnectorDetails": {
@@ -14609,7 +14610,8 @@
"requires_confirmation",
"requires_capture",
"partially_captured",
- "partially_captured_and_capturable"
+ "partially_captured_and_capturable",
+ "conflicted"
]
},
"IssuerData": {
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index 9344f8cbbd..57b119b8d1 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -155,6 +155,7 @@ pub enum AttemptStatus {
PaymentMethodAwaited,
ConfirmationAwaited,
DeviceDataCollectionPending,
+ IntegrityFailure,
}
impl AttemptStatus {
@@ -183,7 +184,8 @@ impl AttemptStatus {
| Self::Pending
| Self::PaymentMethodAwaited
| Self::ConfirmationAwaited
- | Self::DeviceDataCollectionPending => false,
+ | Self::DeviceDataCollectionPending
+ | Self::IntegrityFailure => false,
}
}
}
@@ -1599,6 +1601,8 @@ pub enum IntentStatus {
PartiallyCaptured,
/// The payment has been captured partially and the remaining amount is capturable
PartiallyCapturedAndCapturable,
+ /// There has been a discrepancy between the amount/currency sent in the request and the amount/currency received by the processor
+ Conflicted,
}
impl IntentStatus {
@@ -1612,7 +1616,8 @@ impl IntentStatus {
| Self::RequiresPaymentMethod
| Self::RequiresConfirmation
| Self::RequiresCapture
- | Self::PartiallyCapturedAndCapturable => false,
+ | Self::PartiallyCapturedAndCapturable
+ | Self::Conflicted => false,
}
}
@@ -1627,7 +1632,7 @@ impl IntentStatus {
| Self::Failed
| Self::Cancelled
| Self::PartiallyCaptured
- | Self::RequiresCapture => false,
+ | Self::RequiresCapture | Self::Conflicted => false,
Self::Processing
| Self::RequiresCustomerAction
| Self::RequiresMerchantAction
@@ -1747,7 +1752,8 @@ impl From<AttemptStatus> for PaymentMethodStatus {
| AttemptStatus::PartialCharged
| AttemptStatus::PartialChargedAndChargeable
| AttemptStatus::ConfirmationAwaited
- | AttemptStatus::DeviceDataCollectionPending => Self::Inactive,
+ | AttemptStatus::DeviceDataCollectionPending
+ | AttemptStatus::IntegrityFailure => Self::Inactive,
AttemptStatus::Charged | AttemptStatus::Authorized => Self::Active,
}
}
diff --git a/crates/common_enums/src/transformers.rs b/crates/common_enums/src/transformers.rs
index 5a14e5056a..4915745775 100644
--- a/crates/common_enums/src/transformers.rs
+++ b/crates/common_enums/src/transformers.rs
@@ -2095,7 +2095,7 @@ impl From<AttemptStatus> for IntentStatus {
Self::RequiresCustomerAction
}
AttemptStatus::Unresolved => Self::RequiresMerchantAction,
-
+ AttemptStatus::IntegrityFailure => Self::Conflicted,
AttemptStatus::PartialCharged => Self::PartiallyCaptured,
AttemptStatus::PartialChargedAndChargeable => Self::PartiallyCapturedAndCapturable,
AttemptStatus::Started
diff --git a/crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs b/crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs
index 9d7a5d364e..ed978d8490 100644
--- a/crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs
@@ -685,13 +685,12 @@ impl TryFrom<enums::AttemptStatus> for ChargebeeRecordStatus {
| enums::AttemptStatus::Pending
| enums::AttemptStatus::PaymentMethodAwaited
| enums::AttemptStatus::ConfirmationAwaited
- | enums::AttemptStatus::DeviceDataCollectionPending => {
- Err(errors::ConnectorError::NotSupported {
- message: "Record back flow is only supported for terminal status".to_string(),
- connector: "chargebee",
- }
- .into())
+ | enums::AttemptStatus::DeviceDataCollectionPending
+ | enums::AttemptStatus::IntegrityFailure => Err(errors::ConnectorError::NotSupported {
+ message: "Record back flow is only supported for terminal status".to_string(),
+ connector: "chargebee",
}
+ .into()),
}
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs b/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
index 8639689430..be14e4da0c 100644
--- a/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
@@ -2530,9 +2530,8 @@ impl TryFrom<PaymentsCaptureResponseRouterData<PaypalCaptureResponse>>
| storage_enums::AttemptStatus::Voided => 0,
storage_enums::AttemptStatus::Charged
| storage_enums::AttemptStatus::PartialCharged
- | storage_enums::AttemptStatus::PartialChargedAndChargeable => {
- item.data.request.amount_to_capture
- }
+ | storage_enums::AttemptStatus::PartialChargedAndChargeable
+ | storage_enums::AttemptStatus::IntegrityFailure => item.data.request.amount_to_capture,
};
let connector_payment_id: PaypalMeta =
to_connector_meta(item.data.request.connector_meta.clone())?;
diff --git a/crates/hyperswitch_connectors/src/connectors/recurly/transformers.rs b/crates/hyperswitch_connectors/src/connectors/recurly/transformers.rs
index 0f674948ea..673ba9d432 100644
--- a/crates/hyperswitch_connectors/src/connectors/recurly/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/recurly/transformers.rs
@@ -273,13 +273,12 @@ impl TryFrom<enums::AttemptStatus> for RecurlyRecordStatus {
| enums::AttemptStatus::Pending
| enums::AttemptStatus::PaymentMethodAwaited
| enums::AttemptStatus::ConfirmationAwaited
- | enums::AttemptStatus::DeviceDataCollectionPending => {
- Err(errors::ConnectorError::NotSupported {
- message: "Record back flow is only supported for terminal status".to_string(),
- connector: "recurly",
- }
- .into())
+ | enums::AttemptStatus::DeviceDataCollectionPending
+ | enums::AttemptStatus::IntegrityFailure => Err(errors::ConnectorError::NotSupported {
+ message: "Record back flow is only supported for terminal status".to_string(),
+ connector: "recurly",
}
+ .into()),
}
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/trustpay.rs b/crates/hyperswitch_connectors/src/connectors/trustpay.rs
index 4c7d774a38..185d86d066 100644
--- a/crates/hyperswitch_connectors/src/connectors/trustpay.rs
+++ b/crates/hyperswitch_connectors/src/connectors/trustpay.rs
@@ -1,5 +1,4 @@
pub mod transformers;
-
use base64::Engine;
use common_enums::{enums, PaymentAction};
use common_utils::{
@@ -54,7 +53,7 @@ use transformers as trustpay;
use crate::{
constants::headers,
types::ResponseRouterData,
- utils::{self, ConnectorErrorType, PaymentsPreProcessingRequestData},
+ utils::{self, self as connector_utils, ConnectorErrorType, PaymentsPreProcessingRequestData},
};
#[derive(Clone)]
@@ -424,6 +423,31 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Tru
.parse_struct("trustpay PaymentsResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ if let trustpay::TrustpayPaymentsResponse::WebhookResponse(ref webhook_response) = response
+ {
+ let response_integrity_object = connector_utils::get_sync_integrity_object(
+ self.amount_converter_to_float_major_unit,
+ webhook_response.amount.amount,
+ webhook_response.amount.currency.to_string(),
+ )?;
+
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+
+ let new_router_data = RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ });
+
+ return new_router_data
+ .map(|mut router_data| {
+ router_data.request.integrity_object = Some(response_integrity_object);
+ router_data
+ })
+ .change_context(errors::ConnectorError::ResponseHandlingFailed);
+ }
+
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
@@ -810,6 +834,29 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Trustpay
.parse_struct("trustpay RefundResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ if let trustpay::RefundResponse::WebhookRefund(ref webhook_response) = response {
+ let response_integrity_object = connector_utils::get_refund_integrity_object(
+ self.amount_converter_to_float_major_unit,
+ webhook_response.amount.amount,
+ webhook_response.amount.currency.to_string(),
+ )?;
+
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+
+ let new_router_data = RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ });
+
+ return new_router_data
+ .map(|mut router_data| {
+ router_data.request.integrity_object = Some(response_integrity_object);
+ router_data
+ })
+ .change_context(errors::ConnectorError::ResponseHandlingFailed);
+ }
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index acbf0a620a..091e3efd88 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -440,7 +440,8 @@ pub(crate) fn is_payment_failure(status: AttemptStatus) -> bool {
| AttemptStatus::Pending
| AttemptStatus::PaymentMethodAwaited
| AttemptStatus::ConfirmationAwaited
- | AttemptStatus::DeviceDataCollectionPending => false,
+ | AttemptStatus::DeviceDataCollectionPending
+ | AttemptStatus::IntegrityFailure => false,
}
}
@@ -6172,7 +6173,8 @@ impl FrmTransactionRouterDataRequest for FrmTransactionRouterData {
AttemptStatus::AuthenticationSuccessful
| AttemptStatus::PartialChargedAndChargeable
| AttemptStatus::Authorized
- | AttemptStatus::Charged => Some(true),
+ | AttemptStatus::Charged
+ | AttemptStatus::IntegrityFailure => Some(true),
AttemptStatus::Started
| AttemptStatus::AuthenticationPending
diff --git a/crates/hyperswitch_domain_models/src/router_data.rs b/crates/hyperswitch_domain_models/src/router_data.rs
index 955ddca366..d156243b87 100644
--- a/crates/hyperswitch_domain_models/src/router_data.rs
+++ b/crates/hyperswitch_domain_models/src/router_data.rs
@@ -696,7 +696,8 @@ impl
// So set the amount capturable to zero
common_enums::IntentStatus::Succeeded
| common_enums::IntentStatus::Failed
- | common_enums::IntentStatus::Cancelled => Some(MinorUnit::zero()),
+ | common_enums::IntentStatus::Cancelled
+ | common_enums::IntentStatus::Conflicted => Some(MinorUnit::zero()),
// For these statuses, update the capturable amount when it reaches terminal / capturable state
common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
@@ -726,7 +727,7 @@ impl
match intent_status {
// If the status is succeeded then we have captured the whole amount
// we need not check for `amount_to_capture` here because passing `amount_to_capture` when authorizing is not supported
- common_enums::IntentStatus::Succeeded => {
+ common_enums::IntentStatus::Succeeded | common_enums::IntentStatus::Conflicted => {
let total_amount = payment_data.payment_attempt.amount_details.get_net_amount();
Some(total_amount)
}
@@ -912,7 +913,8 @@ impl
// If the status is already succeeded / failed we cannot capture any more amount
common_enums::IntentStatus::Succeeded
| common_enums::IntentStatus::Failed
- | common_enums::IntentStatus::Cancelled => Some(MinorUnit::zero()),
+ | common_enums::IntentStatus::Cancelled
+ | common_enums::IntentStatus::Conflicted => Some(MinorUnit::zero()),
// For these statuses, update the capturable amount when it reaches terminal / capturable state
common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
@@ -938,7 +940,7 @@ impl
let intent_status = common_enums::IntentStatus::from(self.status);
match intent_status {
// If the status is succeeded then we have captured the whole amount
- common_enums::IntentStatus::Succeeded => {
+ common_enums::IntentStatus::Succeeded | common_enums::IntentStatus::Conflicted => {
let amount_to_capture = payment_data
.payment_attempt
.amount_details
@@ -1153,7 +1155,8 @@ impl
// If the status is already succeeded / failed we cannot capture any more amount
common_enums::IntentStatus::Succeeded
| common_enums::IntentStatus::Failed
- | common_enums::IntentStatus::Cancelled => Some(MinorUnit::zero()),
+ | common_enums::IntentStatus::Cancelled
+ | common_enums::IntentStatus::Conflicted => Some(MinorUnit::zero()),
// For these statuses, update the capturable amount when it reaches terminal / capturable state
common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
@@ -1181,7 +1184,7 @@ impl
let intent_status = common_enums::IntentStatus::from(self.status);
match intent_status {
// If the status is succeeded then we have captured the whole amount or amount_to_capture
- common_enums::IntentStatus::Succeeded => {
+ common_enums::IntentStatus::Succeeded | common_enums::IntentStatus::Conflicted => {
let amount_to_capture = payment_attempt.amount_details.get_amount_to_capture();
let amount_captured =
@@ -1385,7 +1388,8 @@ impl
// So set the amount capturable to zero
common_enums::IntentStatus::Succeeded
| common_enums::IntentStatus::Failed
- | common_enums::IntentStatus::Cancelled => Some(MinorUnit::zero()),
+ | common_enums::IntentStatus::Cancelled
+ | common_enums::IntentStatus::Conflicted => Some(MinorUnit::zero()),
// For these statuses, update the capturable amount when it reaches terminal / capturable state
common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
@@ -1415,7 +1419,7 @@ impl
match intent_status {
// If the status is succeeded then we have captured the whole amount
// we need not check for `amount_to_capture` here because passing `amount_to_capture` when authorizing is not supported
- common_enums::IntentStatus::Succeeded => {
+ common_enums::IntentStatus::Succeeded | common_enums::IntentStatus::Conflicted => {
let total_amount = payment_data.payment_attempt.amount_details.get_net_amount();
Some(total_amount)
}
diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs
index c153c88e0e..84a996e3ef 100644
--- a/crates/router/src/compatibility/stripe/payment_intents/types.rs
+++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs
@@ -423,7 +423,8 @@ impl From<api_enums::IntentStatus> for StripePaymentStatus {
api_enums::IntentStatus::Failed => Self::Canceled,
api_enums::IntentStatus::Processing => Self::Processing,
api_enums::IntentStatus::RequiresCustomerAction
- | api_enums::IntentStatus::RequiresMerchantAction => Self::RequiresAction,
+ | api_enums::IntentStatus::RequiresMerchantAction
+ | api_enums::IntentStatus::Conflicted => 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 90098f1c30..57b85e33de 100644
--- a/crates/router/src/compatibility/stripe/setup_intents/types.rs
+++ b/crates/router/src/compatibility/stripe/setup_intents/types.rs
@@ -315,7 +315,8 @@ impl From<api_enums::IntentStatus> for StripeSetupStatus {
api_enums::IntentStatus::Failed => Self::Canceled,
api_enums::IntentStatus::Processing => Self::Processing,
api_enums::IntentStatus::RequiresCustomerAction => Self::RequiresAction,
- api_enums::IntentStatus::RequiresMerchantAction => Self::RequiresAction,
+ api_enums::IntentStatus::RequiresMerchantAction
+ | api_enums::IntentStatus::Conflicted => 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 ad537f2496..9e834a6d19 100644
--- a/crates/router/src/connector/utils.rs
+++ b/crates/router/src/connector/utils.rs
@@ -2225,7 +2225,8 @@ impl FrmTransactionRouterDataRequest for fraud_check::FrmTransactionRouterData {
| storage_enums::AttemptStatus::Pending
| storage_enums::AttemptStatus::PaymentMethodAwaited
| storage_enums::AttemptStatus::ConfirmationAwaited
- | storage_enums::AttemptStatus::DeviceDataCollectionPending => None,
+ | storage_enums::AttemptStatus::DeviceDataCollectionPending
+ | storage_enums::AttemptStatus::IntegrityFailure => None,
}
}
}
@@ -2255,7 +2256,8 @@ pub fn is_payment_failure(status: enums::AttemptStatus) -> bool {
| common_enums::AttemptStatus::Pending
| common_enums::AttemptStatus::PaymentMethodAwaited
| common_enums::AttemptStatus::ConfirmationAwaited
- | common_enums::AttemptStatus::DeviceDataCollectionPending => false,
+ | common_enums::AttemptStatus::DeviceDataCollectionPending
+ | common_enums::AttemptStatus::IntegrityFailure => false,
}
}
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 1b1f842239..64a06fc8c1 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -2735,6 +2735,7 @@ impl ValidateStatusForOperation for &PaymentRedirectSync {
match intent_status {
common_enums::IntentStatus::RequiresCustomerAction => Ok(()),
common_enums::IntentStatus::Succeeded
+ | common_enums::IntentStatus::Conflicted
| common_enums::IntentStatus::Failed
| common_enums::IntentStatus::Cancelled
| common_enums::IntentStatus::Processing
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index dc1b06e852..0130cafca5 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -4239,7 +4239,8 @@ pub fn get_attempt_type(
| enums::AttemptStatus::Voided
| enums::AttemptStatus::AutoRefunded
| enums::AttemptStatus::PaymentMethodAwaited
- | enums::AttemptStatus::DeviceDataCollectionPending => {
+ | enums::AttemptStatus::DeviceDataCollectionPending
+ | enums::AttemptStatus::IntegrityFailure => {
metrics::MANUAL_RETRY_VALIDATION_FAILED.add(
1,
router_env::metric_attributes!((
@@ -4294,7 +4295,8 @@ pub fn get_attempt_type(
| enums::IntentStatus::PartiallyCaptured
| enums::IntentStatus::PartiallyCapturedAndCapturable
| enums::IntentStatus::Processing
- | enums::IntentStatus::Succeeded => {
+ | enums::IntentStatus::Succeeded
+ | enums::IntentStatus::Conflicted => {
Err(report!(errors::ApiErrorResponse::PreconditionFailed {
message: format!(
"You cannot {action} this payment because it has status {}",
@@ -4538,7 +4540,8 @@ pub fn is_manual_retry_allowed(
| enums::AttemptStatus::Voided
| enums::AttemptStatus::AutoRefunded
| enums::AttemptStatus::PaymentMethodAwaited
- | enums::AttemptStatus::DeviceDataCollectionPending => {
+ | enums::AttemptStatus::DeviceDataCollectionPending
+ | storage_enums::AttemptStatus::IntegrityFailure => {
logger::error!("Payment Attempt should not be in this state because Attempt to Intent status mapping doesn't allow it");
None
}
@@ -4556,7 +4559,8 @@ pub fn is_manual_retry_allowed(
| enums::IntentStatus::PartiallyCaptured
| enums::IntentStatus::PartiallyCapturedAndCapturable
| enums::IntentStatus::Processing
- | enums::IntentStatus::Succeeded => Some(false),
+ | enums::IntentStatus::Succeeded
+ | enums::IntentStatus::Conflicted => Some(false),
enums::IntentStatus::RequiresCustomerAction
| enums::IntentStatus::RequiresMerchantAction
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 15371291d1..33848e1c39 100644
--- a/crates/router/src/core/payments/operations/payment_attempt_record.rs
+++ b/crates/router/src/core/payments/operations/payment_attempt_record.rs
@@ -81,6 +81,7 @@ impl ValidateStatusForOperation for PaymentAttemptRecord {
common_enums::IntentStatus::Succeeded
| common_enums::IntentStatus::Cancelled
| common_enums::IntentStatus::Processing
+ | common_enums::IntentStatus::Conflicted
| common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
| common_enums::IntentStatus::RequiresCapture
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 9fe4e805f9..d644ea5235 100644
--- a/crates/router/src/core/payments/operations/payment_capture_v2.rs
+++ b/crates/router/src/core/payments/operations/payment_capture_v2.rs
@@ -35,6 +35,7 @@ impl ValidateStatusForOperation for PaymentsCapture {
common_enums::IntentStatus::RequiresCapture
| common_enums::IntentStatus::PartiallyCapturedAndCapturable => Ok(()),
common_enums::IntentStatus::Succeeded
+ | common_enums::IntentStatus::Conflicted
| common_enums::IntentStatus::Failed
| common_enums::IntentStatus::Cancelled
| common_enums::IntentStatus::Processing
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 8805710c07..83cffbf419 100644
--- a/crates/router/src/core/payments/operations/payment_confirm_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm_intent.rs
@@ -43,6 +43,7 @@ impl ValidateStatusForOperation for PaymentIntentConfirm {
match intent_status {
common_enums::IntentStatus::RequiresPaymentMethod => Ok(()),
common_enums::IntentStatus::Succeeded
+ | common_enums::IntentStatus::Conflicted
| common_enums::IntentStatus::Failed
| common_enums::IntentStatus::Cancelled
| common_enums::IntentStatus::Processing
diff --git a/crates/router/src/core/payments/operations/payment_get.rs b/crates/router/src/core/payments/operations/payment_get.rs
index 716030c8f4..91c89f422b 100644
--- a/crates/router/src/core/payments/operations/payment_get.rs
+++ b/crates/router/src/core/payments/operations/payment_get.rs
@@ -41,7 +41,8 @@ impl ValidateStatusForOperation for PaymentGet {
| common_enums::IntentStatus::Failed
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
| common_enums::IntentStatus::PartiallyCaptured
- | common_enums::IntentStatus::Cancelled => Ok(()),
+ | common_enums::IntentStatus::Cancelled
+ | common_enums::IntentStatus::Conflicted => Ok(()),
// These statuses are not valid for this operation
common_enums::IntentStatus::RequiresConfirmation
| common_enums::IntentStatus::RequiresPaymentMethod => {
diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs
index 41d494989b..2fb4696ef4 100644
--- a/crates/router/src/core/payments/operations/payment_response.rs
+++ b/crates/router/src/core/payments/operations/payment_response.rs
@@ -1571,7 +1571,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
None,
Some(storage::PaymentAttemptUpdate::ErrorUpdate {
connector: None,
- status: enums::AttemptStatus::Pending,
+ status: enums::AttemptStatus::IntegrityFailure,
error_message: Some(Some("Integrity Check Failed!".to_string())),
error_code: Some(Some("IE".to_string())),
error_reason: Some(Some(format!(
@@ -2572,7 +2572,8 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::PaymentsAuthor
| common_enums::AttemptStatus::CaptureInitiated
| common_enums::AttemptStatus::PaymentMethodAwaited
| common_enums::AttemptStatus::ConfirmationAwaited
- | common_enums::AttemptStatus::DeviceDataCollectionPending => {
+ | common_enums::AttemptStatus::DeviceDataCollectionPending
+ | common_enums::AttemptStatus::IntegrityFailure => {
let pm_update_status = enums::PaymentMethodStatus::Active;
// payment_methods microservice call
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 77cc6dc1a9..8f167a4311 100644
--- a/crates/router/src/core/payments/operations/payment_session_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_session_intent.rs
@@ -41,7 +41,7 @@ impl ValidateStatusForOperation for PaymentSessionIntent {
| common_enums::IntentStatus::RequiresConfirmation
| common_enums::IntentStatus::PartiallyCapturedAndCapturable
| common_enums::IntentStatus::Succeeded
- | common_enums::IntentStatus::Failed => {
+ | common_enums::IntentStatus::Failed | common_enums::IntentStatus::Conflicted => {
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_update_intent.rs b/crates/router/src/core/payments/operations/payment_update_intent.rs
index 9a397e248c..2c7b2ea4e8 100644
--- a/crates/router/src/core/payments/operations/payment_update_intent.rs
+++ b/crates/router/src/core/payments/operations/payment_update_intent.rs
@@ -49,7 +49,8 @@ impl ValidateStatusForOperation for PaymentUpdateIntent {
match intent_status {
// if the status is `Failed`` we would want to Update few intent fields to perform a Revenue Recovery retry
common_enums::IntentStatus::RequiresPaymentMethod
- | common_enums::IntentStatus::Failed => Ok(()),
+ | common_enums::IntentStatus::Failed
+ | common_enums::IntentStatus::Conflicted => Ok(()),
common_enums::IntentStatus::Succeeded
| common_enums::IntentStatus::Cancelled
| common_enums::IntentStatus::Processing
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 9829c10944..0afd6efb0e 100644
--- a/crates/router/src/core/payments/operations/proxy_payments_intent.rs
+++ b/crates/router/src/core/payments/operations/proxy_payments_intent.rs
@@ -45,7 +45,8 @@ impl ValidateStatusForOperation for PaymentProxyIntent {
//Failed state is included here so that in PCR, retries can be done for failed payments, otherwise for a failed attempt it was asking for new payment_intent
common_enums::IntentStatus::RequiresPaymentMethod
| common_enums::IntentStatus::Failed => Ok(()),
- common_enums::IntentStatus::Succeeded
+ common_enums::IntentStatus::Conflicted
+ | common_enums::IntentStatus::Succeeded
| common_enums::IntentStatus::Cancelled
| common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
diff --git a/crates/router/src/core/payments/payment_methods.rs b/crates/router/src/core/payments/payment_methods.rs
index 1464ed4c5f..c10cf05044 100644
--- a/crates/router/src/core/payments/payment_methods.rs
+++ b/crates/router/src/core/payments/payment_methods.rs
@@ -205,6 +205,7 @@ fn validate_payment_status_for_payment_method_list(
match intent_status {
common_enums::IntentStatus::RequiresPaymentMethod => Ok(()),
common_enums::IntentStatus::Succeeded
+ | common_enums::IntentStatus::Conflicted
| common_enums::IntentStatus::Failed
| common_enums::IntentStatus::Cancelled
| common_enums::IntentStatus::Processing
diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rs
index df36f9f511..7b63b27537 100644
--- a/crates/router/src/core/payments/retry.rs
+++ b/crates/router/src/core/payments/retry.rs
@@ -768,7 +768,8 @@ impl<F: Send + Clone + Sync, FData: Send + Sync>
| storage_enums::AttemptStatus::PaymentMethodAwaited
| storage_enums::AttemptStatus::ConfirmationAwaited
| storage_enums::AttemptStatus::Unresolved
- | storage_enums::AttemptStatus::DeviceDataCollectionPending => false,
+ | storage_enums::AttemptStatus::DeviceDataCollectionPending
+ | storage_enums::AttemptStatus::IntegrityFailure => false,
storage_enums::AttemptStatus::AuthenticationFailed
| storage_enums::AttemptStatus::AuthorizationFailed
diff --git a/crates/router/src/core/revenue_recovery/transformers.rs b/crates/router/src/core/revenue_recovery/transformers.rs
index edbea85171..a4e40c69b7 100644
--- a/crates/router/src/core/revenue_recovery/transformers.rs
+++ b/crates/router/src/core/revenue_recovery/transformers.rs
@@ -34,7 +34,8 @@ impl ForeignFrom<AttemptStatus> for RevenueRecoveryPaymentsAttemptStatus {
| AttemptStatus::PaymentMethodAwaited
| AttemptStatus::AuthenticationPending
| AttemptStatus::DeviceDataCollectionPending
- | AttemptStatus::Unresolved => Self::InvalidStatus(s.to_string()),
+ | AttemptStatus::Unresolved
+ | AttemptStatus::IntegrityFailure => Self::InvalidStatus(s.to_string()),
}
}
}
diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rs
index dc0da1c734..12e6923a4f 100644
--- a/crates/router/src/core/routing/helpers.rs
+++ b/crates/router/src/core/routing/helpers.rs
@@ -1641,6 +1641,7 @@ fn get_desired_payment_status_for_dynamic_routing_metrics(
| common_enums::AttemptStatus::AutoRefunded
| common_enums::AttemptStatus::Unresolved
| common_enums::AttemptStatus::Pending
+ | common_enums::AttemptStatus::IntegrityFailure
| common_enums::AttemptStatus::PaymentMethodAwaited
| common_enums::AttemptStatus::ConfirmationAwaited
| common_enums::AttemptStatus::DeviceDataCollectionPending => {
@@ -1672,7 +1673,8 @@ impl ForeignFrom<common_enums::AttemptStatus> for open_router::TxnStatus {
common_enums::AttemptStatus::PartialCharged => Self::PartialCharged,
common_enums::AttemptStatus::PartialChargedAndChargeable => Self::ToBeCharged,
common_enums::AttemptStatus::Unresolved => Self::Pending,
- common_enums::AttemptStatus::Pending => 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,
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index d7e149b9db..53fbff1cd3 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -297,7 +297,7 @@ impl Capturable for PaymentsAuthorizeData {
match intent_status {
common_enums::IntentStatus::Succeeded
| common_enums::IntentStatus::Failed
- | common_enums::IntentStatus::Processing => Some(0),
+ | common_enums::IntentStatus::Processing | common_enums::IntentStatus::Conflicted => Some(0),
common_enums::IntentStatus::Cancelled
| common_enums::IntentStatus::PartiallyCaptured
| common_enums::IntentStatus::RequiresCustomerAction
@@ -336,7 +336,8 @@ impl Capturable for PaymentsCaptureData {
let intent_status = common_enums::IntentStatus::foreign_from(attempt_status);
match intent_status {
common_enums::IntentStatus::Succeeded
- | common_enums::IntentStatus::PartiallyCaptured => Some(0),
+ | common_enums::IntentStatus::PartiallyCaptured
+ | common_enums::IntentStatus::Conflicted => Some(0),
common_enums::IntentStatus::Processing
| common_enums::IntentStatus::Cancelled
| common_enums::IntentStatus::Failed
@@ -380,9 +381,8 @@ impl Capturable for CompleteAuthorizeData {
match intent_status {
common_enums::IntentStatus::Succeeded|
common_enums::IntentStatus::Failed|
- common_enums::IntentStatus::Processing => Some(0),
- common_enums::IntentStatus::Cancelled
- | common_enums::IntentStatus::PartiallyCaptured
+ common_enums::IntentStatus::Processing | common_enums::IntentStatus::Conflicted => Some(0),
+ common_enums::IntentStatus::Cancelled | common_enums::IntentStatus::PartiallyCaptured
| common_enums::IntentStatus::RequiresCustomerAction
| common_enums::IntentStatus::RequiresMerchantAction
| common_enums::IntentStatus::RequiresPaymentMethod
@@ -428,7 +428,8 @@ impl Capturable for PaymentsCancelData {
match intent_status {
common_enums::IntentStatus::Cancelled
| common_enums::IntentStatus::Processing
- | common_enums::IntentStatus::PartiallyCaptured => Some(0),
+ | common_enums::IntentStatus::PartiallyCaptured
+ | common_enums::IntentStatus::Conflicted => Some(0),
common_enums::IntentStatus::Succeeded
| common_enums::IntentStatus::Failed
| common_enums::IntentStatus::RequiresCustomerAction
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index b329b48faa..66dc405fdf 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -148,7 +148,7 @@ impl ForeignTryFrom<storage_enums::AttemptStatus> for storage_enums::CaptureStat
) -> errors::RouterResult<Self> {
match attempt_status {
storage_enums::AttemptStatus::Charged
- | storage_enums::AttemptStatus::PartialCharged => Ok(Self::Charged),
+ | storage_enums::AttemptStatus::PartialCharged | storage_enums::AttemptStatus::IntegrityFailure => Ok(Self::Charged),
storage_enums::AttemptStatus::Pending
| storage_enums::AttemptStatus::CaptureInitiated => Ok(Self::Pending),
storage_enums::AttemptStatus::Failure
@@ -171,7 +171,7 @@ impl ForeignTryFrom<storage_enums::AttemptStatus> for storage_enums::CaptureStat
| storage_enums::AttemptStatus::PaymentMethodAwaited
| storage_enums::AttemptStatus::ConfirmationAwaited
| storage_enums::AttemptStatus::DeviceDataCollectionPending
- | storage_enums::AttemptStatus::PartialChargedAndChargeable=> {
+ | storage_enums::AttemptStatus::PartialChargedAndChargeable => {
Err(errors::ApiErrorResponse::PreconditionFailed {
message: "AttemptStatus must be one of these for multiple partial captures [Charged, PartialCharged, Pending, CaptureInitiated, Failure, CaptureFailed]".into(),
}.into())
@@ -472,9 +472,8 @@ impl ForeignFrom<api_enums::IntentStatus> for Option<storage_enums::EventType> {
Some(storage_enums::EventType::PaymentProcessing)
}
api_enums::IntentStatus::RequiresMerchantAction
- | api_enums::IntentStatus::RequiresCustomerAction => {
- Some(storage_enums::EventType::ActionRequired)
- }
+ | api_enums::IntentStatus::RequiresCustomerAction
+ | api_enums::IntentStatus::Conflicted => Some(storage_enums::EventType::ActionRequired),
api_enums::IntentStatus::Cancelled => Some(storage_enums::EventType::PaymentCancelled),
api_enums::IntentStatus::PartiallyCaptured
| api_enums::IntentStatus::PartiallyCapturedAndCapturable => {
diff --git a/migrations/2025-05-21-194538_modify_attemptstatus_and_intentstatus/down.sql b/migrations/2025-05-21-194538_modify_attemptstatus_and_intentstatus/down.sql
new file mode 100644
index 0000000000..027b7d63fd
--- /dev/null
+++ b/migrations/2025-05-21-194538_modify_attemptstatus_and_intentstatus/down.sql
@@ -0,0 +1 @@
+SELECT 1;
\ No newline at end of file
diff --git a/migrations/2025-05-21-194538_modify_attemptstatus_and_intentstatus/up.sql b/migrations/2025-05-21-194538_modify_attemptstatus_and_intentstatus/up.sql
new file mode 100644
index 0000000000..f73533f505
--- /dev/null
+++ b/migrations/2025-05-21-194538_modify_attemptstatus_and_intentstatus/up.sql
@@ -0,0 +1,2 @@
+ALTER TYPE "AttemptStatus" ADD VALUE 'integrity_failure';
+ALTER TYPE "IntentStatus" ADD VALUE 'conflicted';