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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(router): Add payments get-intent API for v2 (#6396)
Anurag Thakurc514608594eb
diff --git a/api-reference-v2/api-reference/payments/payments--get-intent.mdx b/api-reference-v2/api-reference/payments/payments--get-intent.mdxnew file mode 100644index 0000000000..cd1321be21--- /dev/null+++ b/api-reference-v2/api-reference/payments/payments--get-intent.mdx@@ -0,0 +1,3 @@+---+openapi: get /v2/payments/{id}/get-intent+---\ No newline at end of filediff --git a/api-reference-v2/mint.json b/api-reference-v2/mint.jsonindex 974e530f31..17dd6dfb7f 100644--- a/api-reference-v2/mint.json+++ b/api-reference-v2/mint.json@@ -38,6 +38,7 @@"group": "Payments","pages": ["api-reference/payments/payments--create-intent",+ "api-reference/payments/payments--get-intent","api-reference/payments/payments--session-token","api-reference/payments/payments--confirm-intent"]diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.jsonindex 06bbf125df..0c46790260 100644--- a/api-reference-v2/openapi_spec.json+++ b/api-reference-v2/openapi_spec.json@@ -1843,7 +1843,7 @@"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/PaymentsCreateIntentResponse"+ "$ref": "#/components/schemas/PaymentsIntentResponse"}}}@@ -1859,6 +1859,47 @@]}},+ "/v2/payments/{id}/get-intent": {+ "get": {+ "tags": [+ "Payments"+ ],+ "summary": "Payments - Get Intent",+ "description": "**Get a payment intent object when id is passed in path**\n\nYou will require the 'API - Key' from the Hyperswitch dashboard to make the call.",+ "operationId": "Get the Payment Intent details",+ "parameters": [+ {+ "name": "id",+ "in": "path",+ "description": "The unique identifier for the Payment Intent",+ "required": true,+ "schema": {+ "type": "string"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "Payment Intent",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/PaymentsIntentResponse"+ }+ }+ }+ },+ "404": {+ "description": "Payment Intent not found"+ }+ },+ "security": [+ {+ "api_key": []+ }+ ]+ }+ },"/v2/payments/{id}/confirm-intent": {"post": {"tags": [@@ -13568,179 +13609,6 @@},"additionalProperties": false},- "PaymentsCreateIntentResponse": {- "type": "object",- "required": [- "id",- "amount_details",- "client_secret",- "capture_method",- "authentication_type",- "customer_present",- "setup_future_usage",- "apply_mit_exemption",- "payment_link_enabled",- "request_incremental_authorization",- "expires_on",- "request_external_three_ds_authentication"- ],- "properties": {- "id": {- "type": "string",- "description": "Global Payment Id for the payment"- },- "amount_details": {- "$ref": "#/components/schemas/AmountDetailsResponse"- },- "client_secret": {- "type": "string",- "description": "It's a token used for client side verification.",- "example": "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo"- },- "merchant_reference_id": {- "type": "string",- "description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat have been done by a single merchant.",- "example": "pay_mbabizu24mvu3mela5njyhpit4",- "nullable": true,- "maxLength": 30,- "minLength": 30- },- "routing_algorithm_id": {- "type": "string",- "description": "The routing algorithm id to be used for the payment",- "nullable": true- },- "capture_method": {- "$ref": "#/components/schemas/CaptureMethod"- },- "authentication_type": {- "allOf": [- {- "$ref": "#/components/schemas/AuthenticationType"- }- ],- "default": "no_three_ds"- },- "billing": {- "allOf": [- {- "$ref": "#/components/schemas/Address"- }- ],- "nullable": true- },- "shipping": {- "allOf": [- {- "$ref": "#/components/schemas/Address"- }- ],- "nullable": true- },- "customer_id": {- "type": "string",- "description": "The identifier for the customer",- "example": "cus_y3oqhf46pyzuxjbcn2giaqnb44",- "nullable": true,- "maxLength": 64,- "minLength": 1- },- "customer_present": {- "$ref": "#/components/schemas/PresenceOfCustomerDuringPayment"- },- "description": {- "type": "string",- "description": "A description for the payment",- "example": "It's my first payment request",- "nullable": true- },- "return_url": {- "type": "string",- "description": "The URL to which you want the user to be redirected after the completion of the payment operation",- "example": "https://hyperswitch.io",- "nullable": true- },- "setup_future_usage": {- "$ref": "#/components/schemas/FutureUsage"- },- "apply_mit_exemption": {- "$ref": "#/components/schemas/MitExemptionRequest"- },- "statement_descriptor": {- "type": "string",- "description": "For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters.",- "example": "Hyperswitch Router",- "nullable": true,- "maxLength": 22- },- "order_details": {- "type": "array",- "items": {- "$ref": "#/components/schemas/OrderDetailsWithAmount"- },- "description": "Use this object to capture the details about the different products for which the payment is being made. The sum of amount across different products here should be equal to the overall payment amount",- "example": "[{\n \"product_name\": \"Apple iPhone 16\",\n \"quantity\": 1,\n \"amount\" : 69000\n \"product_img_link\" : \"https://dummy-img-link.com\"\n }]",- "nullable": true- },- "allowed_payment_method_types": {- "type": "array",- "items": {- "$ref": "#/components/schemas/PaymentMethodType"- },- "description": "Use this parameter to restrict the Payment Method Types to show for a given PaymentIntent",- "nullable": true- },- "metadata": {- "type": "object",- "description": "Metadata is useful for storing additional, unstructured information on an object.",- "nullable": true- },- "connector_metadata": {- "allOf": [- {- "$ref": "#/components/schemas/ConnectorMetadata"- }- ],- "nullable": true- },- "feature_metadata": {- "allOf": [- {- "$ref": "#/components/schemas/FeatureMetadata"- }- ],- "nullable": true- },- "payment_link_enabled": {- "$ref": "#/components/schemas/EnablePaymentLinkRequest"- },- "payment_link_config": {- "allOf": [- {- "$ref": "#/components/schemas/PaymentLinkConfigRequest"- }- ],- "nullable": true- },- "request_incremental_authorization": {- "$ref": "#/components/schemas/RequestIncrementalAuthorization"- },- "expires_on": {- "type": "string",- "format": "date-time",- "description": "Will be used to expire client secret after certain amount of time to be supplied in seconds"- },- "frm_metadata": {- "type": "object",- "description": "Additional data related to some frm(Fraud Risk Management) connectors",- "nullable": true- },- "request_external_three_ds_authentication": {- "$ref": "#/components/schemas/External3dsAuthenticationRequest"- }- },- "additionalProperties": false- },"PaymentsCreateResponseOpenApi": {"type": "object","required": [@@ -14434,6 +14302,179 @@}}},+ "PaymentsIntentResponse": {+ "type": "object",+ "required": [+ "id",+ "amount_details",+ "client_secret",+ "capture_method",+ "authentication_type",+ "customer_present",+ "setup_future_usage",+ "apply_mit_exemption",+ "payment_link_enabled",+ "request_incremental_authorization",+ "expires_on",+ "request_external_three_ds_authentication"+ ],+ "properties": {+ "id": {+ "type": "string",+ "description": "Global Payment Id for the payment"+ },+ "amount_details": {+ "$ref": "#/components/schemas/AmountDetailsResponse"+ },+ "client_secret": {+ "type": "string",+ "description": "It's a token used for client side verification.",+ "example": "pay_U42c409qyHwOkWo3vK60_secret_el9ksDkiB8hi6j9N78yo"+ },+ "merchant_reference_id": {+ "type": "string",+ "description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat have been done by a single merchant.",+ "example": "pay_mbabizu24mvu3mela5njyhpit4",+ "nullable": true,+ "maxLength": 30,+ "minLength": 30+ },+ "routing_algorithm_id": {+ "type": "string",+ "description": "The routing algorithm id to be used for the payment",+ "nullable": true+ },+ "capture_method": {+ "$ref": "#/components/schemas/CaptureMethod"+ },+ "authentication_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/AuthenticationType"+ }+ ],+ "default": "no_three_ds"+ },+ "billing": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Address"+ }+ ],+ "nullable": true+ },+ "shipping": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Address"+ }+ ],+ "nullable": true+ },+ "customer_id": {+ "type": "string",+ "description": "The identifier for the customer",+ "example": "cus_y3oqhf46pyzuxjbcn2giaqnb44",+ "nullable": true,+ "maxLength": 64,+ "minLength": 1+ },+ "customer_present": {+ "$ref": "#/components/schemas/PresenceOfCustomerDuringPayment"+ },+ "description": {+ "type": "string",+ "description": "A description for the payment",+ "example": "It's my first payment request",+ "nullable": true+ },+ "return_url": {+ "type": "string",+ "description": "The URL to which you want the user to be redirected after the completion of the payment operation",+ "example": "https://hyperswitch.io",+ "nullable": true+ },+ "setup_future_usage": {+ "$ref": "#/components/schemas/FutureUsage"+ },+ "apply_mit_exemption": {+ "$ref": "#/components/schemas/MitExemptionRequest"+ },+ "statement_descriptor": {+ "type": "string",+ "description": "For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters.",+ "example": "Hyperswitch Router",+ "nullable": true,+ "maxLength": 22+ },+ "order_details": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/OrderDetailsWithAmount"+ },+ "description": "Use this object to capture the details about the different products for which the payment is being made. The sum of amount across different products here should be equal to the overall payment amount",+ "example": "[{\n \"product_name\": \"Apple iPhone 16\",\n \"quantity\": 1,\n \"amount\" : 69000\n \"product_img_link\" : \"https://dummy-img-link.com\"\n }]",+ "nullable": true+ },+ "allowed_payment_method_types": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/PaymentMethodType"+ },+ "description": "Use this parameter to restrict the Payment Method Types to show for a given PaymentIntent",+ "nullable": true+ },+ "metadata": {+ "type": "object",+ "description": "Metadata is useful for storing additional, unstructured information on an object.",+ "nullable": true+ },+ "connector_metadata": {+ "allOf": [+ {+ "$ref": "#/components/schemas/ConnectorMetadata"+ }+ ],+ "nullable": true+ },+ "feature_metadata": {+ "allOf": [+ {+ "$ref": "#/components/schemas/FeatureMetadata"+ }+ ],+ "nullable": true+ },+ "payment_link_enabled": {+ "$ref": "#/components/schemas/EnablePaymentLinkRequest"+ },+ "payment_link_config": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentLinkConfigRequest"+ }+ ],+ "nullable": true+ },+ "request_incremental_authorization": {+ "$ref": "#/components/schemas/RequestIncrementalAuthorization"+ },+ "expires_on": {+ "type": "string",+ "format": "date-time",+ "description": "Will be used to expire client secret after certain amount of time to be supplied in seconds"+ },+ "frm_metadata": {+ "type": "object",+ "description": "Additional data related to some frm(Fraud Risk Management) connectors",+ "nullable": true+ },+ "request_external_three_ds_authentication": {+ "$ref": "#/components/schemas/External3dsAuthenticationRequest"+ }+ },+ "additionalProperties": false+ },"PaymentsResponse": {"type": "object","required": [diff --git a/crates/api_models/src/events/payment.rs b/crates/api_models/src/events/payment.rsindex 000343864b..b9dc1476fd 100644--- a/crates/api_models/src/events/payment.rs+++ b/crates/api_models/src/events/payment.rs@@ -2,7 +2,8 @@ use common_utils::events::{ApiEventMetric, ApiEventsType};#[cfg(feature = "v2")]use super::{- PaymentsConfirmIntentResponse, PaymentsCreateIntentRequest, PaymentsCreateIntentResponse,+ PaymentsConfirmIntentResponse, PaymentsCreateIntentRequest, PaymentsGetIntentRequest,+ PaymentsIntentResponse,};#[cfg(all(any(feature = "v2", feature = "v1"),@@ -150,7 +151,16 @@ impl ApiEventMetric for PaymentsCreateIntentRequest {}#[cfg(feature = "v2")]-impl ApiEventMetric for PaymentsCreateIntentResponse {+impl ApiEventMetric for PaymentsGetIntentRequest {+ fn get_api_event_type(&self) -> Option<ApiEventsType> {+ Some(ApiEventsType::Payment {+ payment_id: self.id.clone(),+ })+ }+}++#[cfg(feature = "v2")]+impl ApiEventMetric for PaymentsIntentResponse {fn get_api_event_type(&self) -> Option<ApiEventsType> {Some(ApiEventsType::Payment {payment_id: self.id.clone(),diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 2f90db83c5..ceb2b65487 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -287,10 +287,17 @@ impl PaymentsCreateIntentRequest {}}+// This struct is only used internally, not visible in API Reference+#[derive(Debug, Clone, serde::Serialize)]+#[cfg(feature = "v2")]+pub struct PaymentsGetIntentRequest {+ pub id: id_type::GlobalPaymentId,+}+#[derive(Debug, serde::Serialize, Clone, ToSchema)]#[serde(deny_unknown_fields)]#[cfg(feature = "v2")]-pub struct PaymentsCreateIntentResponse {+pub struct PaymentsIntentResponse {/// Global Payment Id for the payment#[schema(value_type = String)]pub id: id_type::GlobalPaymentId,diff --git a/crates/hyperswitch_domain_models/src/router_flow_types/payments.rs b/crates/hyperswitch_domain_models/src/router_flow_types/payments.rsindex 602c184139..c43d72ce8d 100644--- a/crates/hyperswitch_domain_models/src/router_flow_types/payments.rs+++ b/crates/hyperswitch_domain_models/src/router_flow_types/payments.rs@@ -57,7 +57,10 @@ pub struct CalculateTax;pub struct SdkSessionUpdate;#[derive(Debug, Clone)]-pub struct CreateIntent;+pub struct PaymentCreateIntent;++#[derive(Debug, Clone)]+pub struct PaymentGetIntent;#[derive(Debug, Clone)]pub struct PostSessionTokens;diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex 7bbe019dcb..dacaedd976 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -123,6 +123,7 @@ Never share your secret api keys. Keep them guarded and secure.//Routes for paymentsroutes::payments::payments_create_intent,+ routes::payments::payments_get_intent,routes::payments::payments_confirm_intent,//Routes for refunds@@ -325,7 +326,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payments::PaymentsSessionRequest,api_models::payments::PaymentsSessionResponse,api_models::payments::PaymentsCreateIntentRequest,- api_models::payments::PaymentsCreateIntentResponse,+ api_models::payments::PaymentsIntentResponse,api_models::payments::PazeWalletData,api_models::payments::AmountDetails,api_models::payments::SessionToken,diff --git a/crates/openapi/src/routes/payments.rs b/crates/openapi/src/routes/payments.rsindex 3429de60ba..e245c5af68 100644--- a/crates/openapi/src/routes/payments.rs+++ b/crates/openapi/src/routes/payments.rs@@ -620,7 +620,7 @@ pub fn payments_post_session_tokens() {}),),responses(- (status = 200, description = "Payment created", body = PaymentsCreateIntentResponse),+ (status = 200, description = "Payment created", body = PaymentsIntentResponse),(status = 400, description = "Missing Mandatory fields")),tag = "Payments",@@ -630,6 +630,25 @@ pub fn payments_post_session_tokens() {}#[cfg(feature = "v2")]pub fn payments_create_intent() {}+/// Payments - Get Intent+///+/// **Get a payment intent object when id is passed in path**+///+/// You will require the 'API - Key' from the Hyperswitch dashboard to make the call.+#[utoipa::path(+ get,+ path = "/v2/payments/{id}/get-intent",+ params (("id" = String, Path, description = "The unique identifier for the Payment Intent")),+ responses(+ (status = 200, description = "Payment Intent", body = PaymentsIntentResponse),+ (status = 404, description = "Payment Intent not found")+ ),+ tag = "Payments",+ operation_id = "Get the Payment Intent details",+ security(("api_key" = [])),+)]+#[cfg(feature = "v2")]+pub fn payments_get_intent() {}/// Payments - Confirm Intent////// **Confirms a payment intent object with the payment method data**diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex de58eeed10..860394f7c4 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -1021,7 +1021,7 @@ pub async fn payments_intent_operation_core<F, Req, Op, D>() -> RouterResult<(D, Req, Option<domain::Customer>)>whereF: Send + Clone + Sync,- Req: Authenticate + Clone,+ Req: Clone,Op: Operation<F, Req, Data = D> + Send + Sync,D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,{@@ -1454,7 +1454,7 @@ pub async fn payments_intent_core<F, Res, Req, Op, D>(whereF: Send + Clone + Sync,Op: Operation<F, Req, Data = D> + Send + Sync + Clone,- Req: Debug + Authenticate + Clone,+ Req: Debug + Clone,D: OperationSessionGetters<F> + OperationSessionSetters<F> + Send + Sync + Clone,Res: transformers::ToResponse<F, D, Op>,{diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rsindex 6546638a62..b03f41ac0f 100644--- a/crates/router/src/core/payments/operations.rs+++ b/crates/router/src/core/payments/operations.rs@@ -28,11 +28,12 @@ pub mod payments_incremental_authorization;#[cfg(feature = "v1")]pub mod tax_calculation;+#[cfg(feature = "v2")]+pub mod payment_confirm_intent;#[cfg(feature = "v2")]pub mod payment_create_intent;-#[cfg(feature = "v2")]-pub mod payment_confirm_intent;+pub mod payment_get_intent;use api_models::enums::FrmSuggestion;#[cfg(all(feature = "v1", feature = "dynamic_routing"))]@@ -45,6 +46,8 @@ use router_env::{instrument, tracing};pub use self::payment_confirm_intent::PaymentIntentConfirm;#[cfg(feature = "v2")]pub use self::payment_create_intent::PaymentIntentCreate;+#[cfg(feature = "v2")]+pub use self::payment_get_intent::PaymentGetIntent;pub use self::payment_response::PaymentResponse;#[cfg(feature = "v1")]pub use self::{diff --git a/crates/router/src/core/payments/operations/payment_get_intent.rs b/crates/router/src/core/payments/operations/payment_get_intent.rsnew file mode 100644index 0000000000..55ddc3b482--- /dev/null+++ b/crates/router/src/core/payments/operations/payment_get_intent.rs@@ -0,0 +1,231 @@+use std::marker::PhantomData;++use api_models::{enums::FrmSuggestion, payments::PaymentsGetIntentRequest};+use async_trait::async_trait;+use common_utils::errors::CustomResult;+use router_env::{instrument, tracing};++use super::{BoxedOperation, Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};+use crate::{+ core::{+ errors::{self, RouterResult},+ payments::{self, helpers, operations},+ },+ db::errors::StorageErrorExt,+ routes::{app::ReqState, SessionState},+ types::{+ api, domain,+ storage::{self, enums},+ },+};++#[derive(Debug, Clone, Copy)]+pub struct PaymentGetIntent;++impl<F: Send + Clone> Operation<F, PaymentsGetIntentRequest> for &PaymentGetIntent {+ type Data = payments::PaymentIntentData<F>;+ fn to_validate_request(+ &self,+ ) -> RouterResult<&(dyn ValidateRequest<F, PaymentsGetIntentRequest, Self::Data> + Send + Sync)>+ {+ Ok(*self)+ }+ fn to_get_tracker(+ &self,+ ) -> RouterResult<&(dyn GetTracker<F, Self::Data, PaymentsGetIntentRequest> + Send + Sync)>+ {+ Ok(*self)+ }+ fn to_domain(&self) -> RouterResult<&(dyn Domain<F, PaymentsGetIntentRequest, Self::Data>)> {+ Ok(*self)+ }+ fn to_update_tracker(+ &self,+ ) -> RouterResult<&(dyn UpdateTracker<F, Self::Data, PaymentsGetIntentRequest> + Send + Sync)>+ {+ Ok(*self)+ }+}++impl<F: Send + Clone> Operation<F, PaymentsGetIntentRequest> for PaymentGetIntent {+ type Data = payments::PaymentIntentData<F>;+ fn to_validate_request(+ &self,+ ) -> RouterResult<&(dyn ValidateRequest<F, PaymentsGetIntentRequest, Self::Data> + Send + Sync)>+ {+ Ok(self)+ }+ fn to_get_tracker(+ &self,+ ) -> RouterResult<&(dyn GetTracker<F, Self::Data, PaymentsGetIntentRequest> + Send + Sync)>+ {+ Ok(self)+ }+ fn to_domain(&self) -> RouterResult<&dyn Domain<F, PaymentsGetIntentRequest, Self::Data>> {+ Ok(self)+ }+ fn to_update_tracker(+ &self,+ ) -> RouterResult<&(dyn UpdateTracker<F, Self::Data, PaymentsGetIntentRequest> + Send + Sync)>+ {+ Ok(self)+ }+}++type PaymentsGetIntentOperation<'b, F> =+ BoxedOperation<'b, F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>;++#[async_trait]+impl<F: Send + Clone> GetTracker<F, payments::PaymentIntentData<F>, PaymentsGetIntentRequest>+ for PaymentGetIntent+{+ #[instrument(skip_all)]+ async fn get_trackers<'a>(+ &'a self,+ state: &'a SessionState,+ _payment_id: &common_utils::id_type::GlobalPaymentId,+ request: &PaymentsGetIntentRequest,+ merchant_account: &domain::MerchantAccount,+ _profile: &domain::Profile,+ key_store: &domain::MerchantKeyStore,+ _header_payload: &hyperswitch_domain_models::payments::HeaderPayload,+ ) -> RouterResult<+ operations::GetTrackerResponse<+ 'a,+ F,+ PaymentsGetIntentRequest,+ payments::PaymentIntentData<F>,+ >,+ > {+ let db = &*state.store;+ let key_manager_state = &state.into();+ let storage_scheme = merchant_account.storage_scheme;+ let payment_intent = db+ .find_payment_intent_by_id(key_manager_state, &request.id, key_store, storage_scheme)+ .await+ .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;++ let payment_data = payments::PaymentIntentData {+ flow: PhantomData,+ payment_intent,+ };++ let get_trackers_response = operations::GetTrackerResponse {+ operation: Box::new(self),+ payment_data,+ };++ Ok(get_trackers_response)+ }+}++#[async_trait]+impl<F: Clone> UpdateTracker<F, payments::PaymentIntentData<F>, PaymentsGetIntentRequest>+ for PaymentGetIntent+{+ #[instrument(skip_all)]+ async fn update_trackers<'b>(+ &'b self,+ _state: &'b SessionState,+ _req_state: ReqState,+ payment_data: payments::PaymentIntentData<F>,+ _customer: Option<domain::Customer>,+ _storage_scheme: enums::MerchantStorageScheme,+ _updated_customer: Option<storage::CustomerUpdate>,+ _key_store: &domain::MerchantKeyStore,+ _frm_suggestion: Option<FrmSuggestion>,+ _header_payload: hyperswitch_domain_models::payments::HeaderPayload,+ ) -> RouterResult<(+ PaymentsGetIntentOperation<'b, F>,+ payments::PaymentIntentData<F>,+ )>+ where+ F: 'b + Send,+ {+ Ok((Box::new(self), payment_data))+ }+}++impl<F: Send + Clone> ValidateRequest<F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>+ for PaymentGetIntent+{+ #[instrument(skip_all)]+ fn validate_request<'a, 'b>(+ &'b self,+ _request: &PaymentsGetIntentRequest,+ merchant_account: &'a domain::MerchantAccount,+ ) -> RouterResult<(+ PaymentsGetIntentOperation<'b, F>,+ operations::ValidateResult,+ )> {+ Ok((+ Box::new(self),+ operations::ValidateResult {+ merchant_id: merchant_account.get_id().to_owned(),+ storage_scheme: merchant_account.storage_scheme,+ requeue: false,+ },+ ))+ }+}++#[async_trait]+impl<F: Clone + Send> Domain<F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>+ for PaymentGetIntent+{+ #[instrument(skip_all)]+ async fn get_customer_details<'a>(+ &'a self,+ state: &SessionState,+ payment_data: &mut payments::PaymentIntentData<F>,+ merchant_key_store: &domain::MerchantKeyStore,+ storage_scheme: enums::MerchantStorageScheme,+ ) -> CustomResult<+ (+ BoxedOperation<'a, F, PaymentsGetIntentRequest, payments::PaymentIntentData<F>>,+ Option<domain::Customer>,+ ),+ errors::StorageError,+ > {+ Ok((Box::new(self), None))+ }++ #[instrument(skip_all)]+ async fn make_pm_data<'a>(+ &'a self,+ _state: &'a SessionState,+ _payment_data: &mut payments::PaymentIntentData<F>,+ _storage_scheme: enums::MerchantStorageScheme,+ _merchant_key_store: &domain::MerchantKeyStore,+ _customer: &Option<domain::Customer>,+ _business_profile: &domain::Profile,+ ) -> RouterResult<(+ PaymentsGetIntentOperation<'a, F>,+ Option<domain::PaymentMethodData>,+ Option<String>,+ )> {+ Ok((Box::new(self), None, None))+ }++ async fn get_connector<'a>(+ &'a self,+ _merchant_account: &domain::MerchantAccount,+ state: &SessionState,+ _request: &PaymentsGetIntentRequest,+ _payment_intent: &storage::PaymentIntent,+ _merchant_key_store: &domain::MerchantKeyStore,+ ) -> CustomResult<api::ConnectorChoice, errors::ApiErrorResponse> {+ helpers::get_connector_default(state, None).await+ }++ #[instrument(skip_all)]+ async fn guard_payment_against_blocklist<'a>(+ &'a self,+ _state: &SessionState,+ _merchant_account: &domain::MerchantAccount,+ _key_store: &domain::MerchantKeyStore,+ _payment_data: &mut payments::PaymentIntentData<F>,+ ) -> CustomResult<bool, errors::ApiErrorResponse> {+ Ok(false)+ }+}diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex c623ad86e6..e059ebdb8b 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -755,7 +755,7 @@ where}#[cfg(feature = "v2")]-impl<F, Op, D> ToResponse<F, D, Op> for api::PaymentsCreateIntentResponse+impl<F, Op, D> ToResponse<F, D, Op> for api::PaymentsIntentResponsewhereF: Clone,Op: Debug,diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rsindex f54895ce7d..ae099a36e4 100644--- a/crates/router/src/routes/app.rs+++ b/crates/router/src/routes/app.rs@@ -527,6 +527,10 @@ impl Payments {web::resource("/confirm-intent").route(web::post().to(payments::payment_confirm_intent)),)+ .service(+ web::resource("/get-intent")+ .route(web::get().to(payments::payments_get_intent)),+ ).service(web::resource("/create-external-sdk-tokens").route(web::post().to(payments::payments_connector_session)),diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rsindex ac17cf8021..43ddc35b8a 100644--- a/crates/router/src/routes/lock_utils.rs+++ b/crates/router/src/routes/lock_utils.rs@@ -139,6 +139,7 @@ impl From<Flow> for ApiIdentifier {| Flow::SessionUpdateTaxCalculation| Flow::PaymentsConfirmIntent| Flow::PaymentsCreateIntent+ | Flow::PaymentsGetIntent| Flow::PaymentsPostSessionTokens => Self::Payments,Flow::PayoutsCreatediff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rsindex bca7bd37cc..62cb4a0b79 100644--- a/crates/router/src/routes/payments.rs+++ b/crates/router/src/routes/payments.rs@@ -125,11 +125,11 @@ pub async fn payments_create_intent(json_payload.into_inner(),|state, auth: auth::AuthenticationDataV2, req, req_state| {payments::payments_intent_core::<- api_types::CreateIntent,- payment_types::PaymentsCreateIntentResponse,+ api_types::PaymentCreateIntent,+ payment_types::PaymentsIntentResponse,_,_,- PaymentIntentData<api_types::CreateIntent>,+ PaymentIntentData<api_types::PaymentCreateIntent>,>(state,req_state,@@ -156,6 +156,57 @@ pub async fn payments_create_intent(.await}+#[cfg(feature = "v2")]+#[instrument(skip_all, fields(flow = ?Flow::PaymentsGetIntent, payment_id))]+pub async fn payments_get_intent(+ state: web::Data<app::AppState>,+ req: actix_web::HttpRequest,+ path: web::Path<common_utils::id_type::GlobalPaymentId>,+) -> impl Responder {+ use api_models::payments::PaymentsGetIntentRequest;+ use hyperswitch_domain_models::payments::PaymentIntentData;++ let flow = Flow::PaymentsGetIntent;+ let header_payload = match HeaderPayload::foreign_try_from(req.headers()) {+ Ok(headers) => headers,+ Err(err) => {+ return api::log_and_return_error_response(err);+ }+ };++ let payload = PaymentsGetIntentRequest {+ id: path.into_inner(),+ };++ Box::pin(api::server_wrap(+ flow,+ state,+ &req,+ payload,+ |state, auth: auth::AuthenticationDataV2, req, req_state| {+ payments::payments_intent_core::<+ api_types::PaymentGetIntent,+ payment_types::PaymentsIntentResponse,+ _,+ _,+ PaymentIntentData<api_types::PaymentGetIntent>,+ >(+ state,+ req_state,+ auth.merchant_account,+ auth.profile,+ auth.key_store,+ payments::operations::PaymentGetIntent,+ req,+ header_payload.clone(),+ )+ },+ &auth::HeaderAuth(auth::ApiKeyAuth),+ api_locking::LockAction::NotApplicable,+ ))+ .await+}+#[cfg(feature = "v1")]#[instrument(skip(state, req), fields(flow = ?Flow::PaymentsStart, payment_id))]pub async fn payments_start(diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rsindex 02d4950a47..2cf8b721a0 100644--- a/crates/router/src/services/api.rs+++ b/crates/router/src/services/api.rs@@ -1259,10 +1259,8 @@ impl Authenticate for api_models::payments::PaymentsIncrementalAuthorizationRequimpl Authenticate for api_models::payments::PaymentsStartRequest {}// impl Authenticate for api_models::payments::PaymentsApproveRequest {}impl Authenticate for api_models::payments::PaymentsRejectRequest {}-#[cfg(feature = "v2")]-impl Authenticate for api_models::payments::PaymentsCreateIntentRequest {}// #[cfg(feature = "v2")]-// impl Authenticate for api_models::payments::PaymentsCreateIntentResponse {}+// impl Authenticate for api_models::payments::PaymentsIntentResponse {}pub fn build_redirection_form(form: &RedirectForm,diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rsindex fc13cc6a22..57ef1d3336 100644--- a/crates/router/src/types/api/payments.rs+++ b/crates/router/src/types/api/payments.rs@@ -19,13 +19,13 @@ pub use api_models::payments::{VerifyResponse, WalletData,};#[cfg(feature = "v2")]-pub use api_models::payments::{PaymentsCreateIntentRequest, PaymentsCreateIntentResponse};+pub use api_models::payments::{PaymentsCreateIntentRequest, PaymentsIntentResponse};use error_stack::ResultExt;pub use hyperswitch_domain_models::router_flow_types::payments::{Approve, Authorize, AuthorizeSessionToken, Balance, CalculateTax, Capture, CompleteAuthorize,- CreateConnectorCustomer, CreateIntent, IncrementalAuthorization, InitPayment, PSync,- PaymentMethodToken, PostProcessing, PostSessionTokens, PreProcessing, Reject, SdkSessionUpdate,- Session, SetupMandate, Void,+ CreateConnectorCustomer, IncrementalAuthorization, InitPayment, PSync, PaymentCreateIntent,+ PaymentGetIntent, PaymentMethodToken, PostProcessing, PostSessionTokens, PreProcessing, Reject,+ SdkSessionUpdate, Session, SetupMandate, Void,};pub use hyperswitch_interfaces::api::payments::{ConnectorCustomer, MandateSetup, Payment, PaymentApprove, PaymentAuthorize,diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rsindex 652ce2b81d..2410be9750 100644--- a/crates/router_env/src/logger/types.rs+++ b/crates/router_env/src/logger/types.rs@@ -171,6 +171,8 @@ pub enum Flow {PaymentsAggregate,/// Payments Create Intent flowPaymentsCreateIntent,+ /// Payments Get Intent flow+ PaymentsGetIntent,#[cfg(feature = "payouts")]/// Payouts create flowPayoutsCreate,