Skip to content

Commit 9f96ab9

Browse files
committed
modify create_webhook_url fn to take merchant_connector_id as input
1 parent be0369f commit 9f96ab9

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

crates/router/src/core/payments.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -6242,8 +6242,14 @@ pub async fn payment_external_authentication(
62426242
&payment_attempt.clone(),
62436243
payment_connector_name,
62446244
));
6245+
let merchant_connector_account_id = payment_attempt
6246+
.merchant_connector_id
6247+
.clone()
6248+
.get_required_value("merchant_connector_id")
6249+
.change_context(errors::ApiErrorResponse::InternalServerError)
6250+
.attach_printable("Merchant connector id is not present in payment_attempt")?;
62456251
let webhook_url =
6246-
helpers::create_webhook_url(&state.base_url, merchant_id, &authentication_connector);
6252+
helpers::create_webhook_url(&state.base_url, merchant_id, &merchant_connector_account_id);
62476253

62486254
let authentication_details = business_profile
62496255
.authentication_connector_details

crates/router/src/core/payments/helpers.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1236,15 +1236,16 @@ pub fn create_authorize_url(
12361236
pub fn create_webhook_url(
12371237
router_base_url: &String,
12381238
merchant_id: &id_type::MerchantId,
1239-
connector_name: impl std::fmt::Display,
1239+
merchant_connector_id: &id_type::MerchantConnectorAccountId,
12401240
) -> String {
12411241
format!(
12421242
"{}/webhooks/{}/{}",
12431243
router_base_url,
12441244
merchant_id.get_string_repr(),
1245-
connector_name
1245+
merchant_connector_id.get_string_repr(),
12461246
)
12471247
}
1248+
12481249
pub fn create_complete_authorize_url(
12491250
router_base_url: &String,
12501251
payment_attempt: &PaymentAttempt,

crates/router/src/core/payments/transformers.rs

+25-7
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
224224
let webhook_url = Some(helpers::create_webhook_url(
225225
router_base_url,
226226
&attempt.merchant_id,
227-
connector_id,
227+
&merchant_connector_account.get_id(),
228228
));
229229

230230
let router_return_url = payment_data
@@ -2368,11 +2368,17 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
23682368
attempt,
23692369
connector_name,
23702370
));
2371-
2371+
let merchant_connector_account_id = payment_data
2372+
.payment_attempt
2373+
.merchant_connector_id
2374+
.clone()
2375+
.get_required_value("merchant_connector_id")
2376+
.change_context(errors::ApiErrorResponse::InternalServerError)
2377+
.attach_printable("Merchant connector id is not present in payment_attempt")?;
23722378
let webhook_url = Some(helpers::create_webhook_url(
23732379
router_base_url,
23742380
&attempt.merchant_id,
2375-
connector_name,
2381+
&merchant_connector_account_id,
23762382
));
23772383
let router_return_url = Some(helpers::create_redirect_url(
23782384
router_base_url,
@@ -3042,11 +3048,17 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
30423048
.map(|customer| customer.clone().into_inner())
30433049
});
30443050
let amount = payment_data.payment_attempt.get_total_amount();
3045-
3051+
let merchant_connector_account_id = payment_data
3052+
.payment_attempt
3053+
.merchant_connector_id
3054+
.clone()
3055+
.get_required_value("merchant_connector_id")
3056+
.change_context(errors::ApiErrorResponse::InternalServerError)
3057+
.attach_printable("Merchant connector id is not present in payment_attempt")?;
30463058
let webhook_url = Some(helpers::create_webhook_url(
30473059
router_base_url,
30483060
&attempt.merchant_id,
3049-
connector_name,
3061+
&merchant_connector_account_id,
30503062
));
30513063

30523064
Ok(Self {
@@ -3245,11 +3257,17 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProce
32453257
.collect::<Result<Vec<_>, _>>()
32463258
})
32473259
.transpose()?;
3248-
3260+
let merchant_connector_account_id = payment_data
3261+
.payment_attempt
3262+
.merchant_connector_id
3263+
.clone()
3264+
.get_required_value("merchant_connector_id")
3265+
.change_context(errors::ApiErrorResponse::InternalServerError)
3266+
.attach_printable("Merchant connector id is not present in payment_attempt")?;
32493267
let webhook_url = Some(helpers::create_webhook_url(
32503268
router_base_url,
32513269
&attempt.merchant_id,
3252-
connector_name,
3270+
&merchant_connector_account_id,
32533271
));
32543272
let router_return_url = Some(helpers::create_redirect_url(
32553273
router_base_url,

crates/router/src/core/utils.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,16 @@ pub async fn construct_refund_router_data<'a, F>(
285285
.payment_method
286286
.get_required_value("payment_method_type")
287287
.change_context(errors::ApiErrorResponse::InternalServerError)?;
288-
288+
let merchant_connector_account_id = payment_attempt
289+
.merchant_connector_id
290+
.clone()
291+
.get_required_value("merchant_connector_id")
292+
.change_context(errors::ApiErrorResponse::InternalServerError)
293+
.attach_printable("Merchant connector id is not present in payment_attempt")?;
289294
let webhook_url = Some(helpers::create_webhook_url(
290295
&state.base_url.clone(),
291296
merchant_account.get_id(),
292-
connector_id,
297+
&merchant_connector_account_id,
293298
));
294299
let test_mode: Option<bool> = merchant_connector_account.is_test_mode_on();
295300

0 commit comments

Comments
 (0)