refactor: add surcharge_applicable to payment_intent and remove surcharge_metadata from payment_attempt (#2642)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Hrithikesh
2023-10-19 19:26:00 +05:30
committed by GitHub
parent 41b7742b54
commit e5fbaae0d4
17 changed files with 72 additions and 65 deletions

View File

@ -345,6 +345,23 @@ pub struct SurchargeMetadata {
pub surcharge_results: HashMap<String, SurchargeDetailsResponse>,
}
impl SurchargeMetadata {
pub fn get_key_for_surcharge_details_hash_map(
payment_method: &common_enums::PaymentMethod,
payment_method_type: &common_enums::PaymentMethodType,
card_network: Option<&common_enums::CardNetwork>,
) -> String {
if let Some(card_network) = card_network {
format!(
"{}_{}_{}",
payment_method, payment_method_type, card_network
)
} else {
format!("{}_{}", payment_method, payment_method_type)
}
}
}
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
#[serde(rename_all = "snake_case", tag = "type", content = "value")]
pub enum Surcharge {