From ea100cf990cf800603258dc0c63b695374d3904f Mon Sep 17 00:00:00 2001 From: Shivansh Bhatnagar Date: Mon, 23 Oct 2023 14:41:08 +0530 Subject: [PATCH] Some Minor Fixes on Formatting and Typos --- crates/router/src/connector/rapyd.rs | 8 +---- .../src/connector/rapyd/transformers.rs | 29 +++++++++++++------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/crates/router/src/connector/rapyd.rs b/crates/router/src/connector/rapyd.rs index 5c04d271d54a..e1b8251ea478 100644 --- a/crates/router/src/connector/rapyd.rs +++ b/crates/router/src/connector/rapyd.rs @@ -493,13 +493,7 @@ impl &self, req: &types::PaymentsCaptureRouterData, ) -> CustomResult, errors::ConnectorError> { - let connector_router_data = rapyd::RapydRouterData::try_from(( - &self.get_currency_unit(), - req.request.currency, - req.request.capture_method, - req, - ))?; - let req_obj = rapyd::CaptureRequest::try_from(&connector_router_data)?; + let req_obj = rapyd::CaptureRequest::try_from(&req)?; let rapyd_req = types::RequestBody::log_and_get_request_body( &req_obj, utils::Encode::::encode_to_string_of_json, diff --git a/crates/router/src/connector/rapyd/transformers.rs b/crates/router/src/connector/rapyd/transformers.rs index 9bf6e243c688..2c716523cfc9 100644 --- a/crates/router/src/connector/rapyd/transformers.rs +++ b/crates/router/src/connector/rapyd/transformers.rs @@ -25,7 +25,7 @@ impl types::storage::enums::Currency, i64, T, - )> for ZenRouterData + )> for RapydRouterData { type Error = error_stack::Report; fn try_from( @@ -36,7 +36,7 @@ impl T, ), ) -> Result { - let amount = utils::get_amount_as_string(currency_unit, amount, currency)?; + let amount = item.amount.to_owned(); Ok(Self { amount, router_data: item, @@ -102,10 +102,15 @@ pub struct RapydWallet { impl TryFrom<&RapydRouterData<&types::PaymentsAuthorizeRouterData>> for RapydPaymentsRequest { type Error = error_stack::Report; - fn try_from(item: &RapydRouterData<&types::PaymentsAuthorizeRouterData>) -> Result { - let (capture, payment_method_options) = match item.payment_method { + fn try_from( + item: &RapydRouterData<&types::PaymentsAuthorizeRouterData>, + ) -> Result { + let (capture, payment_method_options) = match item.router_data.payment_method { diesel_models::enums::PaymentMethod::Card => { - let three_ds_enabled = matches!(item.auth_type, enums::AuthenticationType::ThreeDs); + let three_ds_enabled = matches!( + item.router_data.auth_type, + enums::AuthenticationType::ThreeDs + ); let payment_method_options = PaymentMethodOptions { three_ds: three_ds_enabled, }; @@ -179,9 +184,9 @@ pub struct RapydAuthType { pub secret_key: Secret, } -impl TryFrom<&RapydRouterData<&types::ConnectorAuthType>> for RapydAuthType { +impl TryFrom<&types::ConnectorAuthType> for RapydAuthType { type Error = error_stack::Report; - fn try_from(auth_type: &RapydRouterData<&types::ConnectorAuthType>) -> Result { + fn try_from(auth_type: &types::ConnectorAuthType) -> Result { if let types::ConnectorAuthType::BodyKey { api_key, key1 } = auth_type { Ok(Self { access_key: api_key.to_owned(), @@ -311,7 +316,11 @@ impl TryFrom<&RapydRouterData<&types::RefundsRouterData>> for RapydRefundR type Error = error_stack::Report; fn try_from(item: &RapydRouterData<&types::RefundsRouterData>) -> Result { Ok(Self { - payment: item.router_data.request.connector_transaction_id.to_string(), + payment: item + .router_data + .request + .connector_transaction_id + .to_string(), amount: Some(item.router_data.request.refund_amount), currency: Some(item.router_data.request.currency), }) @@ -413,7 +422,9 @@ pub struct CaptureRequest { impl TryFrom<&RapydRouterData<&types::PaymentsCaptureRouterData>> for CaptureRequest { type Error = error_stack::Report; - fn try_from(item: &RapydRouterData<&types::PaymentsCaptureRouterData>) -> Result { + fn try_from( + item: &RapydRouterData<&types::PaymentsCaptureRouterData>, + ) -> Result { Ok(Self { amount: Some(item.router_data.request.amount_to_capture), receipt_email: None,