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(router): [worldpayvantiv][nuvei] refactor post capture void (#10923)

Akshaya Shankar2b7ae137cfa1
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index bdb9aee388..b64ccc9316 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -1124,7 +1124,14 @@
},
"responses": {
"200": {
- "description": "Payment canceled post capture"
+ "description": "Payment canceled post capture",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PaymentsResponse"
+ }
+ }
+ }
},
"400": {
"description": "Missing mandatory fields",
@@ -25523,6 +25530,36 @@
}
}
},
+ "PaymentIntentStateMetadata": {
+ "type": "object",
+ "description": "Additional metadata for payment intent state containing refunded and disputed amounts",
+ "properties": {
+ "total_refunded_amount": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/MinorUnit"
+ }
+ ],
+ "nullable": true
+ },
+ "total_disputed_amount": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/MinorUnit"
+ }
+ ],
+ "nullable": true
+ },
+ "post_capture_void": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/PostCaptureVoidResponse"
+ }
+ ],
+ "nullable": true
+ }
+ }
+ },
"PaymentLinkBackgroundImageConfig": {
"type": "object",
"required": [
@@ -28803,6 +28840,14 @@
"example": "stripe",
"nullable": true
},
+ "state_metadata": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/PaymentIntentStateMetadata"
+ }
+ ],
+ "nullable": true
+ },
"client_secret": {
"type": "string",
"description": "A secret token unique to this payment intent. It is primarily used by client-side applications (e.g., Hyperswitch SDKs) to authenticate actions like confirming the payment or handling next actions. This secret should be handled carefully and not exposed publicly beyond its intended client-side use.",
@@ -30397,6 +30442,14 @@
"example": "stripe",
"nullable": true
},
+ "state_metadata": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/PaymentIntentStateMetadata"
+ }
+ ],
+ "nullable": true
+ },
"client_secret": {
"type": "string",
"description": "A secret token unique to this payment intent. It is primarily used by client-side applications (e.g., Hyperswitch SDKs) to authenticate actions like confirming the payment or handling next actions. This secret should be handled carefully and not exposed publicly beyond its intended client-side use.",
@@ -33869,6 +33922,47 @@
}
}
},
+ "PostCaptureVoidResponse": {
+ "type": "object",
+ "description": "Additional metadata for payment intent state containing refunded and disputed amounts",
+ "required": [
+ "updated_at"
+ ],
+ "properties": {
+ "status": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/PostCaptureVoidStatus"
+ }
+ ],
+ "nullable": true
+ },
+ "connector_reference_id": {
+ "type": "string",
+ "description": "Connector reference id for post capture void",
+ "nullable": true
+ },
+ "description": {
+ "type": "string",
+ "description": "Description or message related to the post capture void",
+ "nullable": true
+ },
+ "updated_at": {
+ "type": "string",
+ "format": "date-time",
+ "description": "Timestamp when the post capture void was last updated"
+ }
+ }
+ },
+ "PostCaptureVoidStatus": {
+ "type": "string",
+ "description": "The status of a post-capture void operation",
+ "enum": [
+ "succeeded",
+ "pending",
+ "failed"
+ ]
+ },
"PrimaryBusinessDetails": {
"type": "object",
"required": [
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 48e2dfe22a..41d91365c7 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -19781,6 +19781,36 @@
}
}
},
+ "PaymentIntentStateMetadata": {
+ "type": "object",
+ "description": "Additional metadata for payment intent state containing refunded and disputed amounts",
+ "properties": {
+ "total_refunded_amount": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/MinorUnit"
+ }
+ ],
+ "nullable": true
+ },
+ "total_disputed_amount": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/MinorUnit"
+ }
+ ],
+ "nullable": true
+ },
+ "post_capture_void": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/PostCaptureVoidResponse"
+ }
+ ],
+ "nullable": true
+ }
+ }
+ },
"PaymentLinkBackgroundImageConfig": {
"type": "object",
"required": [
@@ -25426,6 +25456,47 @@
"not_found"
]
},
+ "PostCaptureVoidResponse": {
+ "type": "object",
+ "description": "Additional metadata for payment intent state containing refunded and disputed amounts",
+ "required": [
+ "updated_at"
+ ],
+ "properties": {
+ "status": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/PostCaptureVoidStatus"
+ }
+ ],
+ "nullable": true
+ },
+ "connector_reference_id": {
+ "type": "string",
+ "description": "Connector reference id for post capture void",
+ "nullable": true
+ },
+ "description": {
+ "type": "string",
+ "description": "Description or message related to the post capture void",
+ "nullable": true
+ },
+ "updated_at": {
+ "type": "string",
+ "format": "date-time",
+ "description": "Timestamp when the post capture void was last updated"
+ }
+ }
+ },
+ "PostCaptureVoidStatus": {
+ "type": "string",
+ "description": "The status of a post-capture void operation",
+ "enum": [
+ "succeeded",
+ "pending",
+ "failed"
+ ]
+ },
"PresenceOfCustomerDuringPayment": {
"type": "string",
"description": "Set to `present` to indicate that the customer is in your checkout flow during this payment, and therefore is able to authenticate. This parameter should be `absent` when merchant's doing merchant initiated payments and customer is not present while doing the payment.",
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 2fb3974134..55fa3f8000 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -7169,6 +7169,10 @@ pub struct PaymentsResponse {
#[smithy(value_type = "Option<String>")]
pub connector: Option<String>,
+ /// The current state metadata of the payment intent, providing additional context about its status.
+ #[schema(value_type = Option<PaymentIntentStateMetadata>)]
+ pub state_metadata: Option<common_types::payments::PaymentIntentStateMetadata>,
+
/// A secret token unique to this payment intent. It is primarily used by client-side applications (e.g., Hyperswitch SDKs) to authenticate actions like confirming the payment or handling next actions. This secret should be handled carefully and not exposed publicly beyond its intended client-side use.
#[schema(value_type = Option<String>, example = "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo")]
#[smithy(value_type = "Option<String>")]
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index 97ba640db9..2a7f2805e7 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -181,7 +181,6 @@ impl AttemptStatus {
| Self::Charged
| Self::AutoRefunded
| Self::Voided
- | Self::VoidedPostCharge
| Self::VoidFailed
| Self::CaptureFailed
| Self::Failure
@@ -204,7 +203,8 @@ impl AttemptStatus {
| Self::PaymentMethodAwaited
| Self::ConfirmationAwaited
| Self::DeviceDataCollectionPending
- | Self::IntegrityFailure => false,
+ | Self::IntegrityFailure
+ | Self::VoidedPostCharge => false,
}
}
@@ -10756,3 +10756,43 @@ pub enum WebhookRegistrationStatus {
// Webhook registration has failed
Failure,
}
+
+/// The status of a post-capture void operation
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ Default,
+ Eq,
+ PartialOrd,
+ Ord,
+ Hash,
+ PartialEq,
+ serde::Deserialize,
+ serde::Serialize,
+ SmithyModel,
+ strum::Display,
+ strum::VariantNames,
+ strum::EnumIter,
+ strum::EnumString,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "text")]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "snake_case")]
+#[smithy(namespace = "com.hyperswitch.smithy.types")]
+pub enum PostCaptureVoidStatus {
+ Succeeded,
+ #[default]
+ Pending,
+ Failed,
+}
+
+impl PostCaptureVoidStatus {
+ pub fn is_post_capture_void_failure(self) -> bool {
+ match self {
+ Self::Failed => true,
+ Self::Pending | Self::Succeeded => false,
+ }
+ }
+}
diff --git a/crates/common_types/src/domain.rs b/crates/common_types/src/domain.rs
index 567a5cb213..734f182a03 100644
--- a/crates/common_types/src/domain.rs
+++ b/crates/common_types/src/domain.rs
@@ -220,3 +220,14 @@ impl RetryFeatureData {
self.decision
}
}
+
+/// Data for post capture void
+#[derive(Debug, Clone, Default, Serialize, Deserialize)]
+pub struct PostCaptureVoidData {
+ /// Status of post capture void
+ pub status: common_enums::PostCaptureVoidStatus,
+ /// Connector reference id for post capture void
+ pub connector_reference_id: Option<String>,
+ /// Description or message related to the post capture void
+ pub description: Option<String>,
+}
diff --git a/crates/common_types/src/payments.rs b/crates/common_types/src/payments.rs
index 8801eb4ac1..ae24b5ffda 100644
--- a/crates/common_types/src/payments.rs
+++ b/crates/common_types/src/payments.rs
@@ -22,7 +22,7 @@ use smithy::SmithyModel;
use time::PrimitiveDateTime;
use utoipa::ToSchema;
-use crate::domain::{AdyenSplitData, XenditSplitSubMerchantData};
+use crate::domain::{AdyenSplitData, PostCaptureVoidData, XenditSplitSubMerchantData};
#[derive(
Serialize,
Deserialize,
@@ -992,6 +992,25 @@ pub struct PaymentIntentStateMetadata {
pub total_refunded_amount: Option<MinorUnit>,
/// Shows up the total disputed amount across all disputes for a particular payment
pub total_disputed_amount: Option<MinorUnit>,
+ /// Post capture void response details
+ pub post_capture_void: Option<PostCaptureVoidResponse>,
+}
+
+/// Additional metadata for payment intent state containing refunded and disputed amounts
+#[derive(
+ Serialize, Deserialize, Debug, Clone, PartialEq, Eq, AsExpression, FromSqlRow, utoipa::ToSchema,
+)]
+#[diesel(sql_type = Jsonb)]
+pub struct PostCaptureVoidResponse {
+ /// Status of post capture void
+ #[schema(value_type = Option<PostCaptureVoidStatus>)]
+ pub status: enums::PostCaptureVoidStatus,
+ /// Connector reference id for post capture void
+ pub connector_reference_id: Option<String>,
+ /// Description or message related to the post capture void
+ pub description: Option<String>,
+ /// Timestamp when the post capture void was last updated
+ pub updated_at: PrimitiveDateTime,
}
impl PaymentIntentStateMetadata {
@@ -1018,6 +1037,45 @@ impl PaymentIntentStateMetadata {
MinorUnit::new(blocked_amount)
}
+
+ /// Check if post capture void is pending for the payment intent
+ pub fn is_post_capture(&self) -> bool {
+ matches!(
+ self.post_capture_void
+ .as_ref()
+ .map(|post_capture_void| post_capture_void.status),
+ Some(common_enums::PostCaptureVoidStatus::Pending)
+ )
+ }
+
+ /// Check if post capture void is issued for the payment intent
+ pub fn is_post_capture_void_issued(&self) -> bool {
+ self.post_capture_void.is_some()
+ }
+
+ /// Check if post capture void is applied for the payment intent
+ pub fn is_post_capture_void_successful(&self) -> bool {
+ matches!(
+ self.post_capture_void
+ .as_ref()
+ .map(|post_capture_void| post_capture_void.status),
+ Some(common_enums::PostCaptureVoidStatus::Succeeded)
+ )
+ }
+
+ /// Builder method to set post_capture_void data
+ pub fn set_post_capture_void_data(
+ mut self,
+ post_capture_void_data: PostCaptureVoidData,
+ ) -> Self {
+ self.post_capture_void = Some(PostCaptureVoidResponse {
+ status: post_capture_void_data.status,
+ connector_reference_id: post_capture_void_data.connector_reference_id,
+ description: post_capture_void_data.description,
+ updated_at: date_time::now(),
+ });
+ self
+ }
}
common_utils::impl_to_sql_from_sql_json!(PaymentIntentStateMetadata);
diff --git a/crates/diesel_models/Cargo.toml b/crates/diesel_models/Cargo.toml
index 1baab92a10..8c77c17792 100644
--- a/crates/diesel_models/Cargo.toml
+++ b/crates/diesel_models/Cargo.toml
@@ -24,7 +24,6 @@ strum = { version = "0.26.3", features = ["derive"] }
thiserror = "1.0.69"
time = { version = "0.3.41", features = ["serde", "serde-well-known", "std"] }
-
# First party crates
common_enums = { version = "0.1.0", path = "../common_enums" }
common_utils = { version = "0.1.0", path = "../common_utils" }
diff --git a/crates/diesel_models/src/query/refund.rs b/crates/diesel_models/src/query/refund.rs
index a718d36730..b963f2f553 100644
--- a/crates/diesel_models/src/query/refund.rs
+++ b/crates/diesel_models/src/query/refund.rs
@@ -130,6 +130,15 @@ impl Refund {
)
.await
}
+
+ pub fn is_refund_applied(&self) -> bool {
+ matches!(
+ self.refund_status,
+ common_enums::RefundStatus::ManualReview
+ | common_enums::RefundStatus::Pending
+ | common_enums::RefundStatus::Success
+ )
+ }
}
#[cfg(feature = "v2")]
diff --git a/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs b/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs
index 3c56e9c5c3..476ccde031 100644
--- a/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs
@@ -33,7 +33,8 @@ use hyperswitch_domain_models::{
},
router_request_types::{
authentication::MessageExtensionAttribute, AuthenticationData, BrowserInformation,
- CompleteAuthorizeData, PaymentsAuthorizeData, ResponseId, SetupMandateRequestData,
+ CompleteAuthorizeData, PaymentsAuthorizeData, PaymentsCancelPostCaptureData, ResponseId,
+ SetupMandateRequestData,
},
router_response_types::{
MandateReference, PaymentsResponseData, RedirectForm, RefundsResponseData,
@@ -1963,7 +1964,6 @@ pub enum NuveiTransactionType {
fn get_payment_status(
amount: Option<i64>,
- is_post_capture_void: bool,
transaction_type: Option<NuveiTransactionType>,
transaction_status: Option<NuveiTransactionStatus>,
status: NuveiPaymentStatus,
@@ -1997,9 +1997,6 @@ fn get_payment_status(
Some(NuveiTransactionType::Sale) | Some(NuveiTransactionType::Settle) => {
enums::AttemptStatus::Charged
}
- Some(NuveiTransactionType::Void) if is_post_capture_void => {
- enums::AttemptStatus::VoidedPostCharge
- }
Some(NuveiTransactionType::Void) => enums::AttemptStatus::Voided,
Some(NuveiTransactionType::Auth3D) => enums::AttemptStatus::AuthenticationPending,
_ => enums::AttemptStatus::Pending,
@@ -2077,21 +2074,12 @@ fn build_error_response(params: ErrorResponseParams) -> Option<ErrorResponse> {
}
}
-pub trait NuveiPaymentsGenericResponse {
- fn is_post_capture_void() -> bool {
- false
- }
-}
+pub trait NuveiPaymentsGenericResponse {}
impl NuveiPaymentsGenericResponse for CompleteAuthorize {}
impl NuveiPaymentsGenericResponse for Void {}
impl NuveiPaymentsGenericResponse for PSync {}
impl NuveiPaymentsGenericResponse for Capture {}
-impl NuveiPaymentsGenericResponse for PostCaptureVoid {
- fn is_post_capture_void() -> bool {
- true
- }
-}
impl
TryFrom<
@@ -2115,7 +2103,7 @@ impl
let amount = item.data.request.amount;
let response = &item.response;
let (status, redirection_data, connector_response_data) = process_nuvei_payment_response(
- NuveiPaymentResponseData::new(Some(amount), false, item.data.payment_method, response),
+ NuveiPaymentResponseData::new(Some(amount), item.data.payment_method, response),
)?;
let (amount_captured, minor_amount_capturable) = get_amount_captured(
@@ -2179,7 +2167,6 @@ impl
#[derive(Debug)]
pub struct NuveiPaymentResponseData {
pub amount: Option<i64>,
- pub is_post_capture_void: bool,
pub payment_method: enums::PaymentMethod,
pub payment_option: Option<PaymentOption>,
pub transaction_type: Option<NuveiTransactionType>,
@@ -2191,13 +2178,11 @@ pub struct NuveiPaymentResponseData {
impl NuveiPaymentResponseData {
pub fn new(
amount: Option<i64>,
- is_post_capture_void: bool,
payment_method: enums::PaymentMethod,
response: &NuveiPaymentsResponse,
) -> Self {
Self {
amount,
- is_post_capture_void,
payment_method,
payment_option: response.payment_option.clone(),
transaction_type: response.transaction_type.clone(),
@@ -2209,14 +2194,12 @@ impl NuveiPaymentResponseData {
pub fn new_from_sync_response(
amount: Option<i64>,
- is_post_capture_void: bool,
payment_method: enums::PaymentMethod,
response: &NuveiTransactionSyncResponse,
) -> Self {
let transaction_details = &response.transaction_details;
Self {
amount,
- is_post_capture_void,
payment_method,
payment_option: response.payment_option.clone(),
transaction_type: transaction_details
@@ -2265,7 +2248,6 @@ fn process_nuvei_payment_response(
.map(ConnectorResponseData::with_additional_payment_method_data);
let status = get_payment_status(
data.amount,
- data.is_post_capture_void,
data.transaction_type,
data.transaction_status,
data.status,
@@ -2348,7 +2330,7 @@ impl
let amount = Some(item.data.request.amount);
let response = &item.response;
let (status, redirection_data, connector_response_data) = process_nuvei_payment_response(
- NuveiPaymentResponseData::new(amount, false, item.data.payment_method, response),
+ NuveiPaymentResponseData::new(amount, item.data.payment_method, response),
)?;
let (amount_captured, minor_amount_capturable) = get_amount_captured(
@@ -2414,18 +2396,15 @@ where
.minor_amount_capturable
.map(|amount| amount.get_amount_as_i64());
let response = &item.response;
- let (status, redirection_data, connector_response_data) =
- process_nuvei_payment_response(NuveiPaymentResponseData::new(
- amount,
- F::is_post_capture_void(),
- item.data.payment_method,
- response,
- ))?;
+ let (status, redirection_data, connector_response_data) = process_nuvei_payment_response(
+ NuveiPaymentResponseData::new(amount, item.data.payment_method, response),
+ )?;
let (amount_captured, minor_amount_capturable) = get_amount_captured(
response.partial_approval.clone(),
response.transaction_type.clone(),
)?;
+
Ok(Self {
status,
response: if let Some(err) = build_error_response(ErrorResponseParams {
@@ -2460,6 +2439,66 @@ where
}
}
+impl
+ TryFrom<
+ ResponseRouterData<
+ PostCaptureVoid,
+ NuveiPaymentsResponse,
+ PaymentsCancelPostCaptureData,
+ PaymentsResponseData,
+ >,
+ > for RouterData<PostCaptureVoid, PaymentsCancelPostCaptureData, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<
+ PostCaptureVoid,
+ NuveiPaymentsResponse,
+ PaymentsCancelPostCaptureData,
+ PaymentsResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ let post_capture_void_status = match item.response.transaction_status {
+ Some(NuveiTransactionStatus::Approved) => {
+ common_enums::PostCaptureVoidStatus::Succeeded
+ }
+ Some(NuveiTransactionStatus::Declined) | Some(NuveiTransactionStatus::Error) => {
+ common_enums::PostCaptureVoidStatus::Failed
+ }
+ Some(NuveiTransactionStatus::Processing) | Some(NuveiTransactionStatus::Pending) => {
+ common_enums::PostCaptureVoidStatus::Pending
+ }
+ Some(NuveiTransactionStatus::Redirect) => Err(
+ errors::ConnectorError::UnexpectedResponseError(bytes::Bytes::from(
+ "Redirect status is not expected in post capture void flow".to_owned(),
+ )),
+ )?,
+
+ None => match item.response.status {
+ NuveiPaymentStatus::Failed | NuveiPaymentStatus::Error => {
+ common_enums::PostCaptureVoidStatus::Failed
+ }
+ NuveiPaymentStatus::Processing => common_enums::PostCaptureVoidStatus::Pending,
+ NuveiPaymentStatus::Success => common_enums::PostCaptureVoidStatus::Succeeded,
+ },
+ };
+
+ let description = post_capture_void_status
+ .is_post_capture_void_failure()
+ .then_some(item.response.reason.clone())
+ .flatten();
+
+ Ok(Self {
+ response: Ok(PaymentsResponseData::PostCaptureVoidResponse {
+ post_capture_void_status,
+ connector_reference_id: item.response.transaction_id.clone(),
+ description,
+ }),
+ ..item.data
+ })
+ }
+}
+
// Generic implementation for other flow types
impl<F, T> TryFrom<ResponseRouterData<F, NuveiTransactionSyncResponse, T, PaymentsResponseData>>
for RouterData<F, T, PaymentsResponseData>
@@ -2484,7 +2523,6 @@ where
let (status, redirection_data, connector_response_data) =
process_nuvei_payment_response(NuveiPaymentResponseData::new_from_sync_response(
amount,
- F::is_post_capture_void(),
item.data.payment_method,
response,
))?;
@@ -2558,7 +2596,6 @@ impl TryFrom<PaymentsPreAuthenticateResponseRouterData<NuveiPaymentsResponse>>
Ok(Self {
status: get_payment_status(
Some(item.data.request.amount),
- false,
response.transaction_type,
response.transaction_status,
response.status,
@@ -2591,7 +2628,6 @@ impl TryFrom<PaymentsPreprocessingResponseRouterData<NuveiPaymentsResponse>>
Ok(Self {
status: get_payment_status(
Some(item.data.request.amount),
- false,
response.transaction_type,
response.transaction_status,
response.status,
diff --git a/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs
index 2a97dd7532..2edcc8fd50 100644
--- a/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/worldpayvantiv/transformers.rs
@@ -1712,61 +1712,25 @@ impl<F>
) -> Result<Self, Self::Error> {
match item.response.void_response {
Some(void_response) => {
- let status =
- get_attempt_status(WorldpayvantivPaymentFlow::VoidPC, void_response.response)?;
- if connector_utils::is_payment_failure(status) {
- Ok(Self {
- status,
- response: Err(ErrorResponse {
- code: void_response.response.to_string(),
- message: void_response.message.clone(),
- reason: Some(void_response.message.clone()),
- status_code: item.http_code,
- attempt_status: None,
- connector_transaction_id: Some(void_response.cnp_txn_id),
- connector_response_reference_id: None,
- network_advice_code: None,
- network_decline_code: None,
- network_error_message: None,
- connector_metadata: None,
- }),
- ..item.data
- })
- } else {
- Ok(Self {
- status,
- response: Ok(PaymentsResponseData::TransactionResponse {
- resource_id: ResponseId::ConnectorTransactionId(
- void_response.cnp_txn_id,
- ),
- redirection_data: Box::new(None),
- mandate_reference: Box::new(None),
- connector_metadata: None,
- network_txn_id: None,
- connector_response_reference_id: None,
- incremental_authorization_allowed: None,
- authentication_data: None,
- charges: None,
- }),
- ..item.data
- })
- }
+ let post_capture_void_status =
+ get_post_capture_void_status(void_response.response)?;
+ let description = post_capture_void_status
+ .is_post_capture_void_failure()
+ .then_some(void_response.message.clone());
+ Ok(Self {
+ response: Ok(PaymentsResponseData::PostCaptureVoidResponse {
+ post_capture_void_status,
+ connector_reference_id: Some(void_response.cnp_txn_id),
+ description,
+ }),
+ ..item.data
+ })
}
None => Ok(Self {
- // Incase of API failure
- status: common_enums::AttemptStatus::VoidFailed,
- response: Err(ErrorResponse {
- code: item.response.response_code,
- message: item.response.message.clone(),
- reason: Some(item.response.message.clone()),
- status_code: item.http_code,
- attempt_status: None,
- connector_transaction_id: None,
- connector_response_reference_id: None,
- network_advice_code: None,
- network_decline_code: None,
- network_error_message: None,
- connector_metadata: None,
+ response: Ok(PaymentsResponseData::PostCaptureVoidResponse {
+ post_capture_void_status: common_enums::PostCaptureVoidStatus::Failed,
+ connector_reference_id: None,
+ description: Some(item.response.message.clone()),
}),
..item.data
}),
@@ -3604,6 +3568,373 @@ fn get_payment_flow_type(input: &str) -> Result<WorldpayvantivPaymentFlow, error
}
}
+fn get_post_capture_void_status(
+ response: WorldpayvantivResponseCode,
+) -> Result<common_enums::PostCaptureVoidStatus, errors::ConnectorError> {
+ match response {
+ WorldpayvantivResponseCode::Approved
+ | WorldpayvantivResponseCode::PartiallyApproved
+ | WorldpayvantivResponseCode::OfflineApproval
+ | WorldpayvantivResponseCode::OfflineApprovalUnableToGoOnline
+ | WorldpayvantivResponseCode::ConsumerNonReloadablePrepaidCardApproved
+ | WorldpayvantivResponseCode::ConsumerSingleUseVirtualCardNumberApproved
+ | WorldpayvantivResponseCode::ScheduledRecurringPaymentProcessed
+ | WorldpayvantivResponseCode::ApprovedRecurringSubscriptionCreated
+ | WorldpayvantivResponseCode::PendingShopperCheckoutCompletion
+ | WorldpayvantivResponseCode::TransactionReceived
+ | WorldpayvantivResponseCode::AccountNumberWasSuccessfullyRegistered
+ | WorldpayvantivResponseCode::AccountNumberWasPreviouslyRegistered
+ | WorldpayvantivResponseCode::ValidToken
+ => Ok(common_enums::PostCaptureVoidStatus::Pending),
+ WorldpayvantivResponseCode::ShopperCheckoutExpired
+ | WorldpayvantivResponseCode::ProcessingNetworkUnavailable
+ | WorldpayvantivResponseCode::IssuerUnavailable
+ | WorldpayvantivResponseCode::ReSubmitTransaction
+ | WorldpayvantivResponseCode::TryAgainLater
+ | WorldpayvantivResponseCode::InsufficientFunds
+ | WorldpayvantivResponseCode::AuthorizationAmountHasAlreadyBeenDepleted
+ | WorldpayvantivResponseCode::InsufficientFundsRetryAfter1Hour
+ | WorldpayvantivResponseCode::InsufficientFundsRetryAfter24Hour
+ | WorldpayvantivResponseCode::InsufficientFundsRetryAfter2Days
+ | WorldpayvantivResponseCode::InsufficientFundsRetryAfter4Days
+ | WorldpayvantivResponseCode::InsufficientFundsRetryAfter6Days
+ | WorldpayvantivResponseCode::InsufficientFundsRetryAfter8Days
+ | WorldpayvantivResponseCode::InsufficientFundsRetryAfter10Days
+ | WorldpayvantivResponseCode::CallIssuer
+ | WorldpayvantivResponseCode::CallAmex
+ | WorldpayvantivResponseCode::CallDinersClub
+ | WorldpayvantivResponseCode::CallDiscover
+ | WorldpayvantivResponseCode::CallJbs
+ | WorldpayvantivResponseCode::CallVisaMastercard
+ | WorldpayvantivResponseCode::CallIssuerUpdateCardholderData
+ | WorldpayvantivResponseCode::ExceedsApprovalAmountLimit
+ | WorldpayvantivResponseCode::CallIndicatedNumber
+ | WorldpayvantivResponseCode::UnacceptablePinTransactionDeclinedRetry
+ | WorldpayvantivResponseCode::PinNotChanged
+ | WorldpayvantivResponseCode::ConsumerMultiUseVirtualCardNumberSoftDecline
+ | WorldpayvantivResponseCode::ConsumerNonReloadablePrepaidCardSoftDecline
+ | WorldpayvantivResponseCode::ConsumerSingleUseVirtualCardNumberSoftDecline
+ | WorldpayvantivResponseCode::UpdateCardholderData
+ | WorldpayvantivResponseCode::MerchantDoesntQualifyForProductCode
+ | WorldpayvantivResponseCode::Lifecycle
+ | WorldpayvantivResponseCode::Policy
+ | WorldpayvantivResponseCode::FraudSecurity
+ | WorldpayvantivResponseCode::InvalidOrExpiredCardContactCardholderToUpdate
+ | WorldpayvantivResponseCode::InvalidTransactionOrCardRestrictionVerifyInformationAndResubmit
+ | WorldpayvantivResponseCode::AtLeastOneOfOrigIdOrOrigCnpTxnIdIsRequired
+ | WorldpayvantivResponseCode::OrigCnpTxnIdIsRequiredWhenShowStatusOnlyIsUsed
+ | WorldpayvantivResponseCode::IncrementalAuthNotSupported
+ | WorldpayvantivResponseCode::SetAuthIndicatorToIncremental
+ | WorldpayvantivResponseCode::IncrementalValueForAuthIndicatorNotAllowedInThisAuthStructure
+ | WorldpayvantivResponseCode::CannotRequestAnIncrementalAuthIfOriginalAuthNotSetToEstimated
+ | WorldpayvantivResponseCode::TransactionMustReferenceTheEstimatedAuth
+ | WorldpayvantivResponseCode::IncrementedAuthExceedsMaxTransactionAmount
+ | WorldpayvantivResponseCode::SubmittedMccNotAllowed
+ | WorldpayvantivResponseCode::MerchantNotCertifiedEnabledForIias
+ | WorldpayvantivResponseCode::IssuerGeneratedError
+ | WorldpayvantivResponseCode::PickupCardOtherThanLostStolen
+ | WorldpayvantivResponseCode::InvalidAmountHardDecline
+ | WorldpayvantivResponseCode::ReversalUnsuccessful
+ | WorldpayvantivResponseCode::MissingData
+ | WorldpayvantivResponseCode::PickupCardLostCard
+ | WorldpayvantivResponseCode::PickupCardStolenCard
+ | WorldpayvantivResponseCode::RestrictedCard
+ | WorldpayvantivResponseCode::InvalidDeactivate
+ | WorldpayvantivResponseCode::CardAlreadyActive
+ | WorldpayvantivResponseCode::CardNotActive
+ | WorldpayvantivResponseCode::CardAlreadyDeactivate
+ | WorldpayvantivResponseCode::OverMaxBalance
+ | WorldpayvantivResponseCode::InvalidActivate
+ | WorldpayvantivResponseCode::NoTransactionFoundForReversal
+ | WorldpayvantivResponseCode::IncorrectCvv
+ | WorldpayvantivResponseCode::IllegalTransaction
+ | WorldpayvantivResponseCode::DuplicateTransaction
+ | WorldpayvantivResponseCode::SystemError
+ | WorldpayvantivResponseCode::DeconvertedBin
+ | WorldpayvantivResponseCode::MerchantDepleted
+ | WorldpayvantivResponseCode::GiftCardEscheated
+ | WorldpayvantivResponseCode::InvalidReversalTypeForCreditCardTransaction
+ | WorldpayvantivResponseCode::SystemErrorMessageFormatError
+ | WorldpayvantivResponseCode::SystemErrorCannotProcess
+ | WorldpayvantivResponseCode::RefundRejectedDueToPendingDepositStatus
+ | WorldpayvantivResponseCode::RefundRejectedDueToDeclinedDepositStatus
+ | WorldpayvantivResponseCode::RefundRejectedByTheProcessingNetwork
+ | WorldpayvantivResponseCode::CaptureCreditAndAuthReversalTagsCannotBeUsedForGiftCardTransactions
+ | WorldpayvantivResponseCode::InvalidAccountNumber
+ | WorldpayvantivResponseCode::AccountNumberDoesNotMatchPaymentType
+ | WorldpayvantivResponseCode::PickUpCard
+ | WorldpayvantivResponseCode::LostStolenCard
+ | WorldpayvantivResponseCode::ExpiredCard
+ | WorldpayvantivResponseCode::AuthorizationHasExpiredNoNeedToReverse
+ | WorldpayvantivResponseCode::RestrictedCardSoftDecline
+ | WorldpayvantivResponseCode::RestrictedCardChargeback
+ | WorldpayvantivResponseCode::RestrictedCardPrepaidCardFilteringService
+ | WorldpayvantivResponseCode::InvalidTrackData
+ | WorldpayvantivResponseCode::DepositIsAlreadyReferencedByAChargeback
+ | WorldpayvantivResponseCode::RestrictedCardInternationalCardFilteringService
+ | WorldpayvantivResponseCode::InternationalFilteringForIssuingCardCountry
+ | WorldpayvantivResponseCode::RestrictedCardAuthFraudVelocityFilteringService
+ | WorldpayvantivResponseCode::AutomaticRefundAlreadyIssued
+ | WorldpayvantivResponseCode::RestrictedCardAuthFraudAdviceFilteringService
+ | WorldpayvantivResponseCode::RestrictedCardFraudAvsFilteringService
+ | WorldpayvantivResponseCode::InvalidExpirationDate
+ | WorldpayvantivResponseCode::InvalidMerchant
+ | WorldpayvantivResponseCode::InvalidTransaction
+ | WorldpayvantivResponseCode::NoSuchIssuer
+ | WorldpayvantivResponseCode::InvalidPin
+ | WorldpayvantivResponseCode::TransactionNotAllowedAtTerminal
+ | WorldpayvantivResponseCode::ExceedsNumberOfPinEntries
+ | WorldpayvantivResponseCode::CardholderTransactionNotPermitted
+ | WorldpayvantivResponseCode::CardholderRequestedThatRecurringOrInstallmentPaymentBeStopped
+ | WorldpayvantivResponseCode::InvalidPaymentType
+ | WorldpayvantivResponseCode::InvalidPosCapabilityForCardholderAuthorizedTerminalTransaction
+ | WorldpayvantivResponseCode::InvalidPosCardholderIdForCardholderAuthorizedTerminalTransaction
+ | WorldpayvantivResponseCode::ThisMethodOfPaymentDoesNotSupportAuthorizationReversals
+ | WorldpayvantivResponseCode::ReversalAmountDoesNotMatchAuthorizationAmount
+ | WorldpayvantivResponseCode::TransactionDidNotConvertToPinless
+ | WorldpayvantivResponseCode::InvalidAmountSoftDecline
+ | WorldpayvantivResponseCode::InvalidHealthcareAmounts
+ | WorldpayvantivResponseCode::InvalidBillingDescriptorPrefix
+ | WorldpayvantivResponseCode::InvalidBillingDescriptor
+ | WorldpayvantivResponseCode::InvalidReportGroup
+ | WorldpayvantivResponseCode::DoNotHonor
+ | WorldpayvantivResponseCode::GenericDecline
+ | WorldpayvantivResponseCode::DeclineRequestPositiveId
+ | WorldpayvantivResponseCode::DeclineCvv2CidFail
+ | WorldpayvantivResponseCode::ThreeDSecureTransactionNotSupportedByMerchant
+ | WorldpayvantivResponseCode::InvalidPurchaseLevelIiiTheTransactionContainedBadOrMissingData
+ | WorldpayvantivResponseCode::MissingHealthcareIiasTagForAnFsaTransaction
+ | WorldpayvantivResponseCode::RestrictedByVantivDueToSecurityCodeMismatch
+ | WorldpayvantivResponseCode::NoTransactionFoundWithSpecifiedTransactionId
+ | WorldpayvantivResponseCode::AuthorizationNoLongerAvailable
+ | WorldpayvantivResponseCode::TransactionNotVoidedAlreadySettled
+ | WorldpayvantivResponseCode::AutoVoidOnRefund
+ | WorldpayvantivResponseCode::InvalidAccountNumberOriginalOrNocUpdatedECheckAccountRequired
+ | WorldpayvantivResponseCode::TotalCreditAmountExceedsCaptureAmount
+ | WorldpayvantivResponseCode::ExceedTheThresholdForSendingRedeposits
+ | WorldpayvantivResponseCode::DepositHasNotBeenReturnedForInsufficientNonSufficientFunds
+ | WorldpayvantivResponseCode::InvalidCheckNumber
+ | WorldpayvantivResponseCode::RedepositAgainstInvalidTransactionType
+ | WorldpayvantivResponseCode::InternalSystemErrorCallVantiv
+ | WorldpayvantivResponseCode::OriginalTransactionHasBeenProcessedFutureRedepositsCanceled
+ | WorldpayvantivResponseCode::SoftDeclineAutoRecyclingInProgress
+ | WorldpayvantivResponseCode::HardDeclineAutoRecyclingComplete
+ | WorldpayvantivResponseCode::RestrictedCardCardUnderSanction
+ | WorldpayvantivResponseCode::MerchantIsNotEnabledForSurcharging
+ | WorldpayvantivResponseCode::ThisMethodOfPaymentDoesNotSupportSurcharging
+ | WorldpayvantivResponseCode::SurchargeIsNotValidForDebitOrPrepaidCards
+ | WorldpayvantivResponseCode::SurchargeCannotExceedsTheMaximumAllowedLimit
+ | WorldpayvantivResponseCode::TransactionDeclinedByTheProcessingNetwork
+ | WorldpayvantivResponseCode::SecondaryAmountCannotExceedTheSaleAmount
+ | WorldpayvantivResponseCode::ThisMethodOfPaymentDoesNotSupportSecondaryAmount
+ | WorldpayvantivResponseCode::SecondaryAmountCannotBeLessThanZero
+ | WorldpayvantivResponseCode::PartialTransactionIsNotSupportedWhenIncludingASecondaryAmount
+ | WorldpayvantivResponseCode::SecondaryAmountRequiredOnPartialRefundWhenUsedOnDeposit
+ | WorldpayvantivResponseCode::SecondaryAmountNotAllowedOnRefundIfNotIncludedOnDeposit
+ | WorldpayvantivResponseCode::ProcessingNetworkError
+ | WorldpayvantivResponseCode::InvalidEMail
+ | WorldpayvantivResponseCode::InvalidCombinationOfAccountFundingTransactionTypeAndMcc
+ | WorldpayvantivResponseCode::InvalidAccountFundingTransactionTypeForThisMethodOfPayment
+ | WorldpayvantivResponseCode::MissingOneOrMoreReceiverFieldsForAccountFundingTransaction
+ | WorldpayvantivResponseCode::InvalidRecurringRequestSeeRecurringResponseForDetails
+ | WorldpayvantivResponseCode::ParentTransactionDeclinedRecurringSubscriptionNotCreated
+ | WorldpayvantivResponseCode::InvalidPlanCode
+ | WorldpayvantivResponseCode::InvalidSubscriptionId
+ | WorldpayvantivResponseCode::AddOnCodeAlreadyExists
+ | WorldpayvantivResponseCode::DuplicateAddOnCodesInRequests
+ | WorldpayvantivResponseCode::NoMatchingAddOnCodeForTheSubscription
+ | WorldpayvantivResponseCode::NoMatchingDiscountCodeForTheSubscription
+ | WorldpayvantivResponseCode::DuplicateDiscountCodesInRequest
+ | WorldpayvantivResponseCode::InvalidStartDate
+ | WorldpayvantivResponseCode::MerchantNotRegisteredForRecurringEngine
+ | WorldpayvantivResponseCode::InsufficientDataToUpdateSubscription
+ | WorldpayvantivResponseCode::InvalidBillingDate
+ | WorldpayvantivResponseCode::DiscountCodeAlreadyExists
+ | WorldpayvantivResponseCode::PlanCodeAlreadyExists
+ | WorldpayvantivResponseCode::TheAccountNumberWasChanged
+ | WorldpayvantivResponseCode::TheAccountWasClosed
+ | WorldpayvantivResponseCode::TheExpirationDateWasChanged
+ | WorldpayvantivResponseCode::TheIssuingBankDoesNotParticipateInTheUpdateProgram
+ | WorldpayvantivResponseCode::ContactTheCardholderForUpdatedInformation
+ | WorldpayvantivResponseCode::TheCardholderHasOptedOutOfTheUpdateProgram
+ | WorldpayvantivResponseCode::SoftDeclineCardReaderDecryptionServiceIsNotAvailable
+ | WorldpayvantivResponseCode::SoftDeclineDecryptionFailed
+ | WorldpayvantivResponseCode::HardDeclineInputDataIsInvalid
+ | WorldpayvantivResponseCode::ApplePayKeyMismatch
+ | WorldpayvantivResponseCode::ApplePayDecryptionFailed
+ | WorldpayvantivResponseCode::HardDeclineDecryptionFailed
+ | WorldpayvantivResponseCode::MerchantNotConfiguredForProcessingAtThisSite
+ | WorldpayvantivResponseCode::AdvancedFraudFilterScoreBelowThreshold
+ | WorldpayvantivResponseCode::SuspectedFraud
+ | WorldpayvantivResponseCode::SystemErrorContactWorldpayRepresentative
+ | WorldpayvantivResponseCode::AmazonPayAmazonUnavailable
+ | WorldpayvantivResponseCode::AmazonPayAmazonDeclined
+ | WorldpayvantivResponseCode::AmazonPayInvalidToken
+ | WorldpayvantivResponseCode::MerchantNotEnabledForAmazonPay
+ | WorldpayvantivResponseCode::TransactionNotSupportedBlockedByIssuer
+ | WorldpayvantivResponseCode::BlockedByCardholderContactCardholder
+ | WorldpayvantivResponseCode::SoftDeclinePrimaryFundingSourceFailed
+ | WorldpayvantivResponseCode::SoftDeclineBuyerHasAlternateFundingSource
+ | WorldpayvantivResponseCode::HardDeclineInvalidBillingAgreementId
+ | WorldpayvantivResponseCode::HardDeclinePrimaryFundingSourceFailed
+ | WorldpayvantivResponseCode::HardDeclineIssueWithPaypalAccount
+ | WorldpayvantivResponseCode::HardDeclinePayPalAuthorizationIdMissing
+ | WorldpayvantivResponseCode::HardDeclineConfirmedEmailAddressIsNotAvailable
+ | WorldpayvantivResponseCode::HardDeclinePayPalBuyerAccountDenied
+ | WorldpayvantivResponseCode::HardDeclinePayPalBuyerAccountRestricted
+ | WorldpayvantivResponseCode::HardDeclinePayPalOrderHasBeenVoidedExpiredOrCompleted
+ | WorldpayvantivResponseCode::HardDeclineIssueWithPayPalRefund
+ | WorldpayvantivResponseCode::HardDeclinePayPalCredentialsIssue
+ | WorldpayvantivResponseCode::HardDeclinePayPalAuthorizationVoidedOrExpired
+ | WorldpayvantivResponseCode::HardDeclineRequiredPayPalParameterMissing
+ | WorldpayvantivResponseCode::HardDeclinePayPalTransactionIdOrAuthIdIsInvalid
+ | WorldpayvantivResponseCode::HardDeclineExceededMaximumNumberOfPayPalAuthorizationAttempts
+ | WorldpayvantivResponseCode::HardDeclineTransactionAmountExceedsMerchantsPayPalAccountLimit
+ | WorldpayvantivResponseCode::HardDeclinePayPalFundingSourcesUnavailable
+ | WorldpayvantivResponseCode::HardDeclineIssueWithPayPalPrimaryFundingSource
+ | WorldpayvantivResponseCode::HardDeclinePayPalProfileDoesNotAllowThisTransactionType
+ | WorldpayvantivResponseCode::InternalSystemErrorWithPayPalContactVantiv
+ | WorldpayvantivResponseCode::HardDeclineContactPayPalConsumerForAnotherPaymentMethod
+ | WorldpayvantivResponseCode::InvalidTerminalId
+ | WorldpayvantivResponseCode::PinlessDebitProcessingNotSupportedForNonRecurringTransactions
+ | WorldpayvantivResponseCode::PinlessDebitProcessingNotSupportedForPartialAuths
+ | WorldpayvantivResponseCode::MerchantNotConfiguredForPinlessDebitProcessing
+ | WorldpayvantivResponseCode::DeclineCustomerCancellation
+ | WorldpayvantivResponseCode::DeclineReTryTransaction
+ | WorldpayvantivResponseCode::DeclineUnableToLocateRecordOnFile
+ | WorldpayvantivResponseCode::DeclineFileUpdateFieldEditError
+ | WorldpayvantivResponseCode::RemoteFunctionUnknown
+ | WorldpayvantivResponseCode::DeclinedExceedsWithdrawalFrequencyLimit
+ | WorldpayvantivResponseCode::DeclineCardRecordNotAvailable
+ | WorldpayvantivResponseCode::InvalidAuthorizationCode
+ | WorldpayvantivResponseCode::ReconciliationError
+ | WorldpayvantivResponseCode::PreferredDebitRoutingDenialCreditTransactionCanBeDebit
+ | WorldpayvantivResponseCode::DeclinedCurrencyConversionCompleteNoAuthPerformed
+ | WorldpayvantivResponseCode::DeclinedMultiCurrencyDccFail
+ | WorldpayvantivResponseCode::DeclinedMultiCurrencyInvertFail
+ | WorldpayvantivResponseCode::Invalid3DSecurePassword
+ | WorldpayvantivResponseCode::InvalidSocialSecurityNumber
+ | WorldpayvantivResponseCode::InvalidMothersMaidenName
+ | WorldpayvantivResponseCode::EnrollmentInquiryDeclined
+ | WorldpayvantivResponseCode::SocialSecurityNumberNotAvailable
+ | WorldpayvantivResponseCode::MothersMaidenNameNotAvailable
+ | WorldpayvantivResponseCode::PinAlreadyExistsOnDatabase
+ | WorldpayvantivResponseCode::Under18YearsOld
+ | WorldpayvantivResponseCode::BillToOutsideUsa
+ | WorldpayvantivResponseCode::BillToAddressIsNotEqualToShipToAddress
+ | WorldpayvantivResponseCode::DeclinedForeignCurrencyMustBeUsd
+ | WorldpayvantivResponseCode::OnNegativeFile
+ | WorldpayvantivResponseCode::BlockedAgreement
+ | WorldpayvantivResponseCode::InsufficientBuyingPower
+ | WorldpayvantivResponseCode::InvalidData
+ | WorldpayvantivResponseCode::InvalidDataDataElementsMissing
+ | WorldpayvantivResponseCode::InvalidDataDataFormatError
+ | WorldpayvantivResponseCode::InvalidDataInvalidTCVersion
+ | WorldpayvantivResponseCode::DuplicateTransactionPaypalCredit
+ | WorldpayvantivResponseCode::VerifyBillingAddress
+ | WorldpayvantivResponseCode::InactiveAccount
+ | WorldpayvantivResponseCode::InvalidAuth
+ | WorldpayvantivResponseCode::AuthorizationAlreadyExistsForTheOrder
+ | WorldpayvantivResponseCode::LodgingTransactionsAreNotAllowedForThisMcc
+ | WorldpayvantivResponseCode::DurationCannotBeNegative
+ | WorldpayvantivResponseCode::HotelFolioNumberCannotBeBlank
+ | WorldpayvantivResponseCode::InvalidCheckInDate
+ | WorldpayvantivResponseCode::InvalidCheckOutDate
+ | WorldpayvantivResponseCode::InvalidCheckInOrCheckOutDate
+ | WorldpayvantivResponseCode::CheckOutDateCannotBeBeforeCheckInDate
+ | WorldpayvantivResponseCode::NumberOfAdultsCannotBeNegative
+ | WorldpayvantivResponseCode::RoomRateCannotBeNegative
+ | WorldpayvantivResponseCode::RoomTaxCannotBeNegative
+ | WorldpayvantivResponseCode::DurationCanOnlyBeFrom0To99ForVisa
+ | WorldpayvantivResponseCode::MerchantIsNotAuthorizedForTokens
+ | WorldpayvantivResponseCode::CreditCardNumberWasInvalid
+ | WorldpayvantivResponseCode::TokenWasNotFound
+ | WorldpayvantivResponseCode::TokenInvalid
+ | WorldpayvantivResponseCode::MerchantNotAuthorizedForECheckTokens
+ | WorldpayvantivResponseCode::CheckoutIdWasInvalid
+ | WorldpayvantivResponseCode::CheckoutIdWasNotFound
+ | WorldpayvantivResponseCode::GenericCheckoutIdError
+ | WorldpayvantivResponseCode::CaptureAmountCanNotBeMoreThanAuthorizedAmount
+ | WorldpayvantivResponseCode::TaxBillingOnlyAllowedForMcc9311
+ | WorldpayvantivResponseCode::Mcc9311RequiresTaxTypeElement
+ | WorldpayvantivResponseCode::DebtRepaymentOnlyAllowedForViTransactionsOnMccs6012And6051
+ | WorldpayvantivResponseCode::RoutingNumberDidNotMatchOneOnFileForToken
+ | WorldpayvantivResponseCode::InvalidPayPageRegistrationId
+ | WorldpayvantivResponseCode::ExpiredPayPageRegistrationId
+ | WorldpayvantivResponseCode::MerchantIsNotAuthorizedForPayPage
+ | WorldpayvantivResponseCode::MaximumNumberOfUpdatesForThisTokenExceeded
+ | WorldpayvantivResponseCode::TooManyTokensCreatedForExistingNamespace
+ | WorldpayvantivResponseCode::PinValidationNotPossible
+ | WorldpayvantivResponseCode::GenericTokenRegistrationError
+ | WorldpayvantivResponseCode::GenericTokenUseError
+ | WorldpayvantivResponseCode::InvalidBankRoutingNumber
+ | WorldpayvantivResponseCode::MissingName
+ | WorldpayvantivResponseCode::InvalidName
+ | WorldpayvantivResponseCode::MissingBillingCountryCode
+ | WorldpayvantivResponseCode::InvalidIban
+ | WorldpayvantivResponseCode::MissingEmailAddress
+ | WorldpayvantivResponseCode::MissingMandateReference
+ | WorldpayvantivResponseCode::InvalidMandateReference
+ | WorldpayvantivResponseCode::MissingMandateUrl
+ | WorldpayvantivResponseCode::InvalidMandateUrl
+ | WorldpayvantivResponseCode::MissingMandateSignatureDate
+ | WorldpayvantivResponseCode::InvalidMandateSignatureDate
+ | WorldpayvantivResponseCode::RecurringMandateAlreadyExists
+ | WorldpayvantivResponseCode::RecurringMandateWasNotFound
+ | WorldpayvantivResponseCode::FinalRecurringWasAlreadyReceivedUsingThisMandate
+ | WorldpayvantivResponseCode::IbanDidNotMatchOneOnFileForMandate
+ | WorldpayvantivResponseCode::InvalidBillingCountry
+ | WorldpayvantivResponseCode::ExpirationDateRequiredForInteracTransaction
+ | WorldpayvantivResponseCode::TransactionTypeIsNotSupportedWithThisMethodOfPayment
+ | WorldpayvantivResponseCode::UnreferencedOrphanRefundsAreNotAllowed
+ | WorldpayvantivResponseCode::UnableToVoidATransactionWithAHeldState
+ | WorldpayvantivResponseCode::ThisFundingInstructionResultsInANegativeAccountBalance
+ | WorldpayvantivResponseCode::AccountBalanceInformationUnavailableAtThisTime
+ | WorldpayvantivResponseCode::TheSubmittedCardIsNotEligibleForFastAccessFunding
+ | WorldpayvantivResponseCode::TransactionCannotUseBothCcdPaymentInformationAndCtxPaymentInformation
+ | WorldpayvantivResponseCode::ProcessingError
+ | WorldpayvantivResponseCode::ThisFundingInstructionTypeIsInvalidForCanadianMerchants
+ | WorldpayvantivResponseCode::CtxAndCcdRecordsAreNotAllowedForCanadianMerchants
+ | WorldpayvantivResponseCode::CanadianAccountNumberCannotExceed12Digits
+ | WorldpayvantivResponseCode::ThisFundingInstructionTypeIsInvalid
+ | WorldpayvantivResponseCode::DeclineNegativeInformationOnFile
+ | WorldpayvantivResponseCode::AbsoluteDecline
+ | WorldpayvantivResponseCode::TheMerchantProfileDoesNotAllowTheRequestedOperation
+ | WorldpayvantivResponseCode::TheAccountCannotAcceptAchTransactions
+ | WorldpayvantivResponseCode::TheAccountCannotAcceptAchTransactionsOrSiteDrafts
+ | WorldpayvantivResponseCode::AmountGreaterThanLimitSpecifiedInTheMerchantProfile
+ | WorldpayvantivResponseCode::MerchantIsNotAuthorizedToPerformECheckVerificationTransactions
+ | WorldpayvantivResponseCode::FirstNameAndLastNameRequiredForECheckVerifications
+ | WorldpayvantivResponseCode::CompanyNameRequiredForCorporateAccountForECheckVerifications
+ | WorldpayvantivResponseCode::PhoneNumberRequiredForECheckVerifications
+ | WorldpayvantivResponseCode::CardBrandTokenNotSupported
+ | WorldpayvantivResponseCode::PrivateLabelCardNotSupported
+ | WorldpayvantivResponseCode::AllowedDailyDirectDebitCaptureECheckSaleLimitExceeded
+ | WorldpayvantivResponseCode::AllowedDailyDirectDebitCreditECheckCreditLimitExceeded
+ | WorldpayvantivResponseCode::AccountNotEligibleForRtp
+ | WorldpayvantivResponseCode::SoftDeclineCustomerAuthenticationRequired
+ | WorldpayvantivResponseCode::TransactionNotReversedVoidWorkflowNeedToBeInvoked
+ | WorldpayvantivResponseCode::TransactionReversalNotSupportedForTheCoreMerchants
+ | WorldpayvantivResponseCode::NoValidParentDepositOrParentRefundFound
+ | WorldpayvantivResponseCode::TransactionReversalNotEnabledForVisa
+ | WorldpayvantivResponseCode::TransactionReversalNotEnabledForMastercard
+ | WorldpayvantivResponseCode::TransactionReversalNotEnabledForAmEx
+ | WorldpayvantivResponseCode::TransactionReversalNotEnabledForDiscover
+ | WorldpayvantivResponseCode::TransactionReversalNotSupported
+ | WorldpayvantivResponseCode::FundingInstructionHeldPleaseContactYourRelationshipManager
+ | WorldpayvantivResponseCode::MissingAddressInformation
+ | WorldpayvantivResponseCode::CryptographicFailure
+ | WorldpayvantivResponseCode::InvalidRegionCode
+ | WorldpayvantivResponseCode::InvalidCountryCode
+ | WorldpayvantivResponseCode::InvalidCreditAccount
+ | WorldpayvantivResponseCode::InvalidCheckingAccount
+ | WorldpayvantivResponseCode::InvalidSavingsAccount
+ | WorldpayvantivResponseCode::InvalidUseOfMccCorrectAndReattempt
+ | WorldpayvantivResponseCode::ExceedsRtpTransactionLimit
+ => Ok(common_enums::PostCaptureVoidStatus::Failed)
+ }
+}
+
fn get_attempt_status(
flow: WorldpayvantivPaymentFlow,
response: WorldpayvantivResponseCode,
diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs
index 6f3ce2f4ba..3dfcfcbca3 100644
--- a/crates/hyperswitch_connectors/src/default_implementations.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations.rs
@@ -1257,9 +1257,19 @@ macro_rules! default_imp_for_cancel_post_capture {
ConnectorIntegration<
PostCaptureVoid,
PaymentsCancelPostCaptureData,
- PaymentsResponseData,
+ PaymentsResponseData,
> for $path::$connector
- {}
+ {
+ fn build_request(
+ &self,
+ _req: &hyperswitch_domain_models::types::PaymentsCancelPostCaptureRouterData,
+ _connectors: &hyperswitch_interfaces::configs::Connectors
+ ) -> CustomResult<Option<common_utils::request::Request>, hyperswitch_interfaces::errors::ConnectorError> {
+ Err(hyperswitch_interfaces::errors::ConnectorError::NotImplemented(
+ "Cancel post capture not implemented for this connector".to_string(),
+ ).into())
+ }
+ }
)*
};
}
diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rs
index 593c723139..58efc13516 100644
--- a/crates/hyperswitch_domain_models/src/payments.rs
+++ b/crates/hyperswitch_domain_models/src/payments.rs
@@ -340,6 +340,28 @@ impl PaymentIntent {
})
}
+ #[cfg(feature = "v1")]
+ pub fn prevent_refund_after_post_capture_void(
+ &self,
+ ) -> CustomResult<(), crate::errors::api_error_response::ApiErrorResponse> {
+ if self
+ .state_metadata
+ .as_ref()
+ .map(|state_metadata| state_metadata.is_post_capture_void_issued())
+ .unwrap_or(false)
+ {
+ Err(error_stack::report!(
+ crate::errors::api_error_response::ApiErrorResponse::PreconditionFailed {
+ message:
+ "Refund void cannot be performed after a post-capture void has been issued"
+ .into()
+ }
+ ))
+ } else {
+ Ok(())
+ }
+ }
+
#[cfg(feature = "v1")]
pub fn validate_amount_against_intent_state_metadata(
&self,
diff --git a/crates/hyperswitch_domain_models/src/router_data.rs b/crates/hyperswitch_domain_models/src/router_data.rs
index 84f4e111fc..b41ee89084 100644
--- a/crates/hyperswitch_domain_models/src/router_data.rs
+++ b/crates/hyperswitch_domain_models/src/router_data.rs
@@ -1005,6 +1005,9 @@ impl
router_response_types::PaymentsResponseData::PaymentsCreateOrderResponse {
..
} => todo!(),
+ router_response_types::PaymentsResponseData::PostCaptureVoidResponse { .. } => {
+ todo!()
+ }
},
Err(ref error_response) => {
let ErrorResponse {
@@ -1333,6 +1336,9 @@ impl
router_response_types::PaymentsResponseData::PaymentsCreateOrderResponse {
..
} => todo!(),
+ router_response_types::PaymentsResponseData::PostCaptureVoidResponse { .. } => {
+ todo!()
+ }
},
Err(ref error_response) => {
let ErrorResponse {
@@ -1657,6 +1663,9 @@ impl
router_response_types::PaymentsResponseData::PaymentsCreateOrderResponse {
..
} => todo!(),
+ router_response_types::PaymentsResponseData::PostCaptureVoidResponse { .. } => {
+ todo!()
+ }
},
Err(ref error_response) => {
let ErrorResponse {
@@ -1948,6 +1957,9 @@ impl
router_response_types::PaymentsResponseData::PaymentsCreateOrderResponse {
..
} => todo!(),
+ router_response_types::PaymentsResponseData::PostCaptureVoidResponse { .. } => {
+ todo!()
+ }
},
Err(ref error_response) => {
let ErrorResponse {
@@ -2202,6 +2214,9 @@ impl
router_response_types::PaymentsResponseData::PaymentsCreateOrderResponse {
..
} => todo!(),
+ router_response_types::PaymentsResponseData::PostCaptureVoidResponse { .. } => {
+ todo!()
+ }
},
Err(ref error_response) => {
let ErrorResponse {
diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs
index 1607059560..57a7624c46 100644
--- a/crates/hyperswitch_domain_models/src/router_response_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_response_types.rs
@@ -67,6 +67,11 @@ pub enum PaymentsResponseData {
authentication_data: Option<Box<UcsAuthenticationData>>,
charges: Option<common_types::payments::ConnectorChargeResponseData>,
},
+ PostCaptureVoidResponse {
+ post_capture_void_status: common_enums::PostCaptureVoidStatus,
+ connector_reference_id: Option<String>,
+ description: Option<String>,
+ },
MultipleCaptureResponse {
// pending_capture_id_list: Vec<String>,
capture_sync_response_list: HashMap<String, CaptureSyncResponse>,
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index cbba050253..d488a9ff77 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -303,6 +303,8 @@ Never share your secret api keys. Keep them guarded and secure.
common_types::payments::MerchantApplicationDetails,
common_types::connector_webhook_configuration::WebhookSetupCapabilities,
common_types::connector_webhook_configuration::WebhookConfigType,
+ common_types::payments::PaymentIntentStateMetadata,
+ common_types::payments::PostCaptureVoidResponse,
api_models::enums::PaymentChannel,
api_models::three_ds_decision_rule::ThreeDsDecisionRuleExecuteRequest,
api_models::three_ds_decision_rule::ThreeDsDecisionRuleExecuteResponse,
@@ -834,6 +836,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::routing::RoutingVolumeSplitResponse,
api_models::routing::ast::RoutableChoiceKind,
api_models::enums::RoutableConnectors,
+ api_models::enums::PostCaptureVoidStatus,
api_models::routing::ast::ProgramConnectorSelection,
api_models::routing::ast::RuleConnectorSelection,
api_models::routing::ast::IfStatement,
diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs
index 4b1f652729..5cc8b9a086 100644
--- a/crates/openapi/src/openapi_v2.rs
+++ b/crates/openapi/src/openapi_v2.rs
@@ -241,6 +241,8 @@ Never share your secret api keys. Keep them guarded and secure.
common_types::refunds::SplitRefund,
common_types::payments::ConnectorChargeResponseData,
common_types::payments::StripeChargeResponseData,
+ common_types::payments::PaymentIntentStateMetadata,
+ common_types::payments::PostCaptureVoidResponse,
common_types::three_ds_decision_rule_engine::ThreeDSDecisionRule,
common_types::three_ds_decision_rule_engine::ThreeDSDecision,
api_models::payments::CartesBancairesParams,
@@ -385,6 +387,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::enums::VaultTokenType,
api_models::enums::StorageType,
api_models::enums::AcknowledgementStatus,
+ api_models::enums::PostCaptureVoidStatus,
api_models::admin::MerchantConnectorCreate,
api_models::admin::AdditionalMerchantData,
api_models::admin::CardTestingGuardConfig,
diff --git a/crates/openapi/src/routes/payments.rs b/crates/openapi/src/routes/payments.rs
index 1a9a2370ca..6351acb48d 100644
--- a/crates/openapi/src/routes/payments.rs
+++ b/crates/openapi/src/routes/payments.rs
@@ -837,7 +837,7 @@ pub fn payments_cancel() {}
("payment_id" = String, Path, description = "The identifier for payment")
),
responses(
- (status = 200, description = "Payment canceled post capture"),
+ (status = 200, description = "Payment canceled post capture", body = PaymentsResponse),
(status = 400, description = "Missing mandatory fields", body = GenericErrorResponseOpenApi)
),
tag = "Payments",
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 76852f6ce4..b185b7ea9c 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
@@ -75,7 +75,6 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelPo
&[
enums::IntentStatus::Succeeded,
enums::IntentStatus::PartiallyCaptured,
- enums::IntentStatus::PartiallyCapturedAndCapturable,
],
"cancel_post_capture",
)?;
@@ -210,6 +209,30 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelPo
Ok(get_trackers_response)
}
+
+ async fn validate_request_with_state(
+ &self,
+ _state: &SessionState,
+ _request: &api::PaymentsCancelPostCaptureRequest,
+ payment_data: &mut PaymentData<F>,
+ _business_profile: &domain::Profile,
+ ) -> RouterResult<()> {
+ // Validates that no refunds have been issued against the payment before allowing post-capture void
+ let is_refund_issued = payment_data
+ .refunds
+ .iter()
+ .any(|refund| refund.is_refund_applied());
+ crate::utils::when(is_refund_issued, || {
+ Err(error_stack::report!(
+ errors::ApiErrorResponse::PreconditionFailed {
+ message: "Post-capture void cannot be performed after a refund has been issued"
+ .into()
+ }
+ ))
+ })?;
+
+ Ok(())
+ }
}
#[async_trait]
diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs
index ea2bbb99a5..06f791cf8f 100644
--- a/crates/router/src/core/payments/operations/payment_response.rs
+++ b/crates/router/src/core/payments/operations/payment_response.rs
@@ -2072,6 +2072,8 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
429 => router_data.status,
_ => enums::AttemptStatus::Failure,
}
+ } else if sub_flow == "CancelPostCapture" {
+ router_data.status
} else {
match err.status_code {
500..=511 => enums::AttemptStatus::Pending,
@@ -2529,6 +2531,9 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
types::PaymentsResponseData::PaymentsCreateOrderResponse { .. } => {
(None, None, None)
}
+ types::PaymentsResponseData::PostCaptureVoidResponse { .. } => {
+ (None, None, None)
+ }
}
}
}
@@ -2656,37 +2661,12 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
&payment_data,
);
- let payment_intent_update = match &router_data.response {
- Err(_) => storage::PaymentIntentUpdate::PGStatusUpdate {
- status: api_models::enums::IntentStatus::foreign_from(
- payment_data.payment_attempt.status,
- ),
- updated_by: processor.get_account().storage_scheme.to_string(),
- // make this false only if initial payment fails, if incremental authorization call fails don't make it false
- incremental_authorization_allowed: Some(false),
- feature_metadata: payment_data
- .payment_intent
- .feature_metadata
- .clone()
- .map(masking::Secret::new),
- },
- Ok(_) => storage::PaymentIntentUpdate::ResponseUpdate {
- status: api_models::enums::IntentStatus::foreign_from(
- payment_data.payment_attempt.status,
- ),
- amount_captured,
- updated_by: processor.get_account().storage_scheme.to_string(),
- fingerprint_id: payment_data.payment_attempt.fingerprint_id.clone(),
- incremental_authorization_allowed: payment_data
- .payment_intent
- .incremental_authorization_allowed,
- feature_metadata: payment_data
- .payment_intent
- .feature_metadata
- .clone()
- .map(masking::Secret::new),
- },
- };
+ let payment_intent_update = get_payment_intent_update_data::<_, _>(
+ payment_data.clone(),
+ &router_data,
+ processor,
+ amount_captured,
+ );
let m_db = state.clone().store;
let m_key_store = processor.get_key_store().clone();
@@ -2844,6 +2824,68 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
}
}
+#[cfg(feature = "v1")]
+fn get_payment_intent_update_data<F: Clone, T: types::Capturable>(
+ payment_data: PaymentData<F>,
+ router_data: &types::RouterData<F, T, types::PaymentsResponseData>,
+ processor: &domain::Processor,
+ amount_captured: Option<MinorUnit>,
+) -> storage::PaymentIntentUpdate {
+ match &router_data.response {
+ Err(_) => storage::PaymentIntentUpdate::PGStatusUpdate {
+ status: api_models::enums::IntentStatus::foreign_from(
+ payment_data.payment_attempt.status,
+ ),
+ updated_by: processor.get_account().storage_scheme.to_string(),
+ incremental_authorization_allowed: Some(false),
+ feature_metadata: payment_data
+ .payment_intent
+ .feature_metadata
+ .clone()
+ .map(masking::Secret::new),
+ },
+ Ok(types::PaymentsResponseData::PostCaptureVoidResponse {
+ post_capture_void_status,
+ connector_reference_id,
+ description,
+ }) => {
+ let post_capture_void_response = common_types::domain::PostCaptureVoidData {
+ status: *post_capture_void_status,
+ connector_reference_id: connector_reference_id.clone(),
+ description: description.clone(),
+ };
+
+ let current_state = payment_data
+ .payment_intent
+ .state_metadata
+ .clone()
+ .unwrap_or_default()
+ .set_post_capture_void_data(post_capture_void_response);
+
+ storage::PaymentIntentUpdate::StateMetadataUpdate {
+ state_metadata: current_state.clone(),
+ updated_by: processor.get_account().storage_scheme.to_string(),
+ }
+ }
+ Ok(_) => storage::PaymentIntentUpdate::ResponseUpdate {
+ status: api_models::enums::IntentStatus::foreign_from(
+ payment_data.payment_attempt.status,
+ ),
+ amount_captured,
+ updated_by: processor.get_account().storage_scheme.to_string(),
+ fingerprint_id: payment_data.payment_attempt.fingerprint_id.clone(),
+ incremental_authorization_allowed: payment_data
+ .payment_intent
+ .incremental_authorization_allowed,
+ feature_metadata: payment_data
+ .payment_intent
+ .feature_metadata
+ .clone()
+ .map(masking::Secret::new),
+ },
+ }
+}
+
#[cfg(feature = "v2")]
async fn update_payment_method_status_and_ntid<F: Clone>(
state: &SessionState,
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index b6f1ef2b48..719d21919f 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -4007,6 +4007,7 @@ where
initiator: initiator.and_then(|initiator| initiator.to_api_initiator()),
sdk_authorization: Some(sdk_authorization),
connector: routed_through,
+ state_metadata: payment_intent.state_metadata,
client_secret: payment_intent.client_secret.map(Secret::new),
created: Some(payment_intent.created_at),
modified_at: Some(payment_intent.modified_at),
@@ -4304,6 +4305,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
status: pi.status,
amount: pi.amount,
amount_capturable: pa.amount_capturable,
+ state_metadata: pi.state_metadata,
client_secret: pi.client_secret.map(|s| s.into()),
created: Some(pi.created_at),
modified_at: Some(pi.modified_at),
diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rs
index ce265b3596..91fa2fd4c6 100644
--- a/crates/router/src/core/refunds.rs
+++ b/crates/router/src/core/refunds.rs
@@ -98,6 +98,8 @@ pub async fn refund_create_core(
.attach_printable("refund amount validation against payment intent failed")
})?;
+ payment_intent.prevent_refund_after_post_capture_void()?;
+
// Amount is not passed in request refer from payment intent.
amount = req
.amount
diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rs
index bbf3863d91..4422216b38 100644
--- a/crates/router/src/db/events.rs
+++ b/crates/router/src/db/events.rs
@@ -1529,6 +1529,7 @@ mod tests {
partner_merchant_identifier_details: None,
payment_method_tokenization_details: None,
error_details: None,
+ state_metadata: None,
};
let content =
api_webhooks::OutgoingWebhookContent::PaymentDetails(Box::new(expected_response));
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index 2242267805..7c0bb96fc7 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -556,30 +556,13 @@ impl Capturable for PaymentsCancelPostCaptureData {
&self,
_payment_data: &PaymentData<F>,
_amount_capturable: Option<i64>,
- attempt_status: common_enums::AttemptStatus,
+ _attempt_status: common_enums::AttemptStatus,
) -> Option<i64>
where
F: Clone,
{
- let intent_status = common_enums::IntentStatus::foreign_from(attempt_status);
- match intent_status {
- common_enums::IntentStatus::Cancelled
- | common_enums::IntentStatus::CancelledPostCapture
- | common_enums::IntentStatus::PartiallyCaptured
- | common_enums::IntentStatus::Conflicted
- | common_enums::IntentStatus::Expired => Some(0),
- common_enums::IntentStatus::Succeeded
- | common_enums::IntentStatus::Failed
- | common_enums::IntentStatus::RequiresCustomerAction
- | common_enums::IntentStatus::RequiresMerchantAction
- | common_enums::IntentStatus::RequiresPaymentMethod
- | common_enums::IntentStatus::RequiresConfirmation
- | common_enums::IntentStatus::RequiresCapture
- | common_enums::IntentStatus::PartiallyCapturedAndCapturable
- | common_enums::IntentStatus::Processing
- | common_enums::IntentStatus::PartiallyCapturedAndProcessing
- | common_enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture => None,
- }
+ // Capture not available after post capture void flow, hence return 0
+ Some(0)
}
}
impl Capturable for PaymentsApproveData {}
diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs
index 1440c6beef..ab2f8988a9 100644
--- a/crates/router/tests/connectors/utils.rs
+++ b/crates/router/tests/connectors/utils.rs
@@ -592,6 +592,7 @@ pub trait ConnectorActions: Connector {
Ok(types::PaymentsResponseData::PostProcessingResponse { .. }) => None,
Ok(types::PaymentsResponseData::PaymentResourceUpdateResponse { .. }) => None,
Ok(types::PaymentsResponseData::PaymentsCreateOrderResponse { .. }) => None,
+ Ok(types::PaymentsResponseData::PostCaptureVoidResponse { .. }) => None,
Err(_) => None,
}
}
@@ -1185,6 +1186,7 @@ pub fn get_connector_transaction_id(
Ok(types::PaymentsResponseData::PostProcessingResponse { .. }) => None,
Ok(types::PaymentsResponseData::PaymentResourceUpdateResponse { .. }) => None,
Ok(types::PaymentsResponseData::PaymentsCreateOrderResponse { .. }) => None,
+ Ok(types::PaymentsResponseData::PostCaptureVoidResponse { .. }) => None,
Err(_) => None,
}
}
diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rs
index 6c2977c987..361b70b96f 100644
--- a/crates/router/tests/payments.rs
+++ b/crates/router/tests/payments.rs
@@ -480,6 +480,7 @@ async fn payments_create_core() {
partner_merchant_identifier_details: None,
payment_method_tokenization_details: None,
error_details: None,
+ state_metadata: None,
};
let expected_response =
services::ApplicationResponse::JsonWithHeaders((expected_response, vec![]));
@@ -778,6 +779,7 @@ async fn payments_create_core_adyen_no_redirect() {
partner_merchant_identifier_details: None,
payment_method_tokenization_details: None,
error_details: None,
+ state_metadata: None,
},
vec![],
));
diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rs
index 5831f8606e..6f7f436e82 100644
--- a/crates/router/tests/payments2.rs
+++ b/crates/router/tests/payments2.rs
@@ -240,6 +240,7 @@ async fn payments_create_core() {
partner_merchant_identifier_details: None,
payment_method_tokenization_details: None,
error_details: None,
+ state_metadata: None,
};
let expected_response =
@@ -547,6 +548,7 @@ async fn payments_create_core_adyen_no_redirect() {
partner_merchant_identifier_details: None,
payment_method_tokenization_details: None,
error_details: None,
+ state_metadata: None,
},
vec![],
));