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
refactor(core): move db defaults to app side for dispute and gateway_status_map (#12485)
Shivansh Mathur784c00bd12bb
diff --git a/crates/diesel_models/src/authorization.rs b/crates/diesel_models/src/authorization.rsindex f8f95a046b..23701f5543 100644--- a/crates/diesel_models/src/authorization.rs+++ b/crates/diesel_models/src/authorization.rs@@ -39,6 +39,8 @@ pub struct AuthorizationNew {pub connector_authorization_id: Option<String>,pub previously_authorized_amount: MinorUnit,pub processor_merchant_id: Option<common_utils::id_type::MerchantId>,+ pub created_at: PrimitiveDateTime,+ pub modified_at: PrimitiveDateTime,}#[derive(Debug, Clone, Serialize, Deserialize)]diff --git a/crates/diesel_models/src/dispute.rs b/crates/diesel_models/src/dispute.rsindex 1b2061d648..d273c96217 100644--- a/crates/diesel_models/src/dispute.rs+++ b/crates/diesel_models/src/dispute.rs@@ -29,7 +29,7 @@ pub struct DisputeNew {pub connector_created_at: Option<PrimitiveDateTime>,pub connector_updated_at: Option<PrimitiveDateTime>,pub connector: String,- pub evidence: Option<Secret<serde_json::Value>>,+ pub evidence: Secret<serde_json::Value>,pub profile_id: Option<common_utils::id_type::ProfileId>,pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,pub dispute_amount: MinorUnit,@@ -37,6 +37,8 @@ pub struct DisputeNew {pub dispute_currency: Option<storage_enums::Currency>,pub processor_merchant_id: Option<common_utils::id_type::MerchantId>,pub created_by: Option<String>,+ pub created_at: PrimitiveDateTime,+ pub modified_at: PrimitiveDateTime,}#[derive(Clone, Debug, PartialEq, Serialize, Identifiable, Queryable, Selectable)]diff --git a/crates/diesel_models/src/gsm.rs b/crates/diesel_models/src/gsm.rsindex 191ff55fea..3a6a3bf783 100644--- a/crates/diesel_models/src/gsm.rs+++ b/crates/diesel_models/src/gsm.rs@@ -67,6 +67,8 @@ pub struct GatewayStatusMappingNew {pub standardised_code: Option<common_enums::StandardisedCode>,pub description: Option<String>,pub user_guidance_message: Option<String>,+ pub created_at: PrimitiveDateTime,+ pub last_modified: PrimitiveDateTime,}#[derive(diff --git a/crates/diesel_models/src/merchant_account.rs b/crates/diesel_models/src/merchant_account.rsindex ca954917e3..39f8530e79 100644--- a/crates/diesel_models/src/merchant_account.rs+++ b/crates/diesel_models/src/merchant_account.rs@@ -237,6 +237,7 @@ pub struct MerchantAccountNew {pub payment_response_hash_key: Option<String>,pub redirect_to_merchant_with_http_post: Option<bool>,pub publishable_key: Option<String>,+ pub storage_scheme: storage_enums::MerchantStorageScheme,pub locker_id: Option<String>,pub metadata: Option<pii::SecretSerdeValue>,pub routing_algorithm: Option<serde_json::Value>,@@ -267,6 +268,7 @@ pub struct MerchantAccountNew {pub merchant_name: Option<Encryption>,pub merchant_details: Option<Encryption>,pub publishable_key: Option<String>,+ pub storage_scheme: storage_enums::MerchantStorageScheme,pub metadata: Option<pii::SecretSerdeValue>,pub created_at: time::PrimitiveDateTime,pub modified_at: time::PrimitiveDateTime,diff --git a/crates/hyperswitch_domain_models/src/gsm.rs b/crates/hyperswitch_domain_models/src/gsm.rsindex 60de89bd3c..0885dd2326 100644--- a/crates/hyperswitch_domain_models/src/gsm.rs+++ b/crates/hyperswitch_domain_models/src/gsm.rs@@ -68,6 +68,8 @@ impl TryFrom<GatewayStatusMap> for diesel_models::gsm::GatewayStatusMappingNew {standardised_code: value.standardised_code,description: value.description,user_guidance_message: value.user_guidance_message,+ created_at: common_utils::date_time::now(),+ last_modified: common_utils::date_time::now(),})}}diff --git a/crates/hyperswitch_domain_models/src/merchant_account.rs b/crates/hyperswitch_domain_models/src/merchant_account.rsindex d377dde8ef..895e9d61f6 100644--- a/crates/hyperswitch_domain_models/src/merchant_account.rs+++ b/crates/hyperswitch_domain_models/src/merchant_account.rs@@ -663,6 +663,7 @@ impl Conversion for MerchantAccount {merchant_name: self.merchant_name.map(Encryption::from),merchant_details: self.merchant_details.map(Encryption::from),publishable_key: Some(self.publishable_key),+ storage_scheme: self.storage_scheme,metadata: self.metadata,created_at: now,modified_at: now,@@ -836,6 +837,7 @@ impl Conversion for MerchantAccount {payment_response_hash_key: self.payment_response_hash_key,redirect_to_merchant_with_http_post: Some(self.redirect_to_merchant_with_http_post),publishable_key: Some(self.publishable_key),+ storage_scheme: self.storage_scheme,locker_id: self.locker_id,metadata: self.metadata,routing_algorithm: self.routing_algorithm,diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rsindex 230d3ae2f3..b98d42cbb8 100644--- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs+++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs@@ -253,6 +253,8 @@ impl<F: Clone + Sync>connector_authorization_id: None,previously_authorized_amount: payment_data.payment_attempt.get_total_amount(),processor_merchant_id: Some(payment_data.payment_intent.processor_merchant_id.clone()),+ created_at: common_utils::date_time::now(),+ modified_at: common_utils::date_time::now(),};let authorization = state.storediff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rsindex 14063161ad..f1f1bee1a3 100644--- a/crates/router/src/core/webhooks/incoming.rs+++ b/crates/router/src/core/webhooks/incoming.rs@@ -1783,7 +1783,7 @@ pub async fn get_or_update_dispute_object(connector_created_at: dispute_details.created_at,connector_updated_at: dispute_details.updated_at,profile_id: Some(business_profile.get_id().to_owned()),- evidence: None,+ evidence: hyperswitch_masking::Secret::new(serde_json::json!({})),merchant_connector_id: payment_attempt.merchant_connector_id.clone(),dispute_amount: StringMinorUnitForConnector::convert_back(&StringMinorUnitForConnector,@@ -1808,6 +1808,8 @@ pub async fn get_or_update_dispute_object(.created_by.as_ref().map(|created_by| created_by.to_string()),+ created_at: common_utils::date_time::now(),+ modified_at: common_utils::date_time::now(),};state.storediff --git a/crates/router/src/db/dispute.rs b/crates/router/src/db/dispute.rsindex 628e522b40..eb1bdbd702 100644--- a/crates/router/src/db/dispute.rs+++ b/crates/router/src/db/dispute.rs@@ -206,8 +206,6 @@ impl DisputeInterface for MockDb {&self,dispute: storage::DisputeNew,) -> CustomResult<storage::Dispute, errors::StorageError> {- let evidence = dispute.evidence.ok_or(errors::StorageError::MockDbError)?;-let mut locked_disputes = self.disputes.lock().await;if locked_disputes@@ -217,8 +215,6 @@ impl DisputeInterface for MockDb {Err(errors::StorageError::MockDbError)?;}- let now = common_utils::date_time::now();-let new_dispute = storage::Dispute {dispute_id: dispute.dispute_id,amount: dispute.amount,@@ -235,11 +231,11 @@ impl DisputeInterface for MockDb {challenge_required_by: dispute.challenge_required_by,connector_created_at: dispute.connector_created_at,connector_updated_at: dispute.connector_updated_at,- created_at: now,- modified_at: now,+ created_at: dispute.created_at,+ modified_at: dispute.modified_at,connector: dispute.connector,profile_id: dispute.profile_id,- evidence,+ evidence: dispute.evidence,merchant_connector_id: dispute.merchant_connector_id,dispute_amount: dispute.dispute_amount,organization_id: dispute.organization_id,@@ -561,7 +557,7 @@ mod tests {connector_created_at: Some(datetime!(2019-01-02 0:00)),connector_updated_at: Some(datetime!(2019-01-03 0:00)),connector: "connector".into(),- evidence: Some(Secret::from(Value::String("evidence".into()))),+ evidence: Secret::from(Value::String("evidence".into())),profile_id: Some(common_utils::generate_profile_id_of_default_length()),merchant_connector_id: None,dispute_amount: MinorUnit::new(1040),@@ -569,6 +565,8 @@ mod tests {dispute_currency: Some(Currency::default()),processor_merchant_id: Some(dispute_ids.merchant_id),created_by: None,+ created_at: common_utils::date_time::now(),+ modified_at: common_utils::date_time::now(),}}diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rsindex e4595120a5..759cd9d6c6 100644--- a/crates/router/src/utils/user/sample_data.rs+++ b/crates/router/src/utils/user/sample_data.rs@@ -483,7 +483,7 @@ pub async fn generate_sample_data(.connector.clone().unwrap_or(DummyConnector4.to_string()),- evidence: None,+ evidence: hyperswitch_masking::Secret::new(serde_json::json!({})),profile_id: payment_intent.profile_id.clone(),merchant_connector_id: payment_attempt.merchant_connector_id.clone(),dispute_amount: MinorUnit::new(amount * 100),@@ -491,6 +491,8 @@ pub async fn generate_sample_data(dispute_currency: Some(payment_intent.currency.unwrap_or_default()),processor_merchant_id: None,created_by: None,+ created_at: common_utils::date_time::now(),+ modified_at: common_utils::date_time::now(),})} else {None