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

fix(core): add request_extended_authorization in the payment attempt and populate it in the payment response (#9492)

AkshayaFoiger8e629abc92ae
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index bd1d8887c4..6ac0ad192b 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -24132,6 +24132,12 @@
"description": "flag that indicates if extended authorization is applied on this payment or not",
"nullable": true
},
+ "request_extended_authorization": {
+ "type": "boolean",
+ "description": "Optional boolean value to extent authorization period of this payment\n\ncapture method must be manual or manual_multiple",
+ "default": false,
+ "nullable": true
+ },
"capture_before": {
"type": "string",
"format": "date-time",
@@ -25556,6 +25562,12 @@
"description": "flag that indicates if extended authorization is applied on this payment or not",
"nullable": true
},
+ "request_extended_authorization": {
+ "type": "boolean",
+ "description": "Optional boolean value to extent authorization period of this payment\n\ncapture method must be manual or manual_multiple",
+ "default": false,
+ "nullable": true
+ },
"capture_before": {
"type": "string",
"format": "date-time",
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index fa21426a44..f4e2451ab6 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -5615,6 +5615,12 @@ pub struct PaymentsResponse {
#[schema(value_type = Option<bool>)]
pub extended_authorization_applied: Option<ExtendedAuthorizationAppliedBool>,
+ /// Optional boolean value to extent authorization period of this payment
+ ///
+ /// capture method must be manual or manual_multiple
+ #[schema(value_type = Option<bool>, default = false)]
+ pub request_extended_authorization: Option<RequestExtendedAuthorizationBool>,
+
/// date and time after which this payment cannot be captured
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub capture_before: Option<PrimitiveDateTime>,
diff --git a/crates/diesel_models/src/payment_attempt.rs b/crates/diesel_models/src/payment_attempt.rs
index f8799e541f..8cd2525b84 100644
--- a/crates/diesel_models/src/payment_attempt.rs
+++ b/crates/diesel_models/src/payment_attempt.rs
@@ -529,6 +529,7 @@ pub enum PaymentAttemptUpdate {
routing_approach: Option<storage_enums::RoutingApproach>,
connector_request_reference_id: Option<String>,
network_transaction_id: Option<String>,
+ request_extended_authorization: Option<RequestExtendedAuthorizationBool>,
},
VoidUpdate {
status: storage_enums::AttemptStatus,
@@ -1085,6 +1086,7 @@ pub struct PaymentAttemptUpdateInternal {
pub network_transaction_id: Option<String>,
pub is_overcapture_enabled: Option<OvercaptureEnabledBool>,
pub network_details: Option<NetworkDetails>,
+ pub request_extended_authorization: Option<RequestExtendedAuthorizationBool>,
}
#[cfg(feature = "v1")]
@@ -1279,6 +1281,7 @@ impl PaymentAttemptUpdate {
network_transaction_id,
is_overcapture_enabled,
network_details,
+ request_extended_authorization,
} = PaymentAttemptUpdateInternal::from(self).populate_derived_fields(&source);
PaymentAttempt {
amount: amount.unwrap_or(source.amount),
@@ -1351,6 +1354,8 @@ impl PaymentAttemptUpdate {
network_transaction_id: network_transaction_id.or(source.network_transaction_id),
is_overcapture_enabled: is_overcapture_enabled.or(source.is_overcapture_enabled),
network_details: network_details.or(source.network_details),
+ request_extended_authorization: request_extended_authorization
+ .or(source.request_extended_authorization),
..source
}
}
@@ -2691,6 +2696,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
},
PaymentAttemptUpdate::AuthenticationTypeUpdate {
authentication_type,
@@ -2758,6 +2764,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
},
PaymentAttemptUpdate::ConfirmUpdate {
amount,
@@ -2796,6 +2803,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
routing_approach,
connector_request_reference_id,
network_transaction_id,
+ request_extended_authorization,
} => Self {
amount: Some(amount),
currency: Some(currency),
@@ -2859,6 +2867,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization,
},
PaymentAttemptUpdate::VoidUpdate {
status,
@@ -2927,6 +2936,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
},
PaymentAttemptUpdate::RejectUpdate {
status,
@@ -2996,6 +3006,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
},
PaymentAttemptUpdate::BlocklistUpdate {
status,
@@ -3065,6 +3076,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
},
PaymentAttemptUpdate::ConnectorMandateDetailUpdate {
connector_mandate_detail,
@@ -3132,6 +3144,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
},
PaymentAttemptUpdate::PaymentMethodDetailsUpdate {
payment_method_id,
@@ -3199,6 +3212,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
},
PaymentAttemptUpdate::ResponseUpdate {
status,
@@ -3296,6 +3310,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id,
is_overcapture_enabled,
network_details: None,
+ request_extended_authorization: None,
}
}
PaymentAttemptUpdate::ErrorUpdate {
@@ -3383,6 +3398,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details,
+ request_extended_authorization: None,
}
}
PaymentAttemptUpdate::StatusUpdate { status, updated_by } => Self {
@@ -3448,6 +3464,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
},
PaymentAttemptUpdate::UpdateTrackers {
payment_token,
@@ -3522,6 +3539,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
},
PaymentAttemptUpdate::UnresolvedResponseUpdate {
status,
@@ -3602,6 +3620,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
}
}
PaymentAttemptUpdate::PreprocessingUpdate {
@@ -3681,6 +3700,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
}
}
PaymentAttemptUpdate::CaptureUpdate {
@@ -3750,6 +3770,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
},
PaymentAttemptUpdate::AmountToCaptureUpdate {
status,
@@ -3818,6 +3839,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
},
PaymentAttemptUpdate::ConnectorResponse {
authentication_data,
@@ -3895,6 +3917,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
}
}
PaymentAttemptUpdate::IncrementalAuthorizationAmountUpdate {
@@ -3963,6 +3986,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
},
PaymentAttemptUpdate::AuthenticationUpdate {
status,
@@ -4033,6 +4057,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
},
PaymentAttemptUpdate::ManualUpdate {
status,
@@ -4112,6 +4137,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
}
}
PaymentAttemptUpdate::PostSessionTokensUpdate {
@@ -4180,6 +4206,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
network_transaction_id: None,
is_overcapture_enabled: None,
network_details: None,
+ request_extended_authorization: None,
},
}
}
diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rs
index 9675d9b40a..2cc1bcf3b0 100644
--- a/crates/hyperswitch_domain_models/src/payments.rs
+++ b/crates/hyperswitch_domain_models/src/payments.rs
@@ -189,16 +189,24 @@ impl PaymentIntent {
}
};
let intent_request_extended_authorization_optional = self.request_extended_authorization;
- if always_request_extended_authorization_optional.is_some_and(
- |always_request_extended_authorization| *always_request_extended_authorization,
- ) || intent_request_extended_authorization_optional.is_some_and(
- |intent_request_extended_authorization| *intent_request_extended_authorization,
- ) {
- Some(is_extended_authorization_supported_by_connector())
- } else {
- None
- }
- .map(RequestExtendedAuthorizationBool::from)
+
+ let is_extended_authorization_requested = intent_request_extended_authorization_optional
+ .map(|should_request_extended_authorization| *should_request_extended_authorization)
+ .or(always_request_extended_authorization_optional.map(
+ |should_always_request_extended_authorization| {
+ *should_always_request_extended_authorization
+ },
+ ));
+
+ is_extended_authorization_requested
+ .map(|requested| {
+ if requested {
+ is_extended_authorization_supported_by_connector()
+ } else {
+ false
+ }
+ })
+ .map(RequestExtendedAuthorizationBool::from)
}
#[cfg(feature = "v1")]
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
index 383f94a894..f1b50182f7 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
@@ -1407,6 +1407,7 @@ pub enum PaymentAttemptUpdate {
routing_approach: Option<storage_enums::RoutingApproach>,
connector_request_reference_id: Option<String>,
network_transaction_id: Option<String>,
+ request_extended_authorization: Option<RequestExtendedAuthorizationBool>,
},
RejectUpdate {
status: storage_enums::AttemptStatus,
@@ -1682,6 +1683,7 @@ impl PaymentAttemptUpdate {
routing_approach,
connector_request_reference_id,
network_transaction_id,
+ request_extended_authorization,
} => DieselPaymentAttemptUpdate::ConfirmUpdate {
amount: net_amount.get_order_amount(),
currency,
@@ -1726,6 +1728,7 @@ impl PaymentAttemptUpdate {
}),
connector_request_reference_id,
network_transaction_id,
+ request_extended_authorization,
},
Self::VoidUpdate {
status,
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index cbfdd05362..2c867aa608 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -1988,6 +1988,9 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
.payment_attempt
.network_transaction_id
.clone(),
+ request_extended_authorization: payment_data
+ .payment_attempt
+ .request_extended_authorization,
},
storage_scheme,
)
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index fa84e14911..cbb022a9f7 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -3658,6 +3658,7 @@ where
network_details: payment_attempt
.network_details
.map(NetworkDetails::foreign_from),
+ request_extended_authorization: payment_attempt.request_extended_authorization,
};
services::ApplicationResponse::JsonWithHeaders((payments_response, headers))
@@ -3958,6 +3959,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
enable_overcapture: pi.enable_overcapture,
is_overcapture_enabled: pa.is_overcapture_enabled,
network_details: pa.network_details.map(NetworkDetails::foreign_from),
+ request_extended_authorization: pa.request_extended_authorization,
}
}
}
diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rs
index 29acb4ecff..0058c9fd56 100644
--- a/crates/router/src/db/events.rs
+++ b/crates/router/src/db/events.rs
@@ -1411,6 +1411,7 @@ mod tests {
is_overcapture_enabled: None,
enable_overcapture: None,
network_details: None,
+ request_extended_authorization: None,
};
let content =
api_webhooks::OutgoingWebhookContent::PaymentDetails(Box::new(expected_response));
diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rs
index f52e4c2b03..2010707067 100644
--- a/crates/router/tests/payments.rs
+++ b/crates/router/tests/payments.rs
@@ -471,6 +471,7 @@ async fn payments_create_core() {
is_overcapture_enabled: None,
enable_overcapture: None,
network_details: None,
+ request_extended_authorization: None,
};
let expected_response =
services::ApplicationResponse::JsonWithHeaders((expected_response, vec![]));
@@ -755,6 +756,7 @@ async fn payments_create_core_adyen_no_redirect() {
is_overcapture_enabled: None,
enable_overcapture: None,
network_details: None,
+ request_extended_authorization: None,
},
vec![],
));
diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rs
index 8307d11eef..ef7f435764 100644
--- a/crates/router/tests/payments2.rs
+++ b/crates/router/tests/payments2.rs
@@ -233,6 +233,7 @@ async fn payments_create_core() {
is_overcapture_enabled: None,
enable_overcapture: None,
network_details: None,
+ request_extended_authorization: None,
};
let expected_response =
@@ -525,6 +526,7 @@ async fn payments_create_core_adyen_no_redirect() {
is_overcapture_enabled: None,
enable_overcapture: None,
network_details: None,
+ request_extended_authorization: None,
},
vec![],
));