feat(connector): [Trustpay] add webhooks (payment and refund events) (#746)

Co-authored-by: Sangamesh <sangamesh.kulkarni@juspay.in>
Co-authored-by: sai harsha <sai.harsha@sai.harsha-MacBookPro>
Co-authored-by: Arun Raj M <jarnura47@gmail.com>
This commit is contained in:
saiharsha-juspay
2023-03-20 11:32:23 +05:30
committed by GitHub
parent f27732a6e5
commit 853dfa1635
30 changed files with 398 additions and 86 deletions

View File

@ -487,3 +487,41 @@ where
})?;
serializer.serialize_f64(float_value)
}
pub fn collect_values_by_removing_signature(
value: &serde_json::Value,
signature: &String,
) -> Vec<String> {
match value {
serde_json::Value::Null => vec!["null".to_owned()],
serde_json::Value::Bool(b) => vec![b.to_string()],
serde_json::Value::Number(n) => match n.as_f64() {
Some(f) => vec![format!("{:.2}", f)],
None => vec![n.to_string()],
},
serde_json::Value::String(s) => {
if signature == s {
vec![]
} else {
vec![s.clone()]
}
}
serde_json::Value::Array(arr) => arr
.iter()
.flat_map(|v| collect_values_by_removing_signature(v, signature))
.collect(),
serde_json::Value::Object(obj) => obj
.values()
.flat_map(|v| collect_values_by_removing_signature(v, signature))
.collect(),
}
}
pub fn collect_and_sort_values_by_removing_signature(
value: &serde_json::Value,
signature: &String,
) -> Vec<String> {
let mut values = collect_values_by_removing_signature(value, signature);
values.sort();
values
}