Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
chore: address Rust 1.85.0 clippy lints (#7376)
Gaurav Rawat38bb7676be40
diff --git a/crates/hyperswitch_domain_models/src/customer.rs b/crates/hyperswitch_domain_models/src/customer.rsindex 1497c9e362..02c25d722c 100644--- a/crates/hyperswitch_domain_models/src/customer.rs+++ b/crates/hyperswitch_domain_models/src/customer.rs@@ -232,8 +232,8 @@ impl super::behaviour::Conversion for Customer {connector_customer: self.connector_customer,default_payment_method_id: self.default_payment_method_id,updated_by: self.updated_by,- default_billing_address: self.default_billing_address.map(Encryption::from),- default_shipping_address: self.default_shipping_address.map(Encryption::from),+ default_billing_address: self.default_billing_address,+ default_shipping_address: self.default_shipping_address,version: self.version,status: self.status,})diff --git a/crates/hyperswitch_domain_models/src/errors/api_error_response.rs b/crates/hyperswitch_domain_models/src/errors/api_error_response.rsindex 6fa9f9450c..fd8e144f4f 100644--- a/crates/hyperswitch_domain_models/src/errors/api_error_response.rs+++ b/crates/hyperswitch_domain_models/src/errors/api_error_response.rs@@ -344,7 +344,7 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorResponconnector,reason,status_code,- } => AER::ConnectorError(ApiError::new("CE", 0, format!("{code}: {message}"), Some(Extra {connector: Some(connector.clone()), reason: reason.to_owned().map(Into::into), ..Default::default()})), StatusCode::from_u16(*status_code).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)),+ } => AER::ConnectorError(ApiError::new("CE", 0, format!("{code}: {message}"), Some(Extra {connector: Some(connector.clone()), reason: reason.to_owned(), ..Default::default()})), StatusCode::from_u16(*status_code).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)),Self::PaymentAuthorizationFailed { data } => {AER::BadRequest(ApiError::new("CE", 1, "Payment failed during authorization with connector. Retry payment", Some(Extra { data: data.clone(), ..Default::default()})))}diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rsindex 70051bdd50..dea34ecfdb 100644--- a/crates/router/src/compatibility/stripe/payment_intents/types.rs+++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs@@ -283,11 +283,7 @@ impl TryFrom<StripePaymentIntentRequest> for payments::PaymentsRequest {type Error = error_stack::Report<errors::ApiErrorResponse>;fn try_from(item: StripePaymentIntentRequest) -> errors::RouterResult<Self> {let routable_connector: Option<api_enums::RoutableConnectors> =- item.connector.and_then(|v| {- v.into_iter()- .next()- .map(api_enums::RoutableConnectors::from)- });+ item.connector.and_then(|v| v.into_iter().next());let routing = routable_connector.map(|connector| {diff --git a/crates/router/src/compatibility/stripe/setup_intents/types.rs b/crates/router/src/compatibility/stripe/setup_intents/types.rsindex 0b3c6cdd59..3692dc14b9 100644--- a/crates/router/src/compatibility/stripe/setup_intents/types.rs+++ b/crates/router/src/compatibility/stripe/setup_intents/types.rs@@ -179,11 +179,7 @@ impl TryFrom<StripeSetupIntentRequest> for payments::PaymentsRequest {type Error = error_stack::Report<errors::ApiErrorResponse>;fn try_from(item: StripeSetupIntentRequest) -> errors::RouterResult<Self> {let routable_connector: Option<api_enums::RoutableConnectors> =- item.connector.and_then(|v| {- v.into_iter()- .next()- .map(api_enums::RoutableConnectors::from)- });+ item.connector.and_then(|v| v.into_iter().next());let routing = routable_connector.map(|connector| {diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rsindex 157b857052..ee99c7b8ab 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -3755,8 +3755,7 @@ impl ProfileCreateBridge for api::ProfileCreate {collect_billing_details_from_wallet_connector: self.collect_billing_details_from_wallet_connector.or(Some(false)),- outgoing_webhook_custom_http_headers: outgoing_webhook_custom_http_headers- .map(Into::into),+ outgoing_webhook_custom_http_headers,tax_connector_id: self.tax_connector_id,is_tax_connector_enabled: self.is_tax_connector_enabled,always_collect_billing_details_from_wallet_connector: self@@ -3904,8 +3903,7 @@ impl ProfileCreateBridge for api::ProfileCreate {collect_billing_details_from_wallet_connector: self.collect_billing_details_from_wallet_connector_if_required.or(Some(false)),- outgoing_webhook_custom_http_headers: outgoing_webhook_custom_http_headers- .map(Into::into),+ outgoing_webhook_custom_http_headers,always_collect_billing_details_from_wallet_connector: self.always_collect_billing_details_from_wallet_connector,always_collect_shipping_details_from_wallet_connector: self@@ -4211,8 +4209,7 @@ impl ProfileUpdateBridge for api::ProfileUpdate {collect_billing_details_from_wallet_connector: self.collect_billing_details_from_wallet_connector,is_connector_agnostic_mit_enabled: self.is_connector_agnostic_mit_enabled,- outgoing_webhook_custom_http_headers: outgoing_webhook_custom_http_headers- .map(Into::into),+ outgoing_webhook_custom_http_headers,always_collect_billing_details_from_wallet_connector: self.always_collect_billing_details_from_wallet_connector,always_collect_shipping_details_from_wallet_connector: self@@ -4345,8 +4342,7 @@ impl ProfileUpdateBridge for api::ProfileUpdate {collect_billing_details_from_wallet_connector: self.collect_billing_details_from_wallet_connector_if_required,is_connector_agnostic_mit_enabled: self.is_connector_agnostic_mit_enabled,- outgoing_webhook_custom_http_headers: outgoing_webhook_custom_http_headers- .map(Into::into),+ outgoing_webhook_custom_http_headers,order_fulfillment_time: self.order_fulfillment_time.map(|order_fulfillment_time| order_fulfillment_time.into_inner()),diff --git a/crates/router/src/core/customers.rs b/crates/router/src/core/customers.rsindex 353c980c76..6699cf70db 100644--- a/crates/router/src/core/customers.rs+++ b/crates/router/src/core/customers.rs@@ -197,10 +197,8 @@ impl CustomerCreateBridge for customers::CustomerRequest {customer: &'a domain::Customer,) -> errors::CustomerResponse<customers::CustomerResponse> {let address = self.get_address();- let address_details = address.map(api_models::payments::AddressDetails::from);-Ok(services::ApplicationResponse::Json(- customers::CustomerResponse::foreign_from((customer.clone(), address_details)),+ customers::CustomerResponse::foreign_from((customer.clone(), address)),))}}@@ -1265,10 +1263,8 @@ impl CustomerUpdateBridge for customers::CustomerUpdateRequest {customer: &'a domain::Customer,) -> errors::CustomerResponse<customers::CustomerResponse> {let address = self.get_address();- let address_details = address.map(api_models::payments::AddressDetails::from);-Ok(services::ApplicationResponse::Json(- customers::CustomerResponse::foreign_from((customer.clone(), address_details)),+ customers::CustomerResponse::foreign_from((customer.clone(), address)),))}}diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex 452364b654..f30fbda5c5 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -922,7 +922,7 @@ pub async fn create_payment_method_core(merchant_id,key_store,merchant_account.storage_scheme,- payment_method_billing_address.map(Into::into),+ payment_method_billing_address,).await.attach_printable("Failed to add Payment method to DB")?;@@ -1213,7 +1213,7 @@ pub async fn payment_method_intent_create(merchant_id,key_store,merchant_account.storage_scheme,- payment_method_billing_address.map(Into::into),+ payment_method_billing_address,).await.attach_printable("Failed to add Payment method to DB")?;diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex 1f37cc157e..548007825e 100644--- a/crates/router/src/core/payment_methods/cards.rs+++ b/crates/router/src/core/payment_methods/cards.rs@@ -804,7 +804,7 @@ pub async fn skip_locker_call_and_migrate_payment_method(payment_method_issuer: req.payment_method_issuer.clone(),scheme: req.card_network.clone().or(card.scheme.clone()),metadata: payment_method_metadata.map(Secret::new),- payment_method_data: payment_method_data_encrypted.map(Into::into),+ payment_method_data: payment_method_data_encrypted,connector_mandate_details: connector_mandate_details.clone(),customer_acceptance: None,client_secret: None,@@ -823,7 +823,7 @@ pub async fn skip_locker_call_and_migrate_payment_method(created_at: current_time,last_modified: current_time,last_used_at: current_time,- payment_method_billing_address: payment_method_billing_address.map(Into::into),+ payment_method_billing_address,updated_by: None,version: domain::consts::API_VERSION,network_token_requestor_reference_id: None,@@ -1074,7 +1074,7 @@ pub async fn get_client_secret_or_add_payment_method(Some(enums::PaymentMethodStatus::AwaitingData),None,merchant_account.storage_scheme,- payment_method_billing_address.map(Into::into),+ payment_method_billing_address,None,None,None,@@ -1167,7 +1167,7 @@ pub async fn get_client_secret_or_add_payment_method_for_migration(Some(enums::PaymentMethodStatus::AwaitingData),None,merchant_account.storage_scheme,- payment_method_billing_address.map(Into::into),+ payment_method_billing_address,None,None,None,@@ -1687,7 +1687,7 @@ pub async fn add_payment_method(connector_mandate_details,req.network_transaction_id.clone(),merchant_account.storage_scheme,- payment_method_billing_address.map(Into::into),+ payment_method_billing_address,None,None,None,@@ -1949,7 +1949,7 @@ pub async fn save_migration_payment_method(connector_mandate_details.clone(),network_transaction_id.clone(),merchant_account.storage_scheme,- payment_method_billing_address.map(Into::into),+ payment_method_billing_address,None,None,None,diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rsindex 2dc118a60f..d95e92115a 100644--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs@@ -283,7 +283,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>payment_intent.metadata = request.metadata.clone().or(payment_intent.metadata);// The operation merges mandate data from both request and payment_attempt- let setup_mandate = mandate_data.map(Into::into);+ let setup_mandate = mandate_data;let mandate_details_present =payment_attempt.mandate_details.is_some() || request.mandate_data.is_some();diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 6bb923f82e..662c02e523 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -19,7 +19,7 @@ use diesel_models::{};use error_stack::{self, ResultExt};use hyperswitch_domain_models::{- mandates::{MandateData, MandateDetails},+ mandates::MandateDetails,payments::{payment_attempt::PaymentAttempt, payment_intent::CustomerData,FromRequestEncryptablePaymentIntent,@@ -494,7 +494,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>.transpose()?;// The operation merges mandate data from both request and payment_attempt- let setup_mandate = mandate_data.map(MandateData::from);+ let setup_mandate = mandate_data;let surcharge_details = request.surcharge_details.map(|request_surcharge_details| {payments::types::SurchargeDetails::from((&request_surcharge_details, &payment_attempt))diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rsindex e7cc8a41b8..498bda53f2 100644--- a/crates/router/src/core/payments/operations/payment_update.rs+++ b/crates/router/src/core/payments/operations/payment_update.rs@@ -421,7 +421,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>.transpose()?;// The operation merges mandate data from both request and payment_attempt- let setup_mandate = mandate_data.map(Into::into);+ let setup_mandate = mandate_data;let mandate_details_present =payment_attempt.mandate_details.is_some() || request.mandate_data.is_some();helpers::validate_mandate_data_and_future_usage(diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rsindex 3baf72901e..577c7ba53e 100644--- a/crates/router/src/core/payments/tokenization.rs+++ b/crates/router/src/core/payments/tokenization.rs@@ -394,21 +394,20 @@ wheremerchant_id,pm_metadata,customer_acceptance,- pm_data_encrypted.map(Into::into),+ pm_data_encrypted,key_store,None,pm_status,network_transaction_id,merchant_account.storage_scheme,- encrypted_payment_method_billing_address- .map(Into::into),+ encrypted_payment_method_billing_address,resp.card.and_then(|card| {card.card_network.map(|card_network| card_network.to_string())}),network_token_requestor_ref_id,network_token_locker_id,- pm_network_token_data_encrypted.map(Into::into),+ pm_network_token_data_encrypted,).await} else {@@ -513,14 +512,13 @@ wheremerchant_id,resp.metadata.clone().map(|val| val.expose()),customer_acceptance,- pm_data_encrypted.map(Into::into),+ pm_data_encrypted,key_store,None,pm_status,network_transaction_id,merchant_account.storage_scheme,- encrypted_payment_method_billing_address- .map(Into::into),+ encrypted_payment_method_billing_address,resp.card.and_then(|card| {card.card_network.map(|card_network| {card_network.to_string()@@ -528,7 +526,7 @@ where}),network_token_requestor_ref_id,network_token_locker_id,- pm_network_token_data_encrypted.map(Into::into),+ pm_network_token_data_encrypted,).await} else {@@ -733,20 +731,20 @@ wheremerchant_id,pm_metadata,customer_acceptance,- pm_data_encrypted.map(Into::into),+ pm_data_encrypted,key_store,None,pm_status,network_transaction_id,merchant_account.storage_scheme,- encrypted_payment_method_billing_address.map(Into::into),+ encrypted_payment_method_billing_address,resp.card.and_then(|card| {card.card_network.map(|card_network| card_network.to_string())}),network_token_requestor_ref_id,network_token_locker_id,- pm_network_token_data_encrypted.map(Into::into),+ pm_network_token_data_encrypted,).await?;};diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 34c4c76c2e..c4aa8d2d49 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -4050,7 +4050,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthorizcurrency: payment_data.currency,browser_info,email: payment_data.email,- payment_method_data: payment_data.payment_method_data.map(From::from),+ payment_method_data: payment_data.payment_method_data,connector_transaction_id: payment_data.payment_attempt.get_connector_payment_id()@@ -4144,7 +4144,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProcelet amount = payment_data.payment_attempt.get_total_amount();Ok(Self {- payment_method_data: payment_method_data.map(From::from),+ payment_method_data,email: payment_data.email,currency: Some(payment_data.currency),amount: Some(amount.get_amount_as_i64()), // need to change this once we move to connector modulediff --git a/crates/router/src/core/payouts/helpers.rs b/crates/router/src/core/payouts/helpers.rsindex 7eb7925017..332137b6a1 100644--- a/crates/router/src/core/payouts/helpers.rs+++ b/crates/router/src/core/payouts/helpers.rs@@ -556,7 +556,7 @@ pub async fn save_payout_data_to_locker(merchant_account.get_id(),None,None,- card_details_encrypted.clone().map(Into::into),+ card_details_encrypted.clone(),key_store,connector_mandate_details,None,diff --git a/crates/router/src/services/authorization/roles.rs b/crates/router/src/services/authorization/roles.rsindex c6b6946d15..995975d12e 100644--- a/crates/router/src/services/authorization/roles.rs+++ b/crates/router/src/services/authorization/roles.rs@@ -165,7 +165,7 @@ impl From<diesel_models::role::Role> for RoleInfo {Self {role_id: role.role_id,role_name: role.role_name,- groups: role.groups.into_iter().map(Into::into).collect(),+ groups: role.groups,scope: role.scope,entity_type: role.entity_type,is_invitable: true,diff --git a/crates/router/src/types/api/admin.rs b/crates/router/src/types/api/admin.rsindex 67e8990e11..8c720875f1 100644--- a/crates/router/src/types/api/admin.rs+++ b/crates/router/src/types/api/admin.rs@@ -411,7 +411,7 @@ pub async fn create_profile_from_merchant_account(always_collect_shipping_details_from_wallet_connector: request.always_collect_shipping_details_from_wallet_connector.or(Some(false)),- outgoing_webhook_custom_http_headers: outgoing_webhook_custom_http_headers.map(Into::into),+ outgoing_webhook_custom_http_headers,tax_connector_id: request.tax_connector_id,is_tax_connector_enabled: request.is_tax_connector_enabled,dynamic_routing_algorithm: None,