diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 2cd5467f06eb..2ea0f42a7f49 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -6942,6 +6942,31 @@ } ] }, + "CtpServiceDetails": { + "type": "object", + "properties": { + "merchant_transaction_id": { + "type": "string", + "description": "merchant transaction id", + "nullable": true + }, + "correlation_id": { + "type": "string", + "description": "network transaction correlation id", + "nullable": true + }, + "x_src_flow_id": { + "type": "string", + "description": "session transaction flow id", + "nullable": true + }, + "provider": { + "type": "string", + "description": "provider Eg: Visa, Mastercard", + "nullable": true + } + } + }, "Currency": { "type": "string", "description": "The three letter ISO currency code in uppercase. Eg: 'USD' for the United States Dollar.", diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index 937dc7ab2d9a..832f8da9c419 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -9304,6 +9304,31 @@ } ] }, + "CtpServiceDetails": { + "type": "object", + "properties": { + "merchant_transaction_id": { + "type": "string", + "description": "merchant transaction id", + "nullable": true + }, + "correlation_id": { + "type": "string", + "description": "network transaction correlation id", + "nullable": true + }, + "x_src_flow_id": { + "type": "string", + "description": "session transaction flow id", + "nullable": true + }, + "provider": { + "type": "string", + "description": "provider Eg: Visa, Mastercard", + "nullable": true + } + } + }, "Currency": { "type": "string", "description": "The three letter ISO currency code in uppercase. Eg: 'USD' for the United States Dollar.", @@ -17109,6 +17134,14 @@ } ], "nullable": true + }, + "ctp_service_details": { + "allOf": [ + { + "$ref": "#/components/schemas/CtpServiceDetails" + } + ], + "nullable": true } } }, @@ -17487,6 +17520,14 @@ } ], "nullable": true + }, + "ctp_service_details": { + "allOf": [ + { + "$ref": "#/components/schemas/CtpServiceDetails" + } + ], + "nullable": true } } }, @@ -18689,6 +18730,14 @@ } ], "nullable": true + }, + "ctp_service_details": { + "allOf": [ + { + "$ref": "#/components/schemas/CtpServiceDetails" + } + ], + "nullable": true } }, "additionalProperties": false @@ -19730,6 +19779,14 @@ } ], "nullable": true + }, + "ctp_service_details": { + "allOf": [ + { + "$ref": "#/components/schemas/CtpServiceDetails" + } + ], + "nullable": true } } }, diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index cab8071de087..2114bc9f6ca5 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -1013,6 +1013,22 @@ pub struct PaymentsRequest { /// Choose what kind of sca exemption is required for this payment #[schema(value_type = Option)] pub psd2_sca_exemption_type: Option, + + /// Service details for click to pay external authentication + #[schema(value_type = Option)] + pub ctp_service_details: Option, +} + +#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)] +pub struct CtpServiceDetails { + /// merchant transaction id + pub merchant_transaction_id: Option, + /// network transaction correlation id + pub correlation_id: Option, + /// session transaction flow id + pub x_src_flow_id: Option, + /// provider Eg: Visa, Mastercard + pub provider: Option, } #[cfg(feature = "v1")] diff --git a/crates/diesel_models/src/authentication.rs b/crates/diesel_models/src/authentication.rs index 5d0e58c56270..c79892d27bf6 100644 --- a/crates/diesel_models/src/authentication.rs +++ b/crates/diesel_models/src/authentication.rs @@ -47,6 +47,7 @@ pub struct Authentication { pub ds_trans_id: Option, pub directory_server_id: Option, pub acquirer_country_code: Option, + pub service_details: Option, } impl Authentication { @@ -94,6 +95,7 @@ pub struct AuthenticationNew { pub ds_trans_id: Option, pub directory_server_id: Option, pub acquirer_country_code: Option, + pub service_details: Option, } #[derive(Debug)] @@ -190,6 +192,7 @@ pub struct AuthenticationUpdateInternal { pub ds_trans_id: Option, pub directory_server_id: Option, pub acquirer_country_code: Option, + pub service_details: Option, } impl Default for AuthenticationUpdateInternal { @@ -223,6 +226,7 @@ impl Default for AuthenticationUpdateInternal { ds_trans_id: Default::default(), directory_server_id: Default::default(), acquirer_country_code: Default::default(), + service_details: Default::default(), } } } @@ -258,6 +262,7 @@ impl AuthenticationUpdateInternal { ds_trans_id, directory_server_id, acquirer_country_code, + service_details, } = self; Authentication { connector_authentication_id: connector_authentication_id @@ -292,6 +297,7 @@ impl AuthenticationUpdateInternal { ds_trans_id: ds_trans_id.or(source.ds_trans_id), directory_server_id: directory_server_id.or(source.directory_server_id), acquirer_country_code: acquirer_country_code.or(source.acquirer_country_code), + service_details: service_details.or(source.service_details), ..source } } diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs index c30562de9913..82f1ffed1df3 100644 --- a/crates/diesel_models/src/schema.rs +++ b/crates/diesel_models/src/schema.rs @@ -120,6 +120,7 @@ diesel::table! { directory_server_id -> Nullable, #[max_length = 64] acquirer_country_code -> Nullable, + service_details -> Nullable, } } diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs index 12bb19c0a7f1..6c91e258de7b 100644 --- a/crates/diesel_models/src/schema_v2.rs +++ b/crates/diesel_models/src/schema_v2.rs @@ -121,6 +121,7 @@ diesel::table! { directory_server_id -> Nullable, #[max_length = 64] acquirer_country_code -> Nullable, + service_details -> Nullable, } } diff --git a/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs b/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs index cbca353b1009..6dd899cd5b38 100644 --- a/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs +++ b/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs @@ -2,12 +2,12 @@ use masking::Secret; #[derive(Clone, serde::Deserialize, Debug, serde::Serialize)] pub struct UasPreAuthenticationRequestData { - pub service_details: Option, + pub service_details: Option, pub transaction_details: Option, } #[derive(Clone, serde::Deserialize, Debug, serde::Serialize)] -pub struct ServiceDetails { +pub struct CtpServiceDetails { pub service_session_ids: Option, } diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index c7fa29a1b20e..d50bf863b5b8 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -655,6 +655,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::DisplayAmountOnSdk, api_models::payments::PaymentsPostSessionTokensRequest, api_models::payments::PaymentsPostSessionTokensResponse, + api_models::payments::CtpServiceDetails )), modifiers(&SecurityAddon) )] diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs index ba2975349c0f..688d749d5d99 100644 --- a/crates/openapi/src/openapi_v2.rs +++ b/crates/openapi/src/openapi_v2.rs @@ -621,6 +621,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::PaymentsDynamicTaxCalculationResponse, api_models::payments::DisplayAmountOnSdk, api_models::payments::ErrorDetails, + api_models::payments::CtpServiceDetails, common_utils::types::BrowserInformation, api_models::payments::ConfirmIntentAmountDetailsResponse, routes::payments::ForceSync, diff --git a/crates/router/src/core/authentication/utils.rs b/crates/router/src/core/authentication/utils.rs index 01cc6a89562d..21c2ae20e2ca 100644 --- a/crates/router/src/core/authentication/utils.rs +++ b/crates/router/src/core/authentication/utils.rs @@ -219,6 +219,7 @@ pub async fn create_new_authentication( ds_trans_id: None, directory_server_id: None, acquirer_country_code: None, + service_details: None, }; state .store diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index 7912eb090d51..3299bdccac5d 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -4262,6 +4262,7 @@ where pub poll_config: Option, pub tax_data: Option, pub session_id: Option, + pub service_details: Option, } #[derive(Clone, serde::Serialize, Debug)] diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rs index b3d2985bf803..a5993eb2f012 100644 --- a/crates/router/src/core/payments/operations/payment_approve.rs +++ b/crates/router/src/core/payments/operations/payment_approve.rs @@ -194,6 +194,7 @@ impl GetTracker, api::PaymentsCaptureR poll_config: None, tax_data: None, session_id: None, + service_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rs index a40ecf0242e7..427c10aab629 100644 --- a/crates/router/src/core/payments/operations/payment_cancel.rs +++ b/crates/router/src/core/payments/operations/payment_cancel.rs @@ -205,6 +205,7 @@ impl GetTracker, api::PaymentsCancelRe poll_config: None, tax_data: None, session_id: None, + service_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_capture.rs b/crates/router/src/core/payments/operations/payment_capture.rs index d9068b402ce8..f8d304bcb79c 100644 --- a/crates/router/src/core/payments/operations/payment_capture.rs +++ b/crates/router/src/core/payments/operations/payment_capture.rs @@ -254,6 +254,7 @@ impl GetTracker, api::Paymen poll_config: None, tax_data: None, session_id: None, + service_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs index f4f5813c1b04..09e806755ff0 100644 --- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs +++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs @@ -348,6 +348,7 @@ impl GetTracker, api::PaymentsRequest> poll_config: None, tax_data: None, session_id: None, + service_details: None, }; let customer_details = Some(CustomerDetails { diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs index c3fe518ff5eb..58217ef3f41a 100644 --- a/crates/router/src/core/payments/operations/payment_confirm.rs +++ b/crates/router/src/core/payments/operations/payment_confirm.rs @@ -818,6 +818,7 @@ impl GetTracker, api::PaymentsRequest> poll_config: None, tax_data: None, session_id: None, + service_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs index 6b9a4a76711e..9dd3cdaaa71c 100644 --- a/crates/router/src/core/payments/operations/payment_create.rs +++ b/crates/router/src/core/payments/operations/payment_create.rs @@ -613,6 +613,7 @@ impl GetTracker, api::PaymentsRequest> poll_config: None, tax_data: None, session_id: None, + service_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs index 7c30d9c5b759..7337f0808847 100644 --- a/crates/router/src/core/payments/operations/payment_post_session_tokens.rs +++ b/crates/router/src/core/payments/operations/payment_post_session_tokens.rs @@ -165,6 +165,7 @@ impl GetTracker, api::PaymentsPostSess poll_config: None, tax_data: None, session_id: None, + service_details: None, }; let get_trackers_response = operations::GetTrackerResponse { operation: Box::new(self), diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rs index df9544dfb486..a6a10be8e9ab 100644 --- a/crates/router/src/core/payments/operations/payment_reject.rs +++ b/crates/router/src/core/payments/operations/payment_reject.rs @@ -192,6 +192,7 @@ impl GetTracker, PaymentsCancelRequest poll_config: None, tax_data: None, session_id: None, + service_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rs index a9a64c688094..f93327b275cf 100644 --- a/crates/router/src/core/payments/operations/payment_session.rs +++ b/crates/router/src/core/payments/operations/payment_session.rs @@ -212,6 +212,7 @@ impl GetTracker, api::PaymentsSessionR poll_config: None, tax_data: None, session_id: None, + service_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rs index 3285914affae..a895855cefc8 100644 --- a/crates/router/src/core/payments/operations/payment_start.rs +++ b/crates/router/src/core/payments/operations/payment_start.rs @@ -199,6 +199,7 @@ impl GetTracker, api::PaymentsStartReq poll_config: None, tax_data: None, session_id: None, + service_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rs index e2c9a4d7a3ba..69f2d85d6a91 100644 --- a/crates/router/src/core/payments/operations/payment_status.rs +++ b/crates/router/src/core/payments/operations/payment_status.rs @@ -508,6 +508,7 @@ async fn get_tracker_for_sync< poll_config: None, tax_data: None, session_id: None, + service_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs index 1fba79968b68..ed8b6391da63 100644 --- a/crates/router/src/core/payments/operations/payment_update.rs +++ b/crates/router/src/core/payments/operations/payment_update.rs @@ -490,6 +490,7 @@ impl GetTracker, api::PaymentsRequest> poll_config: None, tax_data: None, session_id: None, + service_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs index a629938936b6..035c4e8e2ecf 100644 --- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs +++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs @@ -171,6 +171,7 @@ impl poll_config: None, tax_data: None, session_id: None, + service_details: None, }; let get_trackers_response = operations::GetTrackerResponse { diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rs index dbfed35a44fa..859422920e16 100644 --- a/crates/router/src/core/payments/operations/tax_calculation.rs +++ b/crates/router/src/core/payments/operations/tax_calculation.rs @@ -179,6 +179,7 @@ impl poll_config: None, tax_data: Some(tax_data), session_id: request.session_id.clone(), + service_details: None, }; let get_trackers_response = operations::GetTrackerResponse { operation: Box::new(self), diff --git a/crates/router/src/core/unified_authentication_service.rs b/crates/router/src/core/unified_authentication_service.rs index bd08ea7fe6b7..63375419cf75 100644 --- a/crates/router/src/core/unified_authentication_service.rs +++ b/crates/router/src/core/unified_authentication_service.rs @@ -173,6 +173,7 @@ pub async fn create_new_authentication( ds_trans_id: None, directory_server_id: None, acquirer_country_code: None, + service_details: None, }; state .store diff --git a/crates/router/src/core/unified_authentication_service/transformers.rs b/crates/router/src/core/unified_authentication_service/transformers.rs index cf3cb6f1f631..0dd59fc81c76 100644 --- a/crates/router/src/core/unified_authentication_service/transformers.rs +++ b/crates/router/src/core/unified_authentication_service/transformers.rs @@ -2,7 +2,7 @@ use error_stack::Report; use hyperswitch_domain_models::{ errors::api_error_response::ApiErrorResponse, router_request_types::unified_authentication_service::{ - ServiceDetails, ServiceSessionIds, TransactionDetails, UasPreAuthenticationRequestData, + CtpServiceDetails, ServiceSessionIds, TransactionDetails, UasPreAuthenticationRequestData, }, }; @@ -12,7 +12,7 @@ use crate::core::payments::PaymentData; impl TryFrom> for UasPreAuthenticationRequestData { type Error = Report; fn try_from(payment_data: PaymentData) -> Result { - let service_details = ServiceDetails { + let service_details = CtpServiceDetails { service_session_ids: Some(ServiceSessionIds { merchant_transaction_id: None, correlation_id: None, diff --git a/crates/router/src/db/authentication.rs b/crates/router/src/db/authentication.rs index 1307c53338de..af3da68e6ae5 100644 --- a/crates/router/src/db/authentication.rs +++ b/crates/router/src/db/authentication.rs @@ -150,6 +150,7 @@ impl AuthenticationInterface for MockDb { ds_trans_id: authentication.ds_trans_id, directory_server_id: authentication.directory_server_id, acquirer_country_code: authentication.acquirer_country_code, + service_details: authentication.service_details, }; authentications.push(authentication.clone()); Ok(authentication) diff --git a/migrations/2024-12-05-115544_add-service-details/down.sql b/migrations/2024-12-05-115544_add-service-details/down.sql new file mode 100644 index 000000000000..1c42146adfc1 --- /dev/null +++ b/migrations/2024-12-05-115544_add-service-details/down.sql @@ -0,0 +1,2 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE authentication DROP COLUMN IF EXISTS service_details; \ No newline at end of file diff --git a/migrations/2024-12-05-115544_add-service-details/up.sql b/migrations/2024-12-05-115544_add-service-details/up.sql new file mode 100644 index 000000000000..3555647a987e --- /dev/null +++ b/migrations/2024-12-05-115544_add-service-details/up.sql @@ -0,0 +1,4 @@ +-- Your SQL goes here +ALTER TABLE authentication +ADD COLUMN IF NOT EXISTS service_details JSONB +DEFAULT NULL; \ No newline at end of file