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(core): Add service details field in authentication table (#6757)
Sahkal Poddare9a5615f2ba1
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.jsonindex 2cd5467f06..2ea0f42a7f 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.jsonindex 937dc7ab2d..832f8da9c4 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.rsindex cab8071de0..2114bc9f6c 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<ScaExemptionType>)]pub psd2_sca_exemption_type: Option<api_enums::ScaExemptionType>,++ /// Service details for click to pay external authentication+ #[schema(value_type = Option<CtpServiceDetails>)]+ pub ctp_service_details: Option<CtpServiceDetails>,+}++#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]+pub struct CtpServiceDetails {+ /// merchant transaction id+ pub merchant_transaction_id: Option<String>,+ /// network transaction correlation id+ pub correlation_id: Option<String>,+ /// session transaction flow id+ pub x_src_flow_id: Option<String>,+ /// provider Eg: Visa, Mastercard+ pub provider: Option<String>,}#[cfg(feature = "v1")]diff --git a/crates/diesel_models/src/authentication.rs b/crates/diesel_models/src/authentication.rsindex 5d0e58c562..c79892d27b 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<String>,pub directory_server_id: Option<String>,pub acquirer_country_code: Option<String>,+ pub service_details: Option<serde_json::Value>,}impl Authentication {@@ -94,6 +95,7 @@ pub struct AuthenticationNew {pub ds_trans_id: Option<String>,pub directory_server_id: Option<String>,pub acquirer_country_code: Option<String>,+ pub service_details: Option<serde_json::Value>,}#[derive(Debug)]@@ -190,6 +192,7 @@ pub struct AuthenticationUpdateInternal {pub ds_trans_id: Option<String>,pub directory_server_id: Option<String>,pub acquirer_country_code: Option<String>,+ pub service_details: Option<serde_json::Value>,}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.rsindex c30562de99..82f1ffed1d 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<Varchar>,#[max_length = 64]acquirer_country_code -> Nullable<Varchar>,+ service_details -> Nullable<Jsonb>,}}diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rsindex 12bb19c0a7..6c91e258de 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<Varchar>,#[max_length = 64]acquirer_country_code -> Nullable<Varchar>,+ service_details -> Nullable<Jsonb>,}}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.rsindex cbca353b10..6dd899cd5b 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<ServiceDetails>,+ pub service_details: Option<CtpServiceDetails>,pub transaction_details: Option<TransactionDetails>,}#[derive(Clone, serde::Deserialize, Debug, serde::Serialize)]-pub struct ServiceDetails {+pub struct CtpServiceDetails {pub service_session_ids: Option<ServiceSessionIds>,}diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex c7fa29a1b2..d50bf863b5 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.rsindex ba2975349c..688d749d5d 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.rsindex 01cc6a8956..21c2ae20e2 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.storediff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 7912eb090d..3299bdccac 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -4262,6 +4262,7 @@ wherepub poll_config: Option<router_types::PollConfig>,pub tax_data: Option<TaxData>,pub session_id: Option<String>,+ pub service_details: Option<api_models::payments::CtpServiceDetails>,}#[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.rsindex b3d2985bf8..a5993eb2f0 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<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCaptureRpoll_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.rsindex a40ecf0242..427c10aab6 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<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRepoll_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.rsindex d9068b402c..f8d304bcb7 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<F: Send + Clone + Sync> GetTracker<F, payments::PaymentData<F>, api::Paymenpoll_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.rsindex f4f5813c1b..09e806755f 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<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, 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.rsindex c3fe518ff5..58217ef3f4 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<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, 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.rsindex 6b9a4a7671..9dd3cdaaa7 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<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, 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.rsindex 7c30d9c5b7..7337f08088 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<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsPostSesspoll_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.rsindex df9544dfb4..a6a10be8e9 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<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, PaymentsCancelRequestpoll_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.rsindex a9a64c6880..f93327b275 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<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsSessionRpoll_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.rsindex 3285914aff..a895855cef 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<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsStartReqpoll_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.rsindex e2c9a4d7a3..69f2d85d6a 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.rsindex 1fba79968b..ed8b6391da 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<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, 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.rsindex a629938936..035c4e8e2e 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<F: Send + Clone + 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/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rsindex dbfed35a44..859422920e 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<F: Send + Clone + Sync>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.rsindex bd08ea7fe6..63375419cf 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.storediff --git a/crates/router/src/core/unified_authentication_service/transformers.rs b/crates/router/src/core/unified_authentication_service/transformers.rsindex cf3cb6f1f6..0dd59fc81c 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<F: Clone + Sync> TryFrom<PaymentData<F>> for UasPreAuthenticationRequestData {type Error = Report<ApiErrorResponse>;fn try_from(payment_data: PaymentData<F>) -> Result<Self, Self::Error> {- 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.rsindex 1307c53338..af3da68e6a 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.sqlnew file mode 100644index 0000000000..1c42146adf--- /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 filediff --git a/migrations/2024-12-05-115544_add-service-details/up.sql b/migrations/2024-12-05-115544_add-service-details/up.sqlnew file mode 100644index 0000000000..3555647a98--- /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