Skip to content

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

feat(merchant_account): add `is_recon_enabled` field in merchant_account (#1713)

anji-reddy-j7549cd3aa62f
diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs
index 9868d963fe..7a6e984776 100644
--- a/crates/api_models/src/admin.rs
+++ b/crates/api_models/src/admin.rs
@@ -227,6 +227,9 @@ pub struct MerchantAccountResponse {
/// The organization id merchant is associated with
pub organization_id: Option<String>,
+
+ /// A boolean value to indicate if the merchant has recon service is enabled or not, by default value is false
+ pub is_recon_enabled: bool,
}
#[derive(Clone, Debug, Deserialize, ToSchema, Serialize)]
diff --git a/crates/diesel_models/src/merchant_account.rs b/crates/diesel_models/src/merchant_account.rs
index e295ccd898..4d6e90757b 100644
--- a/crates/diesel_models/src/merchant_account.rs
+++ b/crates/diesel_models/src/merchant_account.rs
@@ -36,6 +36,7 @@ pub struct MerchantAccount {
pub modified_at: time::PrimitiveDateTime,
pub frm_routing_algorithm: Option<serde_json::Value>,
pub organization_id: Option<String>,
+ pub is_recon_enabled: bool,
}
#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
@@ -61,6 +62,7 @@ pub struct MerchantAccountNew {
pub modified_at: time::PrimitiveDateTime,
pub frm_routing_algorithm: Option<serde_json::Value>,
pub organization_id: Option<String>,
+ pub is_recon_enabled: bool,
}
#[derive(Clone, Debug, Default, AsChangeset, router_derive::DebugAsDisplay)]
@@ -85,4 +87,5 @@ pub struct MerchantAccountUpdateInternal {
pub intent_fulfillment_time: Option<i64>,
pub frm_routing_algorithm: Option<serde_json::Value>,
pub organization_id: Option<String>,
+ pub is_recon_enabled: bool,
}
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index 447b67c523..cd74ed2152 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -330,6 +330,7 @@ diesel::table! {
frm_routing_algorithm -> Nullable<Jsonb>,
#[max_length = 32]
organization_id -> Nullable<Varchar>,
+ is_recon_enabled -> Bool,
}
}
diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs
index 9f1f8d6f55..84b1b40b68 100644
--- a/crates/router/src/configs/defaults.rs
+++ b/crates/router/src/configs/defaults.rs
@@ -41,11 +41,15 @@ impl Default for super::settings::Secrets {
jwt_secret: "secret".into(),
#[cfg(not(feature = "kms"))]
admin_api_key: "test_admin".into(),
+ #[cfg(not(feature = "kms"))]
+ recon_admin_api_key: "recon_test_admin".into(),
master_enc_key: "".into(),
#[cfg(feature = "kms")]
kms_encrypted_jwt_secret: "".into(),
#[cfg(feature = "kms")]
kms_encrypted_admin_api_key: "".into(),
+ #[cfg(feature = "kms")]
+ kms_encrypted_recon_admin_api_key: "".into(),
}
}
}
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index 34a9ca66f2..618f49ef21 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -317,11 +317,15 @@ pub struct Secrets {
pub jwt_secret: String,
#[cfg(not(feature = "kms"))]
pub admin_api_key: String,
+ #[cfg(not(feature = "kms"))]
+ pub recon_admin_api_key: String,
pub master_enc_key: String,
#[cfg(feature = "kms")]
pub kms_encrypted_jwt_secret: String,
#[cfg(feature = "kms")]
pub kms_encrypted_admin_api_key: String,
+ #[cfg(feature = "kms")]
+ pub kms_encrypted_recon_admin_api_key: String,
}
#[derive(Debug, Deserialize, Clone)]
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index 8e8af3aa3b..1a21b95a5d 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -173,6 +173,7 @@ pub async fn create_merchant_account(
intent_fulfillment_time: req.intent_fulfillment_time.map(i64::from),
id: None,
organization_id: req.organization_id,
+ is_recon_enabled: false,
})
}
.await
diff --git a/crates/router/src/types/api/admin.rs b/crates/router/src/types/api/admin.rs
index b3fcc07b8f..4cc0b27736 100644
--- a/crates/router/src/types/api/admin.rs
+++ b/crates/router/src/types/api/admin.rs
@@ -35,6 +35,7 @@ impl TryFrom<domain::MerchantAccount> for MerchantAccountResponse {
frm_routing_algorithm: item.frm_routing_algorithm,
intent_fulfillment_time: item.intent_fulfillment_time,
organization_id: item.organization_id,
+ is_recon_enabled: item.is_recon_enabled,
})
}
}
diff --git a/crates/router/src/types/domain/merchant_account.rs b/crates/router/src/types/domain/merchant_account.rs
index 301a34276d..a51a0a7c4a 100644
--- a/crates/router/src/types/domain/merchant_account.rs
+++ b/crates/router/src/types/domain/merchant_account.rs
@@ -37,6 +37,7 @@ pub struct MerchantAccount {
pub modified_at: time::PrimitiveDateTime,
pub intent_fulfillment_time: Option<i64>,
pub organization_id: Option<String>,
+ pub is_recon_enabled: bool,
}
#[allow(clippy::large_enum_variant)]
@@ -63,6 +64,9 @@ pub enum MerchantAccountUpdate {
StorageSchemeUpdate {
storage_scheme: enums::MerchantStorageScheme,
},
+ ReconUpdate {
+ is_recon_enabled: bool,
+ },
}
impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
@@ -110,6 +114,10 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
modified_at: Some(date_time::now()),
..Default::default()
},
+ MerchantAccountUpdate::ReconUpdate { is_recon_enabled } => Self {
+ is_recon_enabled,
+ ..Default::default()
+ },
}
}
}
@@ -144,6 +152,7 @@ impl super::behaviour::Conversion for MerchantAccount {
intent_fulfillment_time: self.intent_fulfillment_time,
frm_routing_algorithm: self.frm_routing_algorithm,
organization_id: self.organization_id,
+ is_recon_enabled: self.is_recon_enabled,
})
}
@@ -184,6 +193,7 @@ impl super::behaviour::Conversion for MerchantAccount {
modified_at: item.modified_at,
intent_fulfillment_time: item.intent_fulfillment_time,
organization_id: item.organization_id,
+ is_recon_enabled: item.is_recon_enabled,
})
}
.await
@@ -215,6 +225,7 @@ impl super::behaviour::Conversion for MerchantAccount {
intent_fulfillment_time: self.intent_fulfillment_time,
frm_routing_algorithm: self.frm_routing_algorithm,
organization_id: self.organization_id,
+ is_recon_enabled: self.is_recon_enabled,
})
}
}
diff --git a/migrations/2023-07-11-140347_add_is_recon_enabled_field_in_merchant_account/down.sql b/migrations/2023-07-11-140347_add_is_recon_enabled_field_in_merchant_account/down.sql
new file mode 100644
index 0000000000..5b19ee9a3e
--- /dev/null
+++ b/migrations/2023-07-11-140347_add_is_recon_enabled_field_in_merchant_account/down.sql
@@ -0,0 +1,2 @@
+-- This file should undo anything in `up.sql`
+ALTER TABLE merchant_account DROP COLUMN is_recon_enabled;
\ No newline at end of file
diff --git a/migrations/2023-07-11-140347_add_is_recon_enabled_field_in_merchant_account/up.sql b/migrations/2023-07-11-140347_add_is_recon_enabled_field_in_merchant_account/up.sql
new file mode 100644
index 0000000000..a92074c031
--- /dev/null
+++ b/migrations/2023-07-11-140347_add_is_recon_enabled_field_in_merchant_account/up.sql
@@ -0,0 +1,2 @@
+-- Your SQL goes here
+ALTER TABLE merchant_account ADD COLUMN "is_recon_enabled" BOOLEAN NOT NULL DEFAULT FALSE;
\ No newline at end of file
diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json
index e2686ca24b..911279bbf9 100644
--- a/openapi/openapi_spec.json
+++ b/openapi/openapi_spec.json
@@ -5014,7 +5014,8 @@
"merchant_id",
"enable_payment_response_hash",
"redirect_to_merchant_with_http_post",
- "primary_business_details"
+ "primary_business_details",
+ "is_recon_enabled"
],
"properties": {
"merchant_id": {
@@ -5135,6 +5136,10 @@
"type": "string",
"description": "The organization id merchant is associated with",
"nullable": true
+ },
+ "is_recon_enabled": {
+ "type": "boolean",
+ "description": "A boolean value to indicate if the merchant has recon service is enabled or not, by default value is false"
}
}
},