Skip to content

Commit

Permalink
Merge branch 'main' of github.com:juspay/hyperswitch into refactor-cu…
Browse files Browse the repository at this point in the history
…stomer-pm-list
  • Loading branch information
Sarthak1799 committed Aug 1, 2024
2 parents e838c6e + 537630f commit 29945bf
Show file tree
Hide file tree
Showing 91 changed files with 4,605 additions and 677 deletions.
7 changes: 4 additions & 3 deletions crates/api_models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ frm = []
olap = []
openapi = ["common_enums/openapi", "olap", "recon", "dummy_connector", "olap"]
recon = []
v1 =[]
v1 = []
v2 = []
routing_v2 = []
merchant_connector_account_v2 = []
business_profile_v2 = []
customer_v2 = []
merchant_account_v2 = []
merchant_connector_account_v2 = []
payment_v2 = []
payment_methods_v2 = []
routing_v2 = []

[dependencies]
actix-web = { version = "4.5.1", optional = true }
Expand Down
102 changes: 100 additions & 2 deletions crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ pub struct MerchantConnectorResponse {

/// Unique ID of the merchant connector account
#[schema(example = "mca_5apGeP94tMts6rg3U3kR")]
pub connector_id: String,
pub id: String,

/// Identifier for the business profile, if not provided default will be chosen from merchant account
#[schema(max_length = 64)]
Expand Down Expand Up @@ -1032,7 +1032,7 @@ impl MerchantConnectorResponse {
pub fn to_merchant_connector_info(&self, connector_label: &String) -> MerchantConnectorInfo {
MerchantConnectorInfo {
connector_label: connector_label.to_string(),
merchant_connector_id: self.connector_id.clone(),
merchant_connector_id: self.id.clone(),
}
}
}
Expand Down Expand Up @@ -1162,6 +1162,10 @@ impl MerchantConnectorResponse {
}
}

#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "merchant_connector_account_v2")
))]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct MerchantConnectorListResponse {
Expand Down Expand Up @@ -1257,6 +1261,10 @@ pub struct MerchantConnectorListResponse {
pub additional_merchant_data: Option<AdditionalMerchantData>,
}

#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "merchant_connector_account_v2")
))]
impl MerchantConnectorListResponse {
pub fn to_merchant_connector_info(&self, connector_label: &String) -> MerchantConnectorInfo {
MerchantConnectorInfo {
Expand All @@ -1266,6 +1274,96 @@ impl MerchantConnectorListResponse {
}
}

#[cfg(all(feature = "v2", feature = "merchant_connector_account_v2"))]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct MerchantConnectorListResponse {
/// Type of the Connector for the financial use case. Could range from Payments to Accounting to Banking.
#[schema(value_type = ConnectorType, example = "payment_processor")]
pub connector_type: api_enums::ConnectorType,
/// Name of the Connector
#[schema(value_type = Connector, example = "stripe")]
pub connector_name: String,

/// A unique label to identify the connector account created under a business profile
#[schema(example = "stripe_US_travel")]
pub connector_label: Option<String>,

/// Unique ID of the merchant connector account
#[schema(example = "mca_5apGeP94tMts6rg3U3kR")]
pub id: String,

/// Identifier for the business profile, if not provided default will be chosen from merchant account
#[schema(max_length = 64)]
pub profile_id: Option<String>,

/// An object containing the details about the payment methods that need to be enabled under this merchant connector account
#[schema(example = json!([
{
"payment_method": "wallet",
"payment_method_types": [
"upi_collect",
"upi_intent"
],
"payment_method_issuers": [
"labore magna ipsum",
"aute"
],
"payment_schemes": [
"Discover",
"Discover"
],
"accepted_currencies": {
"type": "enable_only",
"list": ["USD", "EUR"]
},
"accepted_countries": {
"type": "disable_only",
"list": ["FR", "DE","IN"]
},
"minimum_amount": 1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
}
]))]
pub payment_methods_enabled: Option<Vec<PaymentMethodsEnabled>>,

/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>,max_length = 255,example = json!({ "city": "NY", "unit": "245" }))]
pub metadata: Option<pii::SecretSerdeValue>,

/// A boolean value to indicate if the connector is disabled. By default, its value is false.
#[schema(default = false, example = false)]
pub disabled: Option<bool>,

/// Contains the frm configs for the merchant connector
#[schema(example = json!(consts::FRM_CONFIGS_EG))]
pub frm_configs: Option<Vec<FrmConfigs>>,

/// identifier for the verified domains of a particular connector account
pub applepay_verified_domains: Option<Vec<String>>,

#[schema(value_type = Option<Object>)]
pub pm_auth_config: Option<pii::SecretSerdeValue>,

#[schema(value_type = ConnectorStatus, example = "inactive")]
pub status: api_enums::ConnectorStatus,

#[schema(value_type = Option<AdditionalMerchantData>)]
pub additional_merchant_data: Option<AdditionalMerchantData>,
}

#[cfg(all(feature = "v2", feature = "merchant_connector_account_v2"))]
impl MerchantConnectorListResponse {
pub fn to_merchant_connector_info(&self, connector_label: &String) -> MerchantConnectorInfo {
MerchantConnectorInfo {
connector_label: connector_label.to_string(),
merchant_connector_id: self.id.clone(),
}
}
}

/// Create a new Merchant Connector for the merchant account. The connector could be a payment processor / facilitator / acquirer or specialized services like Fraud / Accounting etc."
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
Expand Down
3 changes: 2 additions & 1 deletion crates/api_models/src/user_role/role.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use common_enums::{PermissionGroup, RoleScope};
use common_enums::{EntityType, PermissionGroup, RoleScope};

use super::Permission;

Expand All @@ -7,6 +7,7 @@ pub struct CreateRoleRequest {
pub role_name: String,
pub groups: Vec<PermissionGroup>,
pub role_scope: RoleScope,
pub entity_type: Option<EntityType>,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
Expand Down
42 changes: 42 additions & 0 deletions crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3027,9 +3027,51 @@ pub enum Owner {
Internal,
}

#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
)]
#[router_derive::diesel_enum(storage_type = "text")]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum EntityType {
Internal,
Organization,
Merchant,
Profile,
}

#[derive(Clone, Debug, serde::Serialize)]
#[serde(rename_all = "snake_case")]
pub enum PayoutRetryType {
SingleConnector,
MultiConnector,
}

#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
ToSchema,
Hash,
)]
#[router_derive::diesel_enum(storage_type = "db_enum")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum OrderFulfillmentTimeOrigin {
Create,
Confirm,
}
4 changes: 3 additions & 1 deletion crates/diesel_models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ readme = "README.md"
license.workspace = true

[features]
default = ["kv_store", "v1"]
default = ["kv_store", "v1"]
kv_store = []
v1 =[]
v2 = []
business_profile_v2 = []
customer_v2 = []
merchant_account_v2 = []
merchant_connector_account_v2 = []
payment_v2 = []

[dependencies]
Expand Down
Loading

0 comments on commit 29945bf

Please sign in to comment.