Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat: adding refunds type to api_event_logs api to fetch refunds audit trail (#3503)

Sagar naikc2b2b65b9cfc
diff --git a/crates/analytics/src/api_event/events.rs b/crates/analytics/src/api_event/events.rs
index eb9b2d561c..4be3a3420d 100644
--- a/crates/analytics/src/api_event/events.rs
+++ b/crates/analytics/src/api_event/events.rs
@@ -33,9 +33,30 @@ where
.add_filter_clause("merchant_id", merchant_id)
.switch()?;
match query_param.query_param {
- QueryType::Payment { payment_id } => query_builder
- .add_filter_clause("payment_id", payment_id)
- .switch()?,
+ QueryType::Payment { payment_id } => {
+ query_builder
+ .add_filter_clause("payment_id", payment_id)
+ .switch()?;
+ query_builder
+ .add_filter_in_range_clause(
+ "api_flow",
+ &[
+ Flow::PaymentsCancel,
+ Flow::PaymentsCapture,
+ Flow::PaymentsConfirm,
+ Flow::PaymentsCreate,
+ Flow::PaymentsStart,
+ Flow::PaymentsUpdate,
+ Flow::RefundsCreate,
+ Flow::RefundsUpdate,
+ Flow::DisputesEvidenceSubmit,
+ Flow::AttachDisputeEvidence,
+ Flow::RetrieveDisputeEvidence,
+ Flow::IncomingWebhookReceive,
+ ],
+ )
+ .switch()?;
+ }
QueryType::Refund {
payment_id,
refund_id,
@@ -46,28 +67,31 @@ where
query_builder
.add_filter_clause("refund_id", refund_id)
.switch()?;
+ query_builder
+ .add_filter_in_range_clause("api_flow", &[Flow::RefundsCreate, Flow::RefundsUpdate])
+ .switch()?;
+ }
+ QueryType::Dispute {
+ payment_id,
+ dispute_id,
+ } => {
+ query_builder
+ .add_filter_clause("payment_id", payment_id)
+ .switch()?;
+ query_builder
+ .add_filter_clause("dispute_id", dispute_id)
+ .switch()?;
+ query_builder
+ .add_filter_in_range_clause(
+ "api_flow",
+ &[
+ Flow::DisputesEvidenceSubmit,
+ Flow::AttachDisputeEvidence,
+ Flow::RetrieveDisputeEvidence,
+ ],
+ )
+ .switch()?;
}
- }
- if let Some(list_api_name) = query_param.api_name_filter {
- query_builder
- .add_filter_in_range_clause("api_flow", &list_api_name)
- .switch()?;
- } else {
- query_builder
- .add_filter_in_range_clause(
- "api_flow",
- &[
- Flow::PaymentsCancel,
- Flow::PaymentsCapture,
- Flow::PaymentsConfirm,
- Flow::PaymentsCreate,
- Flow::PaymentsStart,
- Flow::PaymentsUpdate,
- Flow::RefundsCreate,
- Flow::IncomingWebhookReceive,
- ],
- )
- .switch()?;
}
//TODO!: update the execute_query function to return reports instead of plain errors...
query_builder
diff --git a/crates/api_models/src/analytics/api_event.rs b/crates/api_models/src/analytics/api_event.rs
index 62fe829f01..5fe8e4ff3a 100644
--- a/crates/api_models/src/analytics/api_event.rs
+++ b/crates/api_models/src/analytics/api_event.rs
@@ -8,7 +8,6 @@ use super::{NameDescription, TimeRange};
pub struct ApiLogsRequest {
#[serde(flatten)]
pub query_param: QueryType,
- pub api_name_filter: Option<Vec<String>>,
}
pub enum FilterType {
@@ -27,6 +26,10 @@ pub enum QueryType {
payment_id: String,
refund_id: String,
},
+ Dispute {
+ payment_id: String,
+ dispute_id: String,
+ },
}
#[derive(