Skip to content

Commit 82f15e9

Browse files
feat(connector_cloning): Create API for cloning connectors between merchants and profiles. (#7949)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent 46e830a commit 82f15e9

File tree

25 files changed

+493
-87
lines changed

25 files changed

+493
-87
lines changed

config/config.example.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,9 @@ billing_connectors_which_require_payment_sync = "stripebilling, recurly" # List
10681068
enabled = true # Enable or disable Open Router
10691069
url = "http://localhost:8080" # Open Router URL
10701070

1071-
10721071
[billing_connectors_invoice_sync]
1073-
billing_connectors_which_requires_invoice_sync_call = "recurly" # List of billing connectors which has invoice sync api call
1072+
billing_connectors_which_requires_invoice_sync_call = "recurly" # List of billing connectors which has invoice sync api call
1073+
1074+
[clone_connector_allowlist]
1075+
merchant_ids = "merchant_ids" # Comma-separated list of allowed merchant IDs
1076+
connector_names = "connector_names" # Comma-separated list of allowed connector names

config/deployments/env_specific.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,7 @@ background_color = "#FFFFFF" # Background color of email bod
362362

363363
[connectors.unified_authentication_service] #Unified Authentication Service Configuration
364364
base_url = "http://localhost:8000" #base url to call unified authentication service
365+
366+
[clone_connector_allowlist]
367+
merchant_ids = "merchant_ids" # Comma-separated list of allowed merchant IDs
368+
connector_names = "connector_names" # Comma-separated list of allowed connector names

config/development.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,3 +1156,7 @@ click_to_pay = {connector_list = "adyen, cybersource"}
11561156
[open_router]
11571157
enabled = false
11581158
url = "http://localhost:8080"
1159+
1160+
[clone_connector_allowlist]
1161+
merchant_ids = "merchant_123, merchant_234" # Comma-separated list of allowed merchant IDs
1162+
connector_names = "stripe, adyen" # Comma-separated list of allowed connector names

config/docker_compose.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,3 +1051,7 @@ enabled = true
10511051

10521052
[authentication_providers]
10531053
click_to_pay = {connector_list = "adyen, cybersource"}
1054+
1055+
[clone_connector_allowlist]
1056+
merchant_ids = "merchant_123, merchant_234" # Comma-separated list of allowed merchant IDs
1057+
connector_names = "stripe, adyen" # Comma-separated list of allowed connector names

crates/api_models/src/events/user.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::user::{
1111
GetMetaDataRequest, GetMetaDataResponse, GetMultipleMetaDataPayload, SetMetaDataRequest,
1212
},
1313
AcceptInviteFromEmailRequest, AuthSelectRequest, AuthorizeResponse, BeginTotpResponse,
14-
ChangePasswordRequest, ConnectAccountRequest, CreateInternalUserRequest,
14+
ChangePasswordRequest, CloneConnectorRequest, ConnectAccountRequest, CreateInternalUserRequest,
1515
CreateTenantUserRequest, CreateUserAuthenticationMethodRequest, ForgotPasswordRequest,
1616
GetSsoAuthUrlRequest, GetUserAuthenticationMethodsRequest, GetUserDetailsResponse,
1717
GetUserRoleDetailsRequest, GetUserRoleDetailsResponseV2, InviteUserRequest,
@@ -71,7 +71,8 @@ common_utils::impl_api_event_type!(
7171
UpdateUserAuthenticationMethodRequest,
7272
GetSsoAuthUrlRequest,
7373
SsoSignInRequest,
74-
AuthSelectRequest
74+
AuthSelectRequest,
75+
CloneConnectorRequest
7576
)
7677
);
7778

crates/api_models/src/user.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,31 @@ pub struct SwitchProfileRequest {
108108
pub profile_id: id_type::ProfileId,
109109
}
110110

111+
#[derive(Debug, serde::Deserialize, serde::Serialize)]
112+
pub struct CloneConnectorSource {
113+
pub mca_id: id_type::MerchantConnectorAccountId,
114+
pub merchant_id: id_type::MerchantId,
115+
}
116+
117+
#[derive(Debug, serde::Deserialize, serde::Serialize)]
118+
pub struct CloneConnectorDestination {
119+
pub connector_label: Option<String>,
120+
pub profile_id: id_type::ProfileId,
121+
pub merchant_id: id_type::MerchantId,
122+
}
123+
124+
#[derive(Debug, serde::Deserialize, serde::Serialize)]
125+
pub struct CloneConnectorRequest {
126+
pub source: CloneConnectorSource,
127+
pub destination: CloneConnectorDestination,
128+
}
129+
111130
#[derive(serde::Deserialize, Debug, serde::Serialize)]
112131
pub struct CreateInternalUserRequest {
113132
pub name: Secret<String>,
114133
pub email: pii::Email,
115134
pub password: Secret<String>,
135+
pub role_id: String,
116136
}
117137

118138
#[derive(serde::Deserialize, Debug, serde::Serialize)]

crates/common_enums/src/enums.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7214,6 +7214,7 @@ pub enum PermissionGroup {
72147214
ReconReportsManage,
72157215
ReconOpsView,
72167216
ReconOpsManage,
7217+
InternalManage,
72177218
}
72187219

72197220
#[derive(Clone, Debug, serde::Serialize, PartialEq, Eq, Hash, strum::EnumIter)]
@@ -7226,6 +7227,7 @@ pub enum ParentGroup {
72267227
ReconOps,
72277228
ReconReports,
72287229
Account,
7230+
Internal,
72297231
}
72307232

72317233
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, serde::Serialize)]
@@ -7255,6 +7257,7 @@ pub enum Resource {
72557257
RunRecon,
72567258
ReconConfig,
72577259
RevenueRecovery,
7260+
InternalConnector,
72587261
}
72597262

72607263
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, serde::Serialize, Hash)]

crates/common_utils/src/consts.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ pub const ROLE_ID_ORGANIZATION_ADMIN: &str = "org_admin";
127127
pub const ROLE_ID_INTERNAL_VIEW_ONLY_USER: &str = "internal_view_only";
128128
/// Role ID for Internal Admin
129129
pub const ROLE_ID_INTERNAL_ADMIN: &str = "internal_admin";
130+
/// Role ID for Internal Demo
131+
pub const ROLE_ID_INTERNAL_DEMO: &str = "internal_demo";
130132

131133
/// Max length allowed for Description
132134
pub const MAX_DESCRIPTION_LENGTH: u16 = 255;

crates/router/src/configs/secrets_transformers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,5 +536,6 @@ pub(crate) async fn fetch_raw_secrets(
536536
platform: conf.platform,
537537
authentication_providers: conf.authentication_providers,
538538
open_router: conf.open_router,
539+
clone_connector_allowlist: conf.clone_connector_allowlist,
539540
}
540541
}

crates/router/src/configs/settings.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,24 @@ pub struct Settings<S: SecretState> {
153153
pub platform: Platform,
154154
pub authentication_providers: AuthenticationProviders,
155155
pub open_router: OpenRouter,
156+
pub clone_connector_allowlist: Option<CloneConnectorAllowlistConfig>,
156157
}
157158

158159
#[derive(Debug, Deserialize, Clone, Default)]
159160
pub struct OpenRouter {
160161
pub enabled: bool,
161162
pub url: String,
162163
}
164+
165+
#[derive(Debug, Deserialize, Clone, Default)]
166+
#[serde(default)]
167+
pub struct CloneConnectorAllowlistConfig {
168+
#[serde(deserialize_with = "deserialize_merchant_ids")]
169+
pub merchant_ids: HashSet<id_type::MerchantId>,
170+
#[serde(deserialize_with = "deserialize_hashset")]
171+
pub connector_names: HashSet<enums::Connector>,
172+
}
173+
163174
#[derive(Debug, Deserialize, Clone, Default)]
164175
pub struct Platform {
165176
pub enabled: bool,

0 commit comments

Comments
 (0)