Skip to content

Commit

Permalink
refactor(business_profile): add is_connector_agnostic_mit_enabled i…
Browse files Browse the repository at this point in the history
…n the business profile APIs (#4925)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
ShankarSinghC and hyperswitch-bot[bot] committed Jun 10, 2024
1 parent 9c7dcbe commit 894560f
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ crates/router/src/services/ @juspay/hyperswitch-framework
crates/router/src/db/ @juspay/hyperswitch-framework
crates/router/src/routes/ @juspay/hyperswitch-framework
migrations/ @juspay/hyperswitch-framework
openapi/ @juspay/hyperswitch-framework
api-reference/ @juspay/hyperswitch-framework
postman/ @juspay/hyperswitch-framework
cypress-tests/ @juspay/hyperswitch-framework @juspay/hyperswitch-qa
Cargo.toml @juspay/hyperswitch-framework
Expand Down
10 changes: 10 additions & 0 deletions api-reference/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -6826,6 +6826,11 @@
"type": "boolean",
"description": "A boolean value to indicate if customer shipping details needs to be sent for wallets payments",
"nullable": true
},
"is_connector_agnostic_mit_enabled": {
"type": "boolean",
"description": "Indicates if the MIT (merchant initiated transaction) payments can be made connector\nagnostic, i.e., MITs may be processed through different connector than CIT (customer\ninitiated transaction) based on the routing rules.\nIf set to `false`, MIT will go through the same connector as the CIT.",
"nullable": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -6962,6 +6967,11 @@
"type": "boolean",
"description": "A boolean value to indicate if customer shipping details needs to be sent for wallets payments",
"nullable": true
},
"is_connector_agnostic_mit_enabled": {
"type": "boolean",
"description": "Indicates if the MIT (merchant initiated transaction) payments can be made connector\nagnostic, i.e., MITs may be processed through different connector than CIT (customer\ninitiated transaction) based on the routing rules.\nIf set to `false`, MIT will go through the same connector as the CIT.",
"nullable": true
}
}
},
Expand Down
18 changes: 18 additions & 0 deletions crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,12 @@ pub struct BusinessProfileCreate {

/// A boolean value to indicate if customer shipping details needs to be sent for wallets payments
pub collect_shipping_details_from_wallet_connector: Option<bool>,

/// Indicates if the MIT (merchant initiated transaction) payments can be made connector
/// agnostic, i.e., MITs may be processed through different connector than CIT (customer
/// initiated transaction) based on the routing rules.
/// If set to `false`, MIT will go through the same connector as the CIT.
pub is_connector_agnostic_mit_enabled: Option<bool>,
}

#[derive(Clone, Debug, ToSchema, Serialize)]
Expand Down Expand Up @@ -1016,6 +1022,12 @@ pub struct BusinessProfileResponse {

/// A boolean value to indicate if customer shipping details needs to be sent for wallets payments
pub collect_shipping_details_from_wallet_connector: Option<bool>,

/// Indicates if the MIT (merchant initiated transaction) payments can be made connector
/// agnostic, i.e., MITs may be processed through different connector than CIT (customer
/// initiated transaction) based on the routing rules.
/// If set to `false`, MIT will go through the same connector as the CIT.
pub is_connector_agnostic_mit_enabled: Option<bool>,
}

#[derive(Clone, Debug, Deserialize, ToSchema, Serialize)]
Expand Down Expand Up @@ -1086,6 +1098,12 @@ pub struct BusinessProfileUpdate {

/// A boolean value to indicate if customer shipping details needs to be sent for wallets payments
pub collect_shipping_details_from_wallet_connector: Option<bool>,

/// Indicates if the MIT (merchant initiated transaction) payments can be made connector
/// agnostic, i.e., MITs may be processed through different connector than CIT (customer
/// initiated transaction) based on the routing rules.
/// If set to `false`, MIT will go through the same connector as the CIT.
pub is_connector_agnostic_mit_enabled: Option<bool>,
}

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
Expand Down
3 changes: 3 additions & 0 deletions crates/diesel_models/src/business_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ pub enum BusinessProfileUpdate {
extended_card_info_config: Option<pii::SecretSerdeValue>,
use_billing_as_payment_method_billing: Option<bool>,
collect_shipping_details_from_wallet_connector: Option<bool>,
is_connector_agnostic_mit_enabled: Option<bool>,
},
ExtendedCardInfoUpdate {
is_extended_card_info_enabled: Option<bool>,
Expand Down Expand Up @@ -157,6 +158,7 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
extended_card_info_config,
use_billing_as_payment_method_billing,
collect_shipping_details_from_wallet_connector,
is_connector_agnostic_mit_enabled,
} => Self {
profile_name,
modified_at,
Expand All @@ -178,6 +180,7 @@ impl From<BusinessProfileUpdate> for BusinessProfileUpdateInternal {
extended_card_info_config,
use_billing_as_payment_method_billing,
collect_shipping_details_from_wallet_connector,
is_connector_agnostic_mit_enabled,
..Default::default()
},
BusinessProfileUpdate::ExtendedCardInfoUpdate {
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/core/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ pub async fn update_business_profile_cascade(
extended_card_info_config: None,
use_billing_as_payment_method_billing: None,
collect_shipping_details_from_wallet_connector: None,
is_connector_agnostic_mit_enabled: None,
};

let update_futures = business_profiles.iter().map(|business_profile| async {
Expand Down Expand Up @@ -1728,6 +1729,7 @@ pub async fn update_business_profile(
use_billing_as_payment_method_billing: request.use_billing_as_payment_method_billing,
collect_shipping_details_from_wallet_connector: request
.collect_shipping_details_from_wallet_connector,
is_connector_agnostic_mit_enabled: request.is_connector_agnostic_mit_enabled,
};

let updated_business_profile = db
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/routing/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ pub async fn update_business_profile_active_algorithm_ref(
extended_card_info_config: None,
use_billing_as_payment_method_billing: None,
collect_shipping_details_from_wallet_connector: None,
is_connector_agnostic_mit_enabled: None,
};

db.update_business_profile_by_profile_id(current_business_profile, business_profile_update)
Expand Down
3 changes: 2 additions & 1 deletion crates/router/src/types/api/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ impl ForeignTryFrom<storage::business_profile::BusinessProfile> for BusinessProf
.transpose()?,
collect_shipping_details_from_wallet_connector: item
.collect_shipping_details_from_wallet_connector,
is_connector_agnostic_mit_enabled: item.is_connector_agnostic_mit_enabled,
})
}
}
Expand Down Expand Up @@ -183,7 +184,7 @@ impl ForeignTryFrom<(domain::MerchantAccount, BusinessProfileCreate)>
.change_context(errors::ApiErrorResponse::InvalidDataValue {
field_name: "authentication_connector_details",
})?,
is_connector_agnostic_mit_enabled: None,
is_connector_agnostic_mit_enabled: request.is_connector_agnostic_mit_enabled,
is_extended_card_info_enabled: None,
extended_card_info_config: None,
use_billing_as_payment_method_billing: request
Expand Down

0 comments on commit 894560f

Please sign in to comment.