feat(debit_routing): add debit_routing_savings in analytics payment attempt#8519
feat(debit_routing): add debit_routing_savings in analytics payment attempt#8519Gnanasundari24 merged 10 commits intomainfrom
debit_routing_savings in analytics payment attempt#8519Conversation
…it-routing/analytics/add-savings
| self, | ||
| Self::PaymentProcessedAmount | ||
| | Self::AvgTicketSize | ||
| // add here New Metric |
There was a problem hiding this comment.
Can add Self::DebitRouting here and can remove this comment
This is for the forex conversion of other currencies to USD for debit_routing_savings
| } | ||
|
|
||
| pub fn set_debit_routing_savings(&mut self, debit_routing_savings: Option<&MinorUnit>) { | ||
| self.debit_routing_savings = debit_routing_savings.copied(); |
There was a problem hiding this comment.
Can you explain why we have used .copied() here
There was a problem hiding this comment.
debit_routing_savings is an optional reference: Option<&MinorUnit>
self.debit_routing_savings is of type Option, not a reference
| pub fn get_debit_routing_savings(&self) -> Option<&MinorUnit> { | ||
| match self { | ||
| Self::ResponseUpdate { | ||
| debit_routing_savings, | ||
| .. | ||
| } => debit_routing_savings.as_ref(), | ||
| Self::Update { .. } | ||
| | Self::UpdateTrackers { .. } | ||
| | Self::AuthenticationTypeUpdate { .. } | ||
| | Self::ConfirmUpdate { .. } | ||
| | Self::RejectUpdate { .. } | ||
| | Self::BlocklistUpdate { .. } | ||
| | Self::PaymentMethodDetailsUpdate { .. } | ||
| | Self::ConnectorMandateDetailUpdate { .. } | ||
| | Self::VoidUpdate { .. } | ||
| | Self::UnresolvedResponseUpdate { .. } | ||
| | Self::StatusUpdate { .. } | ||
| | Self::ErrorUpdate { .. } | ||
| | Self::CaptureUpdate { .. } | ||
| | Self::AmountToCaptureUpdate { .. } | ||
| | Self::PreprocessingUpdate { .. } | ||
| | Self::ConnectorResponse { .. } | ||
| | Self::IncrementalAuthorizationAmountUpdate { .. } | ||
| | Self::AuthenticationUpdate { .. } | ||
| | Self::ManualUpdate { .. } | ||
| | Self::PostSessionTokensUpdate { .. } => None, | ||
| } | ||
| } |
There was a problem hiding this comment.
Can this be done in any simpler way?
|
You might have to create another metric, say The changes can be similar to |
| vec![connector_data.clone()], | ||
| debit_routing_output.get_co_badged_card_networks(), | ||
| open_router::CoBadgedCardNetworks( | ||
| debit_routing_output.co_badged_card_networks_info.clone(), |
There was a problem hiding this comment.
debit_routing_output.co_badged_card_networks_info can be a domain type
| )?; | ||
|
|
||
| let debit_routing_savings = payment_data.get_payment_method_data().and_then(|data| { | ||
| payments::helpers::get_debit_routing_savings_amount( |
There was a problem hiding this comment.
get_debit_routing_savings_amount can be a impl based fn on get_payment_method_data
| }) | ||
| } | ||
|
|
||
| pub fn extract_saving_percentage( |
There was a problem hiding this comment.
can move this to impl based fn as well
| "Calculating debit routing saving amount" | ||
| ); | ||
|
|
||
| let savings_float = (net_amount * (saving_percentage / 100.0)).round(); |
There was a problem hiding this comment.
can we somehow avoid two step conversion?
…it-routing/analytics/add-savings
…com/juspay/hyperswitch into debit-routing/analytics/add-savings
| self, | ||
| Self::PaymentProcessedAmount | ||
| | Self::AvgTicketSize | ||
| | Self::DebitRouting |
There was a problem hiding this comment.
Add the SessionizedDebitRouting metric here as well
(To enable the currency conversion from other currencies to USD for debit_routing_savings)
c0a1a9a
prasunna09
left a comment
There was a problem hiding this comment.
Payment method changes looks good to me!
Description
This pull request introduces a new feature to track and analyze debit routing savings and integrates it across multiple components of the analytics system. It also refactors the handling of co-badged card networks to provide additional details, such as saving percentages. Below is a breakdown of the most important changes grouped by theme:
Debit Routing Analytics Integration:
debit_routing_savingsto thepayment_attempt_queue,payment_attempts, andpayment_attempt_mvtables in ClickHouse for tracking debit routing savings.PaymentMetricsAccumulatorstruct to include a newDebitRoutingAccumulator, which tracks transaction counts and savings amounts. Implemented the necessary methods for metric collection and aggregation.PaymentMetrics::DebitRoutingenum variant and its corresponding implementation to load metrics, process data, and convert savings to USD.Additional Changes
Motivation and Context
How did you test it?
-> Enable debit routing for a profile
-> Configure adyen connector with local debit networks enabled
-> Make some debit routing payments
-> Payment FIlters
-> Payment metric that gives total debit routed txn and savings
-> Payment metrics that gives savings per txn
Checklist
cargo +nightly fmt --allcargo clippy