mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 11:06:50 +08:00
feat(connector): add authorize, capture, void, psync, refund, rsync for Forte connector (#955)
Co-authored-by: Arjun Karthik <m.arjunkarthik@gmail.com> Co-authored-by: Arun Raj M <jarnura47@gmail.com>
This commit is contained in:
@ -325,6 +325,14 @@ static CARD_REGEX: Lazy<HashMap<CardIssuer, Result<Regex, regex::Error>>> = Lazy
|
||||
CardIssuer::Maestro,
|
||||
Regex::new(r"^(5018|5020|5038|5893|6304|6759|6761|6762|6763)[0-9]{8,15}$"),
|
||||
);
|
||||
map.insert(
|
||||
CardIssuer::DinersClub,
|
||||
Regex::new(r"^3(?:0[0-5]|[68][0-9])[0-9]{11}$"),
|
||||
);
|
||||
map.insert(
|
||||
CardIssuer::JCB,
|
||||
Regex::new(r"^(3(?:088|096|112|158|337|5(?:2[89]|[3-8][0-9]))\d{12})$"),
|
||||
);
|
||||
map
|
||||
});
|
||||
|
||||
@ -335,6 +343,8 @@ pub enum CardIssuer {
|
||||
Maestro,
|
||||
Visa,
|
||||
Discover,
|
||||
DinersClub,
|
||||
JCB,
|
||||
}
|
||||
|
||||
pub trait CardData {
|
||||
@ -630,6 +640,14 @@ pub fn to_currency_base_unit(
|
||||
amount: i64,
|
||||
currency: storage_models::enums::Currency,
|
||||
) -> Result<String, error_stack::Report<errors::ConnectorError>> {
|
||||
let amount_f64 = to_currency_base_unit_asf64(amount, currency)?;
|
||||
Ok(format!("{amount_f64:.2}"))
|
||||
}
|
||||
|
||||
pub fn to_currency_base_unit_asf64(
|
||||
amount: i64,
|
||||
currency: storage_models::enums::Currency,
|
||||
) -> Result<f64, error_stack::Report<errors::ConnectorError>> {
|
||||
let amount_u32 = u32::try_from(amount)
|
||||
.into_report()
|
||||
.change_context(errors::ConnectorError::RequestEncodingFailed)?;
|
||||
@ -642,7 +660,7 @@ pub fn to_currency_base_unit(
|
||||
| storage_models::enums::Currency::OMR => amount_f64 / 1000.00,
|
||||
_ => amount_f64 / 100.00,
|
||||
};
|
||||
Ok(format!("{amount:.2}"))
|
||||
Ok(amount)
|
||||
}
|
||||
|
||||
pub fn str_to_f32<S>(value: &str, serializer: S) -> Result<S::Ok, S::Error>
|
||||
|
||||
Reference in New Issue
Block a user