Skip to content

Commit

Permalink
feat(core): Add service details field in authentication table (#6757)
Browse files Browse the repository at this point in the history
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
sahkal and hyperswitch-bot[bot] authored Dec 12, 2024
1 parent 573fc2c commit e9a5615
Show file tree
Hide file tree
Showing 30 changed files with 136 additions and 4 deletions.
25 changes: 25 additions & 0 deletions api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
57 changes: 57 additions & 0 deletions api-reference/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -17109,6 +17134,14 @@
}
],
"nullable": true
},
"ctp_service_details": {
"allOf": [
{
"$ref": "#/components/schemas/CtpServiceDetails"
}
],
"nullable": true
}
}
},
Expand Down Expand Up @@ -17487,6 +17520,14 @@
}
],
"nullable": true
},
"ctp_service_details": {
"allOf": [
{
"$ref": "#/components/schemas/CtpServiceDetails"
}
],
"nullable": true
}
}
},
Expand Down Expand Up @@ -18689,6 +18730,14 @@
}
],
"nullable": true
},
"ctp_service_details": {
"allOf": [
{
"$ref": "#/components/schemas/CtpServiceDetails"
}
],
"nullable": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -19730,6 +19779,14 @@
}
],
"nullable": true
},
"ctp_service_details": {
"allOf": [
{
"$ref": "#/components/schemas/CtpServiceDetails"
}
],
"nullable": true
}
}
},
Expand Down
16 changes: 16 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
6 changes: 6 additions & 0 deletions crates/diesel_models/src/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(),
}
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ diesel::table! {
directory_server_id -> Nullable<Varchar>,
#[max_length = 64]
acquirer_country_code -> Nullable<Varchar>,
service_details -> Nullable<Jsonb>,
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/diesel_models/src/schema_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ diesel::table! {
directory_server_id -> Nullable<Varchar>,
#[max_length = 64]
acquirer_country_code -> Nullable<Varchar>,
service_details -> Nullable<Jsonb>,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
}

Expand Down
1 change: 1 addition & 0 deletions crates/openapi/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)]
Expand Down
1 change: 1 addition & 0 deletions crates/openapi/src/openapi_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/authentication/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4262,6 +4262,7 @@ where
pub 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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCaptureR
poll_config: None,
tax_data: None,
session_id: None,
service_details: None,
};

let get_trackers_response = operations::GetTrackerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsCancelRe
poll_config: None,
tax_data: None,
session_id: None,
service_details: None,
};

let get_trackers_response = operations::GetTrackerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, payments::PaymentData<F>, api::Paymen
poll_config: None,
tax_data: None,
session_id: None,
service_details: None,
};

let get_trackers_response = operations::GetTrackerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsPostSess
poll_config: None,
tax_data: None,
session_id: None,
service_details: None,
};
let get_trackers_response = operations::GetTrackerResponse {
operation: Box::new(self),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, PaymentsCancelRequest
poll_config: None,
tax_data: None,
session_id: None,
service_details: None,
};

let get_trackers_response = operations::GetTrackerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsSessionR
poll_config: None,
tax_data: None,
session_id: None,
service_details: None,
};

let get_trackers_response = operations::GetTrackerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsStartReq
poll_config: None,
tax_data: None,
session_id: None,
service_details: None,
};

let get_trackers_response = operations::GetTrackerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/unified_authentication_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};

Expand All @@ -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,
Expand Down
Loading

0 comments on commit e9a5615

Please sign in to comment.