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: add `organization_id` to merchant account (#1611)

Narayan Bhat7025b789b812
diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs
index 4e69aea9c9..9868d963fe 100644
--- a/crates/api_models/src/admin.rs
+++ b/crates/api_models/src/admin.rs
@@ -83,6 +83,9 @@ pub struct MerchantAccountCreate {
///(900) for 15 mins
#[schema(example = 900)]
pub intent_fulfillment_time: Option<u32>,
+
+ /// The id of the organization to which the merchant belongs to
+ pub organization_id: Option<String>,
}
#[derive(Clone, Debug, Deserialize, ToSchema)]
@@ -221,6 +224,9 @@ pub struct MerchantAccountResponse {
///Will be used to expire client secret after certain amount of time to be supplied in seconds
///(900) for 15 mins
pub intent_fulfillment_time: Option<i64>,
+
+ /// The organization id merchant is associated with
+ pub organization_id: Option<String>,
}
#[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 c4dd26f206..e295ccd898 100644
--- a/crates/diesel_models/src/merchant_account.rs
+++ b/crates/diesel_models/src/merchant_account.rs
@@ -35,6 +35,7 @@ pub struct MerchantAccount {
pub created_at: time::PrimitiveDateTime,
pub modified_at: time::PrimitiveDateTime,
pub frm_routing_algorithm: Option<serde_json::Value>,
+ pub organization_id: Option<String>,
}
#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
@@ -59,6 +60,7 @@ pub struct MerchantAccountNew {
pub created_at: time::PrimitiveDateTime,
pub modified_at: time::PrimitiveDateTime,
pub frm_routing_algorithm: Option<serde_json::Value>,
+ pub organization_id: Option<String>,
}
#[derive(Clone, Debug, Default, AsChangeset, router_derive::DebugAsDisplay)]
@@ -82,4 +84,5 @@ pub struct MerchantAccountUpdateInternal {
pub modified_at: Option<time::PrimitiveDateTime>,
pub intent_fulfillment_time: Option<i64>,
pub frm_routing_algorithm: Option<serde_json::Value>,
+ pub organization_id: Option<String>,
}
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index 6c0e28db19..447b67c523 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -328,6 +328,8 @@ diesel::table! {
created_at -> Timestamp,
modified_at -> Timestamp,
frm_routing_algorithm -> Nullable<Jsonb>,
+ #[max_length = 32]
+ organization_id -> Nullable<Varchar>,
}
}
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index 390e03e94e..8e8af3aa3b 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -172,6 +172,7 @@ pub async fn create_merchant_account(
frm_routing_algorithm: req.frm_routing_algorithm,
intent_fulfillment_time: req.intent_fulfillment_time.map(i64::from),
id: None,
+ organization_id: req.organization_id,
})
}
.await
diff --git a/crates/router/src/types/api/admin.rs b/crates/router/src/types/api/admin.rs
index 1695f88a36..b3fcc07b8f 100644
--- a/crates/router/src/types/api/admin.rs
+++ b/crates/router/src/types/api/admin.rs
@@ -34,6 +34,7 @@ impl TryFrom<domain::MerchantAccount> for MerchantAccountResponse {
primary_business_details,
frm_routing_algorithm: item.frm_routing_algorithm,
intent_fulfillment_time: item.intent_fulfillment_time,
+ organization_id: item.organization_id,
})
}
}
diff --git a/crates/router/src/types/domain/merchant_account.rs b/crates/router/src/types/domain/merchant_account.rs
index 80c3c2cb5a..301a34276d 100644
--- a/crates/router/src/types/domain/merchant_account.rs
+++ b/crates/router/src/types/domain/merchant_account.rs
@@ -36,6 +36,7 @@ pub struct MerchantAccount {
pub created_at: time::PrimitiveDateTime,
pub modified_at: time::PrimitiveDateTime,
pub intent_fulfillment_time: Option<i64>,
+ pub organization_id: Option<String>,
}
#[allow(clippy::large_enum_variant)]
@@ -142,6 +143,7 @@ impl super::behaviour::Conversion for MerchantAccount {
modified_at: self.modified_at,
intent_fulfillment_time: self.intent_fulfillment_time,
frm_routing_algorithm: self.frm_routing_algorithm,
+ organization_id: self.organization_id,
})
}
@@ -181,6 +183,7 @@ impl super::behaviour::Conversion for MerchantAccount {
created_at: item.created_at,
modified_at: item.modified_at,
intent_fulfillment_time: item.intent_fulfillment_time,
+ organization_id: item.organization_id,
})
}
.await
@@ -211,6 +214,7 @@ impl super::behaviour::Conversion for MerchantAccount {
modified_at: now,
intent_fulfillment_time: self.intent_fulfillment_time,
frm_routing_algorithm: self.frm_routing_algorithm,
+ organization_id: self.organization_id,
})
}
}
diff --git a/migrations/2023-07-04-131721_add_org_id_and_org_name/down.sql b/migrations/2023-07-04-131721_add_org_id_and_org_name/down.sql
new file mode 100644
index 0000000000..67a408a3e8
--- /dev/null
+++ b/migrations/2023-07-04-131721_add_org_id_and_org_name/down.sql
@@ -0,0 +1,2 @@
+-- This file should undo anything in `up.sql`
+ALTER TABLE merchant_account DROP COLUMN IF EXISTS organization_id;
diff --git a/migrations/2023-07-04-131721_add_org_id_and_org_name/up.sql b/migrations/2023-07-04-131721_add_org_id_and_org_name/up.sql
new file mode 100644
index 0000000000..2d568abd82
--- /dev/null
+++ b/migrations/2023-07-04-131721_add_org_id_and_org_name/up.sql
@@ -0,0 +1,3 @@
+-- Your SQL goes here
+ALTER TABLE merchant_account
+ADD COLUMN IF NOT EXISTS organization_id VARCHAR(32);
diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json
index 51095d9c35..344500a49e 100644
--- a/openapi/openapi_spec.json
+++ b/openapi/openapi_spec.json
@@ -4846,6 +4846,11 @@
"example": 900,
"nullable": true,
"minimum": 0.0
+ },
+ "organization_id": {
+ "type": "string",
+ "description": "The id of the organization to which the merchant belongs to",
+ "nullable": true
}
}
},
@@ -4991,6 +4996,11 @@
"format": "int64",
"description": "Will be used to expire client secret after certain amount of time to be supplied in seconds\n(900) for 15 mins",
"nullable": true
+ },
+ "organization_id": {
+ "type": "string",
+ "description": "The organization id merchant is associated with",
+ "nullable": true
}
}
},