refactor(connector): [noon] update and add recommended fields (#2381)

Co-authored-by: Arjun Karthik <m.arjunkarthik@gmail.com>
This commit is contained in:
SamraatBansal
2023-10-12 17:17:58 +05:30
committed by GitHub
parent 53d7604603
commit 751f16eaee
2 changed files with 62 additions and 2 deletions

View File

@ -283,6 +283,7 @@ pub trait PaymentsAuthorizeRequestData {
fn get_payment_method_type(&self) -> Result<diesel_models::enums::PaymentMethodType, Error>;
fn get_connector_mandate_id(&self) -> Result<String, Error>;
fn get_complete_authorize_url(&self) -> Result<String, Error>;
fn get_ip_address_as_optional(&self) -> Option<Secret<String, IpAddress>>;
}
impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {
@ -370,6 +371,13 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {
self.connector_mandate_id()
.ok_or_else(missing_field_err("connector_mandate_id"))
}
fn get_ip_address_as_optional(&self) -> Option<Secret<String, IpAddress>> {
self.browser_info.clone().and_then(|browser_info| {
browser_info
.ip_address
.map(|ip| Secret::new(ip.to_string()))
})
}
}
pub trait ConnectorCustomerData {