diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index 9632fc67abc3..e740d1f62a41 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -6564,15 +6564,15 @@ pub async fn payment_external_authentication( &payment_attempt.clone(), payment_connector_name, )); - let merchant_connector_account_id = merchant_connector_account + let merchant_connector_account_id_or_connector_name = merchant_connector_account .get_mca_id() - .ok_or(errors::ApiErrorResponse::InternalServerError) - .attach_printable("Error while finding mca_id from merchant_connector_account")?; + .map(|mca_id| mca_id.get_string_repr().to_string()) + .unwrap_or(authentication_connector.to_string()); let webhook_url = helpers::create_webhook_url( &state.base_url, merchant_id, - &merchant_connector_account_id.get_string_repr().to_string(), + &merchant_connector_account_id_or_connector_name, ); let authentication_details = business_profile diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 90c3775256bc..11354a246714 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -224,7 +224,10 @@ pub async fn construct_payment_router_data_for_authorize<'a>( let webhook_url = Some(helpers::create_webhook_url( router_base_url, &attempt.merchant_id, - &merchant_connector_account.get_id().get_string_repr().to_string(), + &merchant_connector_account + .get_id() + .get_string_repr() + .to_string(), )); let router_return_url = payment_data @@ -2745,7 +2748,7 @@ impl TryFrom> for types::PaymentsAuthoriz attempt, connector_name, )); - let merchant_connector_account_id = payment_data + let merchant_connector_account_id_or_connector_name = payment_data .payment_attempt .clone() .merchant_connector_id @@ -2755,7 +2758,7 @@ impl TryFrom> for types::PaymentsAuthoriz let webhook_url = Some(helpers::create_webhook_url( router_base_url, &attempt.merchant_id, - &merchant_connector_account_id, + &merchant_connector_account_id_or_connector_name, )); let router_return_url = Some(helpers::create_redirect_url( router_base_url, @@ -3575,17 +3578,16 @@ impl TryFrom> for types::SetupMandateRequ .map(|customer| customer.clone().into_inner()) }); let amount = payment_data.payment_attempt.get_total_amount(); - let merchant_connector_account_id = payment_data + let merchant_connector_account_id_or_connector_name = payment_data .payment_attempt .merchant_connector_id .clone() - .get_required_value("merchant_connector_id") - .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable("Merchant connector id is not present in payment_attempt")?; + .map(|mca_id| mca_id.get_string_repr().to_string()) + .unwrap_or(connector_name.to_string()); let webhook_url = Some(helpers::create_webhook_url( router_base_url, &attempt.merchant_id, - &merchant_connector_account_id.get_string_repr().to_string(), + &merchant_connector_account_id_or_connector_name, )); Ok(Self { @@ -3784,17 +3786,16 @@ impl TryFrom> for types::PaymentsPreProce .collect::, _>>() }) .transpose()?; - let merchant_connector_account_id = payment_data + let merchant_connector_account_id_or_connector_name = payment_data .payment_attempt .merchant_connector_id .clone() - .get_required_value("merchant_connector_id") - .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable("Merchant connector id is not present in payment_attempt")?; + .map(|mca_id| mca_id.get_string_repr().to_string()) + .unwrap_or(connector_name.to_string()); let webhook_url = Some(helpers::create_webhook_url( router_base_url, &attempt.merchant_id, - &merchant_connector_account_id.get_string_repr().to_string(), + &merchant_connector_account_id_or_connector_name, )); let router_return_url = Some(helpers::create_redirect_url( router_base_url, diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rs index adaf3030e8eb..29d81c98e526 100644 --- a/crates/router/src/core/utils.rs +++ b/crates/router/src/core/utils.rs @@ -285,16 +285,16 @@ pub async fn construct_refund_router_data<'a, F>( .payment_method .get_required_value("payment_method_type") .change_context(errors::ApiErrorResponse::InternalServerError)?; - let merchant_connector_account_id = payment_attempt + let merchant_connector_account_id_or_connector_name = payment_attempt .merchant_connector_id .clone() - .get_required_value("merchant_connector_id") - .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable("Merchant connector id is not present in payment_attempt")?; + .map(|mca_id| mca_id.get_string_repr().to_string()) + .unwrap_or(connector_id.to_string()); + let webhook_url = Some(helpers::create_webhook_url( &state.base_url.clone(), merchant_account.get_id(), - &merchant_connector_account_id.get_string_repr().to_string(), + &merchant_connector_account_id_or_connector_name, )); let test_mode: Option = merchant_connector_account.is_test_mode_on();