Skip to content

Commit 53b4816

Browse files
refactor(merchant_account): make organization_id as mandatory (#2458)
1 parent 8c80c00 commit 53b4816

File tree

8 files changed

+21
-8
lines changed

8 files changed

+21
-8
lines changed

crates/api_models/src/admin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ pub struct MerchantAccountResponse {
265265
pub intent_fulfillment_time: Option<i64>,
266266

267267
/// The organization id merchant is associated with
268-
pub organization_id: Option<String>,
268+
pub organization_id: String,
269269

270270
/// A boolean value to indicate if the merchant has recon service is enabled or not, by default value is false
271271
pub is_recon_enabled: bool,

crates/diesel_models/src/merchant_account.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct MerchantAccount {
3636
pub modified_at: time::PrimitiveDateTime,
3737
pub frm_routing_algorithm: Option<serde_json::Value>,
3838
pub payout_routing_algorithm: Option<serde_json::Value>,
39-
pub organization_id: Option<String>,
39+
pub organization_id: String,
4040
pub is_recon_enabled: bool,
4141
pub default_profile: Option<String>,
4242
pub recon_status: storage_enums::ReconStatus,
@@ -65,7 +65,7 @@ pub struct MerchantAccountNew {
6565
pub modified_at: time::PrimitiveDateTime,
6666
pub frm_routing_algorithm: Option<serde_json::Value>,
6767
pub payout_routing_algorithm: Option<serde_json::Value>,
68-
pub organization_id: Option<String>,
68+
pub organization_id: String,
6969
pub is_recon_enabled: bool,
7070
pub default_profile: Option<String>,
7171
pub recon_status: storage_enums::ReconStatus,

crates/diesel_models/src/schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ diesel::table! {
437437
frm_routing_algorithm -> Nullable<Jsonb>,
438438
payout_routing_algorithm -> Nullable<Jsonb>,
439439
#[max_length = 32]
440-
organization_id -> Nullable<Varchar>,
440+
organization_id -> Varchar,
441441
is_recon_enabled -> Bool,
442442
#[max_length = 64]
443443
default_profile -> Nullable<Varchar>,

crates/router/src/core/admin.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ use crate::{
3131
utils::{self, OptionExt},
3232
};
3333

34+
const DEFAULT_ORG_ID: &str = "org_abcdefghijklmn";
35+
3436
#[inline]
3537
pub fn create_merchant_publishable_key() -> String {
3638
format!(
@@ -164,7 +166,7 @@ pub async fn create_merchant_account(
164166
intent_fulfillment_time: req.intent_fulfillment_time.map(i64::from),
165167
payout_routing_algorithm: req.payout_routing_algorithm,
166168
id: None,
167-
organization_id: req.organization_id,
169+
organization_id: req.organization_id.unwrap_or(DEFAULT_ORG_ID.to_string()),
168170
is_recon_enabled: false,
169171
default_profile: None,
170172
recon_status: diesel_models::enums::ReconStatus::NotRequested,

crates/router/src/types/domain/merchant_account.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct MerchantAccount {
4040
pub modified_at: time::PrimitiveDateTime,
4141
pub intent_fulfillment_time: Option<i64>,
4242
pub payout_routing_algorithm: Option<serde_json::Value>,
43-
pub organization_id: Option<String>,
43+
pub organization_id: String,
4444
pub is_recon_enabled: bool,
4545
pub default_profile: Option<String>,
4646
pub recon_status: diesel_models::enums::ReconStatus,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- This file should undo anything in `up.sql`
2+
ALTER TABLE merchant_account
3+
ALTER COLUMN organization_id DROP NOT NULL;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Your SQL goes here
2+
UPDATE merchant_account
3+
SET organization_id = 'org_abcdefghijklmn'
4+
WHERE organization_id IS NULL;
5+
6+
ALTER TABLE merchant_account
7+
ALTER COLUMN organization_id
8+
SET NOT NULL;

openapi/openapi_spec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6113,6 +6113,7 @@
61136113
"enable_payment_response_hash",
61146114
"redirect_to_merchant_with_http_post",
61156115
"primary_business_details",
6116+
"organization_id",
61166117
"is_recon_enabled",
61176118
"recon_status"
61186119
],
@@ -6241,8 +6242,7 @@
62416242
},
62426243
"organization_id": {
62436244
"type": "string",
6244-
"description": "The organization id merchant is associated with",
6245-
"nullable": true
6245+
"description": "The organization id merchant is associated with"
62466246
},
62476247
"is_recon_enabled": {
62486248
"type": "boolean",

0 commit comments

Comments
 (0)