mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
feat(connector): [Bluesnap] add cards 3DS support (#1057)
Co-authored-by: Jagan Elavarasan <jaganelavarasan@gmail.com> Co-authored-by: Kartikeya Hegde <karthikey.hegde@juspay.in>
This commit is contained in:
@ -119,3 +119,34 @@ impl<E> ConnectorResponseExt
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert the amount to its base denomination based on Currency and return String
|
||||
pub fn to_currency_base_unit(
|
||||
amount: i64,
|
||||
currency: storage_models::enums::Currency,
|
||||
) -> Result<String, error_stack::Report<errors::ValidationError>> {
|
||||
let amount_f64 = to_currency_base_unit_asf64(amount, currency)?;
|
||||
Ok(format!("{amount_f64:.2}"))
|
||||
}
|
||||
|
||||
/// Convert the amount to its base denomination based on Currency and return f64
|
||||
pub fn to_currency_base_unit_asf64(
|
||||
amount: i64,
|
||||
currency: storage_models::enums::Currency,
|
||||
) -> Result<f64, error_stack::Report<errors::ValidationError>> {
|
||||
let amount_u32 = u32::try_from(amount).into_report().change_context(
|
||||
errors::ValidationError::InvalidValue {
|
||||
message: amount.to_string(),
|
||||
},
|
||||
)?;
|
||||
let amount_f64 = f64::from(amount_u32);
|
||||
let amount = match currency {
|
||||
storage_models::enums::Currency::JPY | storage_models::enums::Currency::KRW => amount_f64,
|
||||
storage_models::enums::Currency::BHD
|
||||
| storage_models::enums::Currency::JOD
|
||||
| storage_models::enums::Currency::KWD
|
||||
| storage_models::enums::Currency::OMR => amount_f64 / 1000.00,
|
||||
_ => amount_f64 / 100.00,
|
||||
};
|
||||
Ok(amount)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user