diff --git a/crates/router/src/connector/netcetera.rs b/crates/router/src/connector/netcetera.rs index 194687b6260a..4315739dea5f 100644 --- a/crates/router/src/connector/netcetera.rs +++ b/crates/router/src/connector/netcetera.rs @@ -280,7 +280,7 @@ impl req: &types::authentication::PreAuthNRouterData, _connectors: &settings::Connectors, ) -> CustomResult { - let connector_router_data = NetceteraRouterData::try_from((MinorUnit::zero(), req))?; + let connector_router_data = NetceteraRouterData::try_from((Some(MinorUnit::zero()), req))?; let req_obj = netcetera::NetceteraPreAuthenticationRequest::try_from(&connector_router_data)?; Ok(RequestContent::Json(Box::new(req_obj))) @@ -378,18 +378,22 @@ impl req: &types::authentication::ConnectorAuthenticationRouterData, _connectors: &settings::Connectors, ) -> CustomResult { - let currency = - req.request - .currency - .ok_or(errors::ConnectorError::MissingRequiredField { - field_name: "currency", - })?; - let amount = req.request.amount.map(MinorUnit::new).ok_or( - errors::ConnectorError::MissingRequiredField { - field_name: "amount", - }, - )?; - let amount = utils::convert_amount(self.amount_convertor, amount, currency)?; + let amount = match req.request.amount { + Some(amount) => { + let currency = + req.request + .currency + .ok_or(errors::ConnectorError::MissingRequiredField { + field_name: "currency", + })?; + Some(utils::convert_amount( + self.amount_convertor, + MinorUnit::new(amount), + currency, + )?) + } + None => None, + }; let connector_router_data = NetceteraRouterData::try_from((amount, req))?; let req_obj = netcetera::NetceteraAuthenticationRequest::try_from(&connector_router_data); Ok(RequestContent::Json(Box::new(req_obj?))) diff --git a/crates/router/src/connector/netcetera/transformers.rs b/crates/router/src/connector/netcetera/transformers.rs index 8c6688fc43f4..c1e7660c3515 100644 --- a/crates/router/src/connector/netcetera/transformers.rs +++ b/crates/router/src/connector/netcetera/transformers.rs @@ -13,13 +13,13 @@ use crate::{ //TODO: Fill the struct with respective fields pub struct NetceteraRouterData { - pub amount: MinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc. + pub amount: Option, // The type of amount that a connector accepts, for example, String, i64, f64, etc. pub router_data: T, } -impl TryFrom<(MinorUnit, T)> for NetceteraRouterData { +impl TryFrom<(Option, T)> for NetceteraRouterData { type Error = error_stack::Report; - fn try_from((amount, router_data): (MinorUnit, T)) -> Result { + fn try_from((amount, router_data): (Option, T)) -> Result { Ok(Self { amount, router_data, @@ -470,7 +470,7 @@ impl TryFrom<&NetceteraRouterData<&types::authentication::ConnectorAuthenticatio let purchase = netcetera_types::Purchase { purchase_instal_data: None, merchant_risk_indicator: None, - purchase_amount: Some(item.amount), + purchase_amount: item.amount, purchase_currency: currency.iso_4217().to_string(), purchase_exponent: currency.number_of_digits_after_decimal_point(), purchase_date: Some(