mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
refactor(payment_connector): allow connector label to be updated (#2622)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -661,12 +661,38 @@ pub async fn create_payment_connector(
|
||||
&merchant_account,
|
||||
)?;
|
||||
|
||||
let connector_label = core_utils::get_connector_label(
|
||||
// Business label support will be deprecated soon
|
||||
let profile_id = core_utils::get_profile_id_from_business_details(
|
||||
req.business_country,
|
||||
req.business_label.as_ref(),
|
||||
req.business_sub_label.as_ref(),
|
||||
&req.connector_name.to_string(),
|
||||
);
|
||||
&merchant_account,
|
||||
req.profile_id.as_ref(),
|
||||
store,
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let business_profile = state
|
||||
.store
|
||||
.find_business_profile_by_profile_id(&profile_id)
|
||||
.await
|
||||
.to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {
|
||||
id: profile_id.to_owned(),
|
||||
})?;
|
||||
|
||||
// If connector label is not passed in the request, generate one
|
||||
let connector_label = req
|
||||
.connector_label
|
||||
.or(core_utils::get_connector_label(
|
||||
req.business_country,
|
||||
req.business_label.as_ref(),
|
||||
req.business_sub_label.as_ref(),
|
||||
&req.connector_name.to_string(),
|
||||
))
|
||||
.unwrap_or(format!(
|
||||
"{}_{}",
|
||||
req.connector_name, business_profile.profile_name
|
||||
));
|
||||
|
||||
let mut vec = Vec::new();
|
||||
let payment_methods_enabled = match req.payment_methods_enabled {
|
||||
@ -718,16 +744,6 @@ pub async fn create_payment_connector(
|
||||
|
||||
let frm_configs = get_frm_config_as_secret(req.frm_configs);
|
||||
|
||||
let profile_id = core_utils::get_profile_id_from_business_details(
|
||||
req.business_country,
|
||||
req.business_label.as_ref(),
|
||||
&merchant_account,
|
||||
req.profile_id.as_ref(),
|
||||
&*state.store,
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let merchant_connector_account = domain::MerchantConnectorAccount {
|
||||
merchant_id: merchant_id.to_string(),
|
||||
connector_type: req.connector_type,
|
||||
@ -749,7 +765,7 @@ pub async fn create_payment_connector(
|
||||
disabled: req.disabled,
|
||||
metadata: req.metadata,
|
||||
frm_configs,
|
||||
connector_label: connector_label.clone(),
|
||||
connector_label: Some(connector_label),
|
||||
business_country: req.business_country,
|
||||
business_label: req.business_label.clone(),
|
||||
business_sub_label: req.business_sub_label,
|
||||
@ -911,6 +927,7 @@ pub async fn update_payment_connector(
|
||||
connector_type: Some(req.connector_type),
|
||||
connector_name: None,
|
||||
merchant_connector_id: None,
|
||||
connector_label: req.connector_label,
|
||||
connector_account_details: req
|
||||
.connector_account_details
|
||||
.async_lift(|inner| {
|
||||
|
||||
Reference in New Issue
Block a user