feat(connector): [Bluesnap] Add dispute webhooks support (#2053)

This commit is contained in:
SamraatBansal
2023-09-01 14:05:36 +05:30
committed by GitHub
parent 38ab6e54f1
commit f8410b5b2a
4 changed files with 117 additions and 14 deletions

View File

@ -1,4 +1,4 @@
use std::num::TryFromIntError;
use std::num::{ParseFloatError, TryFromIntError};
use router_derive;
use serde::{Deserialize, Serialize};
@ -342,6 +342,19 @@ impl Currency {
Ok(amount)
}
///Convert the higher decimal amount to its base absolute units
pub fn to_currency_lower_unit(&self, amount: String) -> Result<String, ParseFloatError> {
let amount_f64 = amount.parse::<f64>()?;
let amount_string = if self.is_zero_decimal_currency() {
amount_f64
} else if self.is_three_decimal_currency() {
amount_f64 * 1000.00
} else {
amount_f64 * 100.00
};
Ok(amount_string.to_string())
}
/// Convert the amount to its base denomination based on Currency and check for zero decimal currency and return String
/// Paypal Connector accepts Zero and Two decimal currency but not three decimal and it should be updated as required for 3 decimal currencies.
/// Paypal Ref - https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/