Skip to content

Commit

Permalink
refactor(merchant_account): make organization_id as mandatory (#2458)
Browse files Browse the repository at this point in the history
  • Loading branch information
Narayanbhat166 authored Oct 6, 2023
1 parent 8c80c00 commit 53b4816
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ pub struct MerchantAccountResponse {
pub intent_fulfillment_time: Option<i64>,

/// The organization id merchant is associated with
pub organization_id: Option<String>,
pub organization_id: 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,
Expand Down
4 changes: 2 additions & 2 deletions crates/diesel_models/src/merchant_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct MerchantAccount {
pub modified_at: time::PrimitiveDateTime,
pub frm_routing_algorithm: Option<serde_json::Value>,
pub payout_routing_algorithm: Option<serde_json::Value>,
pub organization_id: Option<String>,
pub organization_id: String,
pub is_recon_enabled: bool,
pub default_profile: Option<String>,
pub recon_status: storage_enums::ReconStatus,
Expand Down Expand Up @@ -65,7 +65,7 @@ pub struct MerchantAccountNew {
pub modified_at: time::PrimitiveDateTime,
pub frm_routing_algorithm: Option<serde_json::Value>,
pub payout_routing_algorithm: Option<serde_json::Value>,
pub organization_id: Option<String>,
pub organization_id: String,
pub is_recon_enabled: bool,
pub default_profile: Option<String>,
pub recon_status: storage_enums::ReconStatus,
Expand Down
2 changes: 1 addition & 1 deletion crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ diesel::table! {
frm_routing_algorithm -> Nullable<Jsonb>,
payout_routing_algorithm -> Nullable<Jsonb>,
#[max_length = 32]
organization_id -> Nullable<Varchar>,
organization_id -> Varchar,
is_recon_enabled -> Bool,
#[max_length = 64]
default_profile -> Nullable<Varchar>,
Expand Down
4 changes: 3 additions & 1 deletion crates/router/src/core/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ use crate::{
utils::{self, OptionExt},
};

const DEFAULT_ORG_ID: &str = "org_abcdefghijklmn";

#[inline]
pub fn create_merchant_publishable_key() -> String {
format!(
Expand Down Expand Up @@ -164,7 +166,7 @@ pub async fn create_merchant_account(
intent_fulfillment_time: req.intent_fulfillment_time.map(i64::from),
payout_routing_algorithm: req.payout_routing_algorithm,
id: None,
organization_id: req.organization_id,
organization_id: req.organization_id.unwrap_or(DEFAULT_ORG_ID.to_string()),
is_recon_enabled: false,
default_profile: None,
recon_status: diesel_models::enums::ReconStatus::NotRequested,
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/types/domain/merchant_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct MerchantAccount {
pub modified_at: time::PrimitiveDateTime,
pub intent_fulfillment_time: Option<i64>,
pub payout_routing_algorithm: Option<serde_json::Value>,
pub organization_id: Option<String>,
pub organization_id: String,
pub is_recon_enabled: bool,
pub default_profile: Option<String>,
pub recon_status: diesel_models::enums::ReconStatus,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- This file should undo anything in `up.sql`
ALTER TABLE merchant_account
ALTER COLUMN organization_id DROP NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Your SQL goes here
UPDATE merchant_account
SET organization_id = 'org_abcdefghijklmn'
WHERE organization_id IS NULL;

ALTER TABLE merchant_account
ALTER COLUMN organization_id
SET NOT NULL;
4 changes: 2 additions & 2 deletions openapi/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -6113,6 +6113,7 @@
"enable_payment_response_hash",
"redirect_to_merchant_with_http_post",
"primary_business_details",
"organization_id",
"is_recon_enabled",
"recon_status"
],
Expand Down Expand Up @@ -6241,8 +6242,7 @@
},
"organization_id": {
"type": "string",
"description": "The organization id merchant is associated with",
"nullable": true
"description": "The organization id merchant is associated with"
},
"is_recon_enabled": {
"type": "boolean",
Expand Down

0 comments on commit 53b4816

Please sign in to comment.