mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-31 01:57:45 +08:00
refactor: create separate struct for surcharge details response (#3027)
This commit is contained in:
@ -16,7 +16,6 @@ use crate::{
|
||||
admin, disputes,
|
||||
enums::{self as api_enums},
|
||||
ephemeral_key::EphemeralKeyCreateResponse,
|
||||
payment_methods::{Surcharge, SurchargeDetailsResponse},
|
||||
refunds,
|
||||
};
|
||||
|
||||
@ -340,17 +339,6 @@ impl RequestSurchargeDetails {
|
||||
pub fn is_surcharge_zero(&self) -> bool {
|
||||
self.surcharge_amount == 0 && self.tax_amount.unwrap_or(0) == 0
|
||||
}
|
||||
pub fn get_surcharge_details_object(&self, original_amount: i64) -> SurchargeDetailsResponse {
|
||||
let surcharge_amount = self.surcharge_amount;
|
||||
let tax_on_surcharge_amount = self.tax_amount.unwrap_or(0);
|
||||
SurchargeDetailsResponse {
|
||||
surcharge: Surcharge::Fixed(self.surcharge_amount),
|
||||
tax_on_surcharge: None,
|
||||
surcharge_amount,
|
||||
tax_on_surcharge_amount,
|
||||
final_amount: original_amount + surcharge_amount + tax_on_surcharge_amount,
|
||||
}
|
||||
}
|
||||
pub fn get_total_surcharge_amount(&self) -> i64 {
|
||||
self.surcharge_amount + self.tax_amount.unwrap_or(0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user