Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/api_models/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use crate::{
files::*,
mandates::*,
organization::{
ConvertOrganizationToPlatformRequest, ConvertOrganizationToPlatformResponse,
OrganizationCreateRequest, OrganizationId, OrganizationResponse, OrganizationUpdateRequest,
},
payment_methods::*,
Expand Down Expand Up @@ -74,6 +75,8 @@ impl_api_event_type!(
RetrievePaymentLinkResponse,
MandateListConstraints,
CreateFileResponse,
ConvertOrganizationToPlatformRequest,
ConvertOrganizationToPlatformResponse,
MerchantConnectorResponse,
MerchantConnectorId,
MandateResponse,
Expand Down
21 changes: 21 additions & 0 deletions crates/api_models/src/organization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,24 @@ pub struct OrganizationResponse {
#[schema(value_type = Option<OrganizationType>, example = "standard")]
pub organization_type: Option<OrganizationType>,
}

#[derive(serde::Deserialize, Debug, Clone, serde::Serialize, ToSchema)]
pub struct ConvertOrganizationToPlatformRequest {
/// Name for the platform merchant to be created
pub platform_merchant_name: Option<String>,
}

#[derive(serde::Serialize, Debug, Clone, ToSchema)]
pub struct ConvertOrganizationToPlatformResponse {
/// The unique identifier for the Organization
#[schema(value_type = String)]
pub organization_id: id_type::OrganizationId,

/// Organization Type after conversion
#[schema(value_type = OrganizationType)]
pub organization_type: OrganizationType,

/// The unique identifier for the platform merchant created
#[schema(value_type = String)]
pub platform_merchant_id: id_type::MerchantId,
}
3 changes: 2 additions & 1 deletion crates/api_models/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct SignUpWithMerchantIdRequest {
pub email: pii::Email,
pub password: Secret<String>,
pub company_name: String,
pub organization_type: Option<common_enums::OrganizationType>,
}

pub type SignUpWithMerchantIdResponse = AuthorizeResponse;
Expand Down Expand Up @@ -194,7 +195,7 @@ pub struct PlatformAccountCreateResponse {
pub struct UserMerchantCreate {
pub company_name: String,
pub product_type: Option<common_enums::MerchantProductType>,
pub merchant_account_type: Option<common_enums::MerchantAccountRequestType>,
pub merchant_account_type: Option<common_enums::MerchantAccountType>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be MerchantAccountRequestType?

}

#[derive(serde::Serialize, Debug, Clone)]
Expand Down
10 changes: 10 additions & 0 deletions crates/common_enums/src/enums/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,13 @@ pub enum MerchantAccountRequestType {
Standard,
Connected,
}

impl MerchantAccountType {
pub fn get_merchant_account_type(self) -> Option<MerchantAccountRequestType> {
match self {
Self::Standard => Some(MerchantAccountRequestType::Standard),
Self::Connected => Some(MerchantAccountRequestType::Connected),
Self::Platform => None,
}
}
}
29 changes: 27 additions & 2 deletions crates/diesel_models/src/organization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ pub struct OrganizationUpdateInternal {
metadata: Option<pii::SecretSerdeValue>,
modified_at: time::PrimitiveDateTime,
platform_merchant_id: Option<id_type::MerchantId>,
organization_type: Option<common_enums::OrganizationType>,
}

#[cfg(feature = "v2")]
Expand All @@ -217,13 +218,16 @@ pub struct OrganizationUpdateInternal {
metadata: Option<pii::SecretSerdeValue>,
modified_at: time::PrimitiveDateTime,
platform_merchant_id: Option<id_type::MerchantId>,
organization_type: Option<common_enums::OrganizationType>,
}

pub enum OrganizationUpdate {
Update {
organization_name: Option<String>,
organization_details: Option<pii::SecretSerdeValue>,
metadata: Option<pii::SecretSerdeValue>,
},
ConvertToPlatform {
platform_merchant_id: Option<id_type::MerchantId>,
},
}
Expand All @@ -236,14 +240,25 @@ impl From<OrganizationUpdate> for OrganizationUpdateInternal {
organization_name,
organization_details,
metadata,
platform_merchant_id,
} => Self {
org_name: organization_name.clone(),
organization_name,
organization_details,
metadata,
modified_at: common_utils::date_time::now(),
platform_merchant_id: None,
organization_type: None,
},
OrganizationUpdate::ConvertToPlatform {
platform_merchant_id,
} => Self {
org_name: None,
organization_name: None,
organization_details: None,
metadata: None,
modified_at: common_utils::date_time::now(),
platform_merchant_id,
organization_type: Some(common_enums::OrganizationType::Platform),
},
}
}
Expand All @@ -257,13 +272,23 @@ impl From<OrganizationUpdate> for OrganizationUpdateInternal {
organization_name,
organization_details,
metadata,
platform_merchant_id,
} => Self {
organization_name,
organization_details,
metadata,
modified_at: common_utils::date_time::now(),
platform_merchant_id: None,
organization_type: None,
},
OrganizationUpdate::ConvertToPlatform {
platform_merchant_id,
} => Self {
organization_name: None,
organization_details: None,
metadata: None,
modified_at: common_utils::date_time::now(),
platform_merchant_id,
organization_type: Some(common_enums::OrganizationType::Platform),
},
}
}
Expand Down
43 changes: 0 additions & 43 deletions crates/hyperswitch_domain_models/src/merchant_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ pub enum MerchantAccountUpdate {
},
UnsetDefaultProfile,
ModifiedAtUpdate,
ToPlatformAccount,
}

#[cfg(feature = "v2")]
Expand All @@ -305,7 +304,6 @@ pub enum MerchantAccountUpdate {
recon_status: diesel_models::enums::ReconStatus,
},
ModifiedAtUpdate,
ToPlatformAccount,
}

#[cfg(feature = "v1")]
Expand Down Expand Up @@ -480,35 +478,6 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
is_platform_account: None,
product_type: None,
},
MerchantAccountUpdate::ToPlatformAccount => Self {
modified_at: now,
merchant_name: None,
merchant_details: None,
return_url: None,
webhook_details: None,
sub_merchants_enabled: None,
parent_merchant_id: None,
enable_payment_response_hash: None,
payment_response_hash_key: None,
redirect_to_merchant_with_http_post: None,
publishable_key: None,
storage_scheme: None,
locker_id: None,
metadata: None,
routing_algorithm: None,
primary_business_details: None,
intent_fulfillment_time: None,
frm_routing_algorithm: None,
payout_routing_algorithm: None,
organization_id: None,
is_recon_enabled: None,
default_profile: None,
recon_status: None,
payment_link_config: None,
pm_collect_link_config: None,
is_platform_account: Some(true),
product_type: None,
},
}
}
}
Expand Down Expand Up @@ -572,18 +541,6 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {
is_platform_account: None,
product_type: None,
},
MerchantAccountUpdate::ToPlatformAccount => Self {
modified_at: now,
merchant_name: None,
merchant_details: None,
publishable_key: None,
storage_scheme: None,
metadata: None,
organization_id: None,
recon_status: None,
is_platform_account: Some(true),
product_type: None,
},
}
}
}
Expand Down
Loading
Loading