mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
refactor(connector): added amount conversion framework for klarna and change type of amount to MinorUnit for OrderDetailsWithAmount (#4979)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: swangi-kumari <swangi.12015941@lpu.in> Co-authored-by: Swangi Kumari <85639103+swangi-kumari@users.noreply.github.com>
This commit is contained in:
@ -7,7 +7,8 @@ pub mod authentication;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
fmt::Display,
|
||||
ops::{Add, Sub},
|
||||
iter::Sum,
|
||||
ops::{Add, Mul, Sub},
|
||||
primitive::i64,
|
||||
str::FromStr,
|
||||
};
|
||||
@ -483,6 +484,20 @@ impl Sub for MinorUnit {
|
||||
}
|
||||
}
|
||||
|
||||
impl Mul<u16> for MinorUnit {
|
||||
type Output = Self;
|
||||
|
||||
fn mul(self, a2: u16) -> Self::Output {
|
||||
Self(self.0 * i64::from(a2))
|
||||
}
|
||||
}
|
||||
|
||||
impl Sum for MinorUnit {
|
||||
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
|
||||
iter.fold(Self(0), |a, b| a + b)
|
||||
}
|
||||
}
|
||||
|
||||
/// Connector specific types to send
|
||||
|
||||
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, PartialEq)]
|
||||
|
||||
Reference in New Issue
Block a user