Skip to content

Commit

Permalink
feat(core): added new column to authentication table to store service…
Browse files Browse the repository at this point in the history
… details
  • Loading branch information
sahkal committed Dec 5, 2024
1 parent 60ec5e0 commit 7c6a74b
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 16 deletions.
10 changes: 10 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,16 @@ 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 external authentication
pub service_details: Option<ServiceDetails>,
}

#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct ServiceDetails {
pub merchant_transaction_id: Option<String>,
pub correlation_id: Option<String>,
pub x_src_flow_id: 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 @@ -186,6 +188,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 @@ -219,6 +222,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 @@ -254,6 +258,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 @@ -288,6 +293,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
33 changes: 17 additions & 16 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 Expand Up @@ -204,12 +205,6 @@ diesel::table! {
#[max_length = 64]
tax_connector_id -> Nullable<Varchar>,
is_tax_connector_enabled -> Nullable<Bool>,
version -> ApiVersion,
dynamic_routing_algorithm -> Nullable<Json>,
is_network_tokenization_enabled -> Bool,
is_auto_retries_enabled -> Nullable<Bool>,
max_auto_retries_enabled -> Nullable<Int2>,
is_click_to_pay_enabled -> Bool,
#[max_length = 64]
routing_algorithm_id -> Nullable<Varchar>,
order_fulfillment_time -> Nullable<Int8>,
Expand All @@ -222,6 +217,12 @@ diesel::table! {
should_collect_cvv_during_payment -> Bool,
#[max_length = 64]
id -> Varchar,
version -> ApiVersion,
dynamic_routing_algorithm -> Nullable<Json>,
is_network_tokenization_enabled -> Bool,
is_auto_retries_enabled -> Nullable<Bool>,
max_auto_retries_enabled -> Nullable<Int2>,
is_click_to_pay_enabled -> Bool,
}
}

Expand Down Expand Up @@ -806,9 +807,6 @@ diesel::table! {
organization_id -> Varchar,
#[max_length = 32]
card_network -> Nullable<Varchar>,
shipping_cost -> Nullable<Int8>,
order_tax_amount -> Nullable<Int8>,
connector_mandate_detail -> Nullable<Jsonb>,
payment_method_type_v2 -> Varchar,
#[max_length = 128]
connector_payment_id -> Nullable<Varchar>,
Expand All @@ -825,6 +823,9 @@ diesel::table! {
connector_payment_data -> Nullable<Varchar>,
#[max_length = 64]
id -> Varchar,
shipping_cost -> Nullable<Int8>,
order_tax_amount -> Nullable<Int8>,
connector_mandate_detail -> Nullable<Jsonb>,
}
}

Expand Down Expand Up @@ -877,7 +878,6 @@ diesel::table! {
organization_id -> Varchar,
tax_details -> Nullable<Jsonb>,
skip_external_tax_calculation -> Nullable<Bool>,
psd2_sca_exemption_type -> Nullable<ScaExemptionType>,
#[max_length = 64]
merchant_reference_id -> Nullable<Varchar>,
billing_address -> Nullable<Bytea>,
Expand All @@ -899,6 +899,7 @@ diesel::table! {
payment_link_config -> Nullable<Jsonb>,
#[max_length = 64]
id -> Varchar,
psd2_sca_exemption_type -> Nullable<ScaExemptionType>,
}
}

Expand Down Expand Up @@ -958,12 +959,6 @@ diesel::table! {
payment_method_billing_address -> Nullable<Bytea>,
#[max_length = 64]
updated_by -> Nullable<Varchar>,
version -> ApiVersion,
#[max_length = 128]
network_token_requestor_reference_id -> Nullable<Varchar>,
#[max_length = 64]
network_token_locker_id -> Nullable<Varchar>,
network_token_payment_method_data -> Nullable<Bytea>,
#[max_length = 64]
locker_fingerprint_id -> Nullable<Varchar>,
#[max_length = 64]
Expand All @@ -972,6 +967,12 @@ diesel::table! {
payment_method_subtype -> Nullable<Varchar>,
#[max_length = 64]
id -> Varchar,
version -> ApiVersion,
#[max_length = 128]
network_token_requestor_reference_id -> Nullable<Varchar>,
#[max_length = 64]
network_token_locker_id -> Nullable<Varchar>,
network_token_payment_method_data -> Nullable<Bytea>,
}
}

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 @@ -4249,6 +4249,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::ServiceDetails>,
}

#[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> GetTracker<F, PaymentData<F>, api::PaymentsCaptureRequest>
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 @@ -203,6 +203,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::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 @@ -254,6 +254,7 @@ impl<F: Send + Clone> GetTracker<F, payments::PaymentData<F>, api::PaymentsCaptu
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 @@ -346,6 +346,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Co
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 @@ -810,6 +810,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
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 @@ -612,6 +612,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
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> GetTracker<F, PaymentData<F>, api::PaymentsPostSessionToke
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 @@ -190,6 +190,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, PaymentsCancelRequest> for P
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> GetTracker<F, PaymentData<F>, api::PaymentsSessionRequest>
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 @@ -197,6 +197,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsStartRequest> f
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 @@ -506,6 +506,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> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
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>
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 @@ -178,6 +178,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsDynamicTaxCalcu
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/db/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions migrations/2024-12-05-115544_add-service-details/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
ALTER TABLE authentication DROP COLUMN IF EXISTS service_details;
4 changes: 4 additions & 0 deletions migrations/2024-12-05-115544_add-service-details/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Your SQL goes here
ALTER TABLE authentication
ADD COLUMN IF NOT EXISTS service_details JSONB
DEFAULT NULL;

0 comments on commit 7c6a74b

Please sign in to comment.