Skip to content

Commit

Permalink
add create_webhook_url fn changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cookieg13 committed Jan 6, 2025
1 parent c595f10 commit a13dbf6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
8 changes: 4 additions & 4 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 14 additions & 13 deletions crates/router/src/core/payments/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2745,7 +2748,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> 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
Expand All @@ -2755,7 +2758,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> 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,
Expand Down Expand Up @@ -3575,17 +3578,16 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> 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 {
Expand Down Expand Up @@ -3784,17 +3786,16 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProce
.collect::<Result<Vec<_>, _>>()
})
.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,
Expand Down
10 changes: 5 additions & 5 deletions crates/router/src/core/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> = merchant_connector_account.is_test_mode_on();

Expand Down

0 comments on commit a13dbf6

Please sign in to comment.