From 0d5cd711b245fb69d0f35830aa1ba2f0b8a297cc Mon Sep 17 00:00:00 2001 From: Narayan Bhat <48803246+Narayanbhat166@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:19:12 +0530 Subject: [PATCH] fix: add `profile_id` in dispute (#3486) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- crates/api_models/src/disputes.rs | 4 ++++ crates/router/src/core/webhooks.rs | 5 ++++- crates/router/src/types/transformers.rs | 2 ++ openapi/openapi_spec.json | 10 ++++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/api_models/src/disputes.rs b/crates/api_models/src/disputes.rs index b8955bb8ff..ca701ddf9b 100644 --- a/crates/api_models/src/disputes.rs +++ b/crates/api_models/src/disputes.rs @@ -43,6 +43,10 @@ pub struct DisputeResponse { /// Time at which dispute is received #[serde(with = "common_utils::custom_serde::iso8601")] pub created_at: PrimitiveDateTime, + /// The `profile_id` associated with the dispute + pub profile_id: Option, + /// The `merchant_connector_id` of the connector / processor through which the dispute was processed + pub merchant_connector_id: Option, } #[derive(Clone, Debug, Serialize, ToSchema, Eq, PartialEq)] diff --git a/crates/router/src/core/webhooks.rs b/crates/router/src/core/webhooks.rs index f0348e45eb..cc30146de3 100644 --- a/crates/router/src/core/webhooks.rs +++ b/crates/router/src/core/webhooks.rs @@ -340,6 +340,7 @@ pub async fn get_payment_attempt_from_object_reference_id( } } +#[allow(clippy::too_many_arguments)] pub async fn get_or_update_dispute_object( state: AppState, option_dispute: Option, @@ -347,6 +348,7 @@ pub async fn get_or_update_dispute_object( merchant_id: &str, payment_attempt: &data_models::payments::payment_attempt::PaymentAttempt, event_type: api_models::webhooks::IncomingWebhookEvent, + business_profile: &diesel_models::business_profile::BusinessProfile, connector_name: &str, ) -> CustomResult { let db = &*state.store; @@ -375,7 +377,7 @@ pub async fn get_or_update_dispute_object( challenge_required_by: dispute_details.challenge_required_by, connector_created_at: dispute_details.created_at, connector_updated_at: dispute_details.updated_at, - profile_id: None, + profile_id: Some(business_profile.profile_id.clone()), evidence: None, merchant_connector_id: payment_attempt.merchant_connector_id.clone(), }; @@ -534,6 +536,7 @@ pub async fn disputes_incoming_webhook_flow( &merchant_account.merchant_id, &payment_attempt, event_type, + &business_profile, connector.id(), ) .await?; diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index 41aefc9026..3821654686 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -693,6 +693,8 @@ impl ForeignFrom for api_models::disputes::DisputeResponse { connector_created_at: dispute.connector_created_at, connector_updated_at: dispute.connector_updated_at, created_at: dispute.created_at, + profile_id: dispute.profile_id, + merchant_connector_id: dispute.merchant_connector_id, } } } diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index 9afd518252..98cfaecf6b 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -7641,6 +7641,16 @@ "type": "string", "format": "date-time", "description": "Time at which dispute is received" + }, + "profile_id": { + "type": "string", + "description": "The `profile_id` associated with the dispute", + "nullable": true + }, + "merchant_connector_id": { + "type": "string", + "description": "The `merchant_connector_id` of the connector / processor through which the dispute was processed", + "nullable": true } } },