chore: add lints in workspace cargo config (#223)

This commit is contained in:
Sanchith Hegde
2022-12-24 14:28:03 +05:30
committed by GitHub
parent a996f0d89b
commit e7579a4819
95 changed files with 443 additions and 383 deletions

View File

@ -38,7 +38,7 @@ pub trait Feature<F, T> {
storage_scheme: enums::MerchantStorageScheme,
) -> RouterResult<Self>
where
Self: std::marker::Sized,
Self: Sized,
F: Clone,
dyn api::Connector: services::ConnectorIntegration<F, T, types::PaymentsResponseData>;
}

View File

@ -13,7 +13,6 @@ use crate::{
types::{
self, api,
storage::{self, enums as storage_enums},
PaymentsAuthorizeData, PaymentsAuthorizeRouterData, PaymentsResponseData,
},
};
@ -74,7 +73,7 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
}
}
impl PaymentsAuthorizeRouterData {
impl types::PaymentsAuthorizeRouterData {
pub async fn decide_flow<'a, 'b>(
&'b self,
state: &'a AppState,
@ -87,9 +86,10 @@ impl PaymentsAuthorizeRouterData {
match confirm {
Some(true) => {
let connector_integration: services::BoxedConnectorIntegration<
'_,
api::Authorize,
PaymentsAuthorizeData,
PaymentsResponseData,
types::PaymentsAuthorizeData,
types::PaymentsResponseData,
> = connector.connector.get_connector_integration();
let resp = services::execute_connector_processing_step(
state,

View File

@ -11,7 +11,6 @@ use crate::{
types::{
self, api,
storage::{self, enums},
PaymentsCancelRouterData, PaymentsResponseData,
},
};
@ -24,7 +23,7 @@ impl ConstructFlowSpecificData<api::Void, types::PaymentsCancelData, types::Paym
state: &AppState,
connector_id: &str,
merchant_account: &storage::MerchantAccount,
) -> RouterResult<PaymentsCancelRouterData> {
) -> RouterResult<types::PaymentsCancelRouterData> {
transformers::construct_payment_router_data::<api::Void, types::PaymentsCancelData>(
state,
self.clone(),
@ -58,7 +57,7 @@ impl Feature<api::Void, types::PaymentsCancelData>
}
}
impl PaymentsCancelRouterData {
impl types::PaymentsCancelRouterData {
#[allow(clippy::too_many_arguments)]
pub async fn decide_flow<'a, 'b>(
&'b self,
@ -69,9 +68,10 @@ impl PaymentsCancelRouterData {
call_connector_action: payments::CallConnectorAction,
) -> RouterResult<Self> {
let connector_integration: services::BoxedConnectorIntegration<
'_,
api::Void,
types::PaymentsCancelData,
PaymentsResponseData,
types::PaymentsResponseData,
> = connector.connector.get_connector_integration();
let resp = services::execute_connector_processing_step(
state,

View File

@ -11,7 +11,6 @@ use crate::{
types::{
self, api,
storage::{self, enums},
PaymentsCaptureData, PaymentsCaptureRouterData, PaymentsResponseData,
},
};
@ -25,7 +24,7 @@ impl
state: &AppState,
connector_id: &str,
merchant_account: &storage::MerchantAccount,
) -> RouterResult<PaymentsCaptureRouterData> {
) -> RouterResult<types::PaymentsCaptureRouterData> {
transformers::construct_payment_router_data::<api::Capture, types::PaymentsCaptureData>(
state,
self.clone(),
@ -59,7 +58,7 @@ impl Feature<api::Capture, types::PaymentsCaptureData>
}
}
impl PaymentsCaptureRouterData {
impl types::PaymentsCaptureRouterData {
#[allow(clippy::too_many_arguments)]
pub async fn decide_flow<'a, 'b>(
&'b self,
@ -70,9 +69,10 @@ impl PaymentsCaptureRouterData {
call_connector_action: payments::CallConnectorAction,
) -> RouterResult<Self> {
let connector_integration: services::BoxedConnectorIntegration<
'_,
api::Capture,
PaymentsCaptureData,
PaymentsResponseData,
types::PaymentsCaptureData,
types::PaymentsResponseData,
> = connector.connector.get_connector_integration();
let resp = services::execute_connector_processing_step(
state,

View File

@ -11,7 +11,6 @@ use crate::{
types::{
self, api,
storage::{self, enums},
PaymentsResponseData, PaymentsSyncData, PaymentsSyncRouterData,
},
};
@ -60,7 +59,7 @@ impl Feature<api::PSync, types::PaymentsSyncData>
}
}
impl PaymentsSyncRouterData {
impl types::PaymentsSyncRouterData {
pub async fn decide_flow<'a, 'b>(
&'b self,
state: &'a AppState,
@ -70,9 +69,10 @@ impl PaymentsSyncRouterData {
call_connector_action: payments::CallConnectorAction,
) -> RouterResult<Self> {
let connector_integration: services::BoxedConnectorIntegration<
'_,
api::PSync,
PaymentsSyncData,
PaymentsResponseData,
types::PaymentsSyncData,
types::PaymentsResponseData,
> = connector.connector.get_connector_integration();
let resp = services::execute_connector_processing_step(
state,

View File

@ -110,6 +110,7 @@ impl types::PaymentsSessionRouterData {
api::GetToken::Metadata => create_gpay_session_token(self),
api::GetToken::Connector => {
let connector_integration: services::BoxedConnectorIntegration<
'_,
api::Session,
types::PaymentsSessionData,
types::PaymentsResponseData,

View File

@ -70,6 +70,7 @@ impl types::VerifyRouterData {
match confirm {
Some(true) => {
let connector_integration: services::BoxedConnectorIntegration<
'_,
api::Verify,
types::VerifyRequestData,
types::PaymentsResponseData,

View File

@ -566,7 +566,7 @@ pub(crate) async fn call_payment_method(
pub(crate) fn client_secret_auth<P>(
payload: P,
auth_type: &services::api::MerchantAuthentication,
auth_type: &services::api::MerchantAuthentication<'_>,
) -> RouterResult<P>
where
P: services::Authenticate,
@ -1195,7 +1195,7 @@ pub fn make_url_with_signature(
}
pub fn hmac_sha256_sorted_query_params<'a>(
params: &mut [(Cow<str>, Cow<str>)],
params: &mut [(Cow<'_, str>, Cow<'_, str>)],
key: &'a str,
) -> RouterResult<String> {
params.sort();

View File

@ -8,21 +8,18 @@ mod payment_session;
mod payment_start;
mod payment_status;
mod payment_update;
use async_trait::async_trait;
use error_stack::{report, ResultExt};
pub use payment_cancel::PaymentCancel;
pub use payment_capture::PaymentCapture;
pub use payment_confirm::PaymentConfirm;
pub use payment_create::PaymentCreate;
pub use payment_method_validate::PaymentMethodValidate;
pub use payment_response::PaymentResponse;
pub use payment_session::PaymentSession;
pub use payment_start::PaymentStart;
pub use payment_status::PaymentStatus;
pub use payment_update::PaymentUpdate;
use router_env::{instrument, tracing};
use storage::Customer;
pub use self::{
payment_cancel::PaymentCancel, payment_capture::PaymentCapture,
payment_confirm::PaymentConfirm, payment_create::PaymentCreate,
payment_method_validate::PaymentMethodValidate, payment_response::PaymentResponse,
payment_session::PaymentSession, payment_start::PaymentStart, payment_status::PaymentStatus,
payment_update::PaymentUpdate,
};
use super::{helpers, CustomerDetails, PaymentData};
use crate::{
core::errors::{self, CustomResult, RouterResult},
@ -150,7 +147,7 @@ pub trait UpdateTracker<F, D, Req>: Send {
db: &dyn StorageInterface,
payment_id: &api::PaymentIdType,
payment_data: D,
customer: Option<Customer>,
customer: Option<storage::Customer>,
storage_scheme: enums::MerchantStorageScheme,
) -> RouterResult<(BoxedOperation<'b, F, Req>, D)>
where

View File

@ -13,7 +13,7 @@ use crate::{
db::StorageInterface,
routes::AppState,
types::{
api::{self, PaymentIdTypeExt, PaymentsCaptureRequest},
api::{self, PaymentIdTypeExt},
storage::{self, enums},
transformers::ForeignInto,
},
@ -34,7 +34,7 @@ impl<F: Send + Clone> GetTracker<F, payments::PaymentData<F>, api::PaymentsCaptu
state: &'a AppState,
payment_id: &api::PaymentIdType,
merchant_id: &str,
request: &PaymentsCaptureRequest,
request: &api::PaymentsCaptureRequest,
_mandate_type: Option<api::MandateTxnType>,
storage_scheme: enums::MerchantStorageScheme,
) -> RouterResult<(

View File

@ -101,7 +101,6 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsSessionRequest>
payment_intent.shipping_address_id = shipping_address.clone().map(|x| x.address_id);
payment_intent.billing_address_id = billing_address.clone().map(|x| x.address_id);
let db = db as &dyn StorageInterface;
let connector_response = db
.find_connector_response_by_payment_id_merchant_id_attempt_id(
&payment_intent.payment_id,

View File

@ -16,7 +16,7 @@ use crate::{
routes::AppState,
types::{
api::{self, enums as api_enums, PaymentIdTypeExt},
storage::{self, enums, Customer},
storage::{self, enums},
transformers::ForeignInto,
},
utils::OptionExt,
@ -158,7 +158,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsStartRequest> for P
_db: &dyn StorageInterface,
_payment_id: &api::PaymentIdType,
payment_data: PaymentData<F>,
_customer: Option<Customer>,
_customer: Option<storage::Customer>,
_storage_scheme: enums::MerchantStorageScheme,
) -> RouterResult<(
BoxedOperation<'b, F, api::PaymentsStartRequest>,

View File

@ -109,7 +109,7 @@ impl<F: Clone + Send> Domain<F, api::PaymentsRequest> for PaymentStatus {
&'a self,
state: &'a AppState,
payment_attempt: &storage::PaymentAttempt,
) -> CustomResult<(), errors::ApiErrorResponse> {
) -> CustomResult<(), ApiErrorResponse> {
helpers::add_domain_task_to_pt(self, state, payment_attempt).await
}
@ -118,7 +118,7 @@ impl<F: Clone + Send> Domain<F, api::PaymentsRequest> for PaymentStatus {
merchant_account: &storage::MerchantAccount,
state: &AppState,
request_connector: Option<api_enums::Connector>,
) -> CustomResult<api::ConnectorCallType, errors::ApiErrorResponse> {
) -> CustomResult<api::ConnectorCallType, ApiErrorResponse> {
helpers::get_connector_default(merchant_account, state, request_connector).await
}
}

View File

@ -112,7 +112,6 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
payment_intent.shipping_address_id = shipping_address.clone().map(|x| x.address_id);
payment_intent.billing_address_id = billing_address.clone().map(|x| x.address_id);
let db = db as &dyn StorageInterface;
let connector_response = db
.find_connector_response_by_payment_id_merchant_id_attempt_id(
&payment_intent.payment_id,

View File

@ -13,8 +13,7 @@ use crate::{
routes::AppState,
services::{self, RedirectForm},
types::{
self,
api::{self, NextAction, PaymentsResponse},
self, api,
storage::{self, enums},
transformers::ForeignInto,
},
@ -32,8 +31,7 @@ where
T: TryFrom<PaymentData<F>>,
types::RouterData<F, T, types::PaymentsResponseData>: Feature<F, T>,
F: Clone,
error_stack::Report<errors::ApiErrorResponse>:
std::convert::From<<T as TryFrom<PaymentData<F>>>::Error>,
error_stack::Report<errors::ApiErrorResponse>: From<<T as TryFrom<PaymentData<F>>>::Error>,
{
//TODO: everytime parsing the json may have impact?
@ -260,10 +258,10 @@ where
.map_err(|_| errors::ApiErrorResponse::InternalServerError)?;
services::BachResponse::Form(form)
} else {
let mut response: PaymentsResponse = request.into();
let mut response: api::PaymentsResponse = request.into();
let mut next_action_response = None;
if payment_intent.status == enums::IntentStatus::RequiresCustomerAction {
next_action_response = Some(NextAction {
next_action_response = Some(api::NextAction {
next_action_type: api::NextActionType::RedirectToUrl,
redirect_to_url: Some(helpers::create_startpay_url(
server,
@ -342,7 +340,7 @@ where
)
}
}
None => services::BachResponse::Json(PaymentsResponse {
None => services::BachResponse::Json(api::PaymentsResponse {
payment_id: Some(payment_attempt.payment_id),
merchant_id: Some(payment_attempt.merchant_id),
status: payment_intent.status.foreign_into(),