mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 17:47:54 +08:00
feat(router): add mertics to apple pay flow (#2235)
Co-authored-by: ItsMeShashank <shashank.attarde@juspay.in>
This commit is contained in:
@ -5,7 +5,7 @@ pub mod ext_traits;
|
||||
#[cfg(feature = "kv_store")]
|
||||
pub mod storage_partitioning;
|
||||
|
||||
use api_models::{payments, webhooks};
|
||||
use api_models::{enums, payments, webhooks};
|
||||
use base64::Engine;
|
||||
pub use common_utils::{
|
||||
crypto,
|
||||
@ -530,3 +530,104 @@ impl CustomerAddress for api_models::customers::CustomerRequest {
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_apple_pay_flow_metrics(
|
||||
apple_pay_flow: &Option<enums::ApplePayFlow>,
|
||||
connector: Option<String>,
|
||||
merchant_id: String,
|
||||
) {
|
||||
if let Some(flow) = apple_pay_flow {
|
||||
match flow {
|
||||
enums::ApplePayFlow::Simplified => metrics::APPLE_PAY_SIMPLIFIED_FLOW.add(
|
||||
&metrics::CONTEXT,
|
||||
1,
|
||||
&[
|
||||
metrics::request::add_attributes(
|
||||
"connector",
|
||||
connector.to_owned().unwrap_or("null".to_string()),
|
||||
),
|
||||
metrics::request::add_attributes("merchant_id", merchant_id.to_owned()),
|
||||
],
|
||||
),
|
||||
enums::ApplePayFlow::Manual => metrics::APPLE_PAY_MANUAL_FLOW.add(
|
||||
&metrics::CONTEXT,
|
||||
1,
|
||||
&[
|
||||
metrics::request::add_attributes(
|
||||
"connector",
|
||||
connector.to_owned().unwrap_or("null".to_string()),
|
||||
),
|
||||
metrics::request::add_attributes("merchant_id", merchant_id.to_owned()),
|
||||
],
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_apple_pay_payment_status_metrics(
|
||||
payment_attempt_status: enums::AttemptStatus,
|
||||
apple_pay_flow: Option<enums::ApplePayFlow>,
|
||||
connector: Option<String>,
|
||||
merchant_id: String,
|
||||
) {
|
||||
if payment_attempt_status == enums::AttemptStatus::Charged {
|
||||
if let Some(flow) = apple_pay_flow {
|
||||
match flow {
|
||||
enums::ApplePayFlow::Simplified => {
|
||||
metrics::APPLE_PAY_SIMPLIFIED_FLOW_SUCCESSFUL_PAYMENT.add(
|
||||
&metrics::CONTEXT,
|
||||
1,
|
||||
&[
|
||||
metrics::request::add_attributes(
|
||||
"connector",
|
||||
connector.to_owned().unwrap_or("null".to_string()),
|
||||
),
|
||||
metrics::request::add_attributes("merchant_id", merchant_id.to_owned()),
|
||||
],
|
||||
)
|
||||
}
|
||||
enums::ApplePayFlow::Manual => metrics::APPLE_PAY_MANUAL_FLOW_SUCCESSFUL_PAYMENT
|
||||
.add(
|
||||
&metrics::CONTEXT,
|
||||
1,
|
||||
&[
|
||||
metrics::request::add_attributes(
|
||||
"connector",
|
||||
connector.to_owned().unwrap_or("null".to_string()),
|
||||
),
|
||||
metrics::request::add_attributes("merchant_id", merchant_id.to_owned()),
|
||||
],
|
||||
),
|
||||
}
|
||||
}
|
||||
} else if payment_attempt_status == enums::AttemptStatus::Failure {
|
||||
if let Some(flow) = apple_pay_flow {
|
||||
match flow {
|
||||
enums::ApplePayFlow::Simplified => {
|
||||
metrics::APPLE_PAY_SIMPLIFIED_FLOW_FAILED_PAYMENT.add(
|
||||
&metrics::CONTEXT,
|
||||
1,
|
||||
&[
|
||||
metrics::request::add_attributes(
|
||||
"connector",
|
||||
connector.to_owned().unwrap_or("null".to_string()),
|
||||
),
|
||||
metrics::request::add_attributes("merchant_id", merchant_id.to_owned()),
|
||||
],
|
||||
)
|
||||
}
|
||||
enums::ApplePayFlow::Manual => metrics::APPLE_PAY_MANUAL_FLOW_FAILED_PAYMENT.add(
|
||||
&metrics::CONTEXT,
|
||||
1,
|
||||
&[
|
||||
metrics::request::add_attributes(
|
||||
"connector",
|
||||
connector.to_owned().unwrap_or("null".to_string()),
|
||||
),
|
||||
metrics::request::add_attributes("merchant_id", merchant_id.to_owned()),
|
||||
],
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user