chore: address some clippy lints arising from v2 code (#6015)

This commit is contained in:
Sanchith Hegde
2024-09-25 16:21:27 +05:30
committed by GitHub
parent 4dac86cebf
commit dec0a57f76
16 changed files with 115 additions and 112 deletions

View File

@ -307,6 +307,7 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable 2 weeks ago
components: clippy
- name: Install Protoc
uses: arduino/setup-protoc@v3
@ -322,14 +323,9 @@ jobs:
tool: just
checksum: true
- name: Run cargo check with v2 features enabled
- name: Run cargo clippy with v2 features enabled
shell: bash
env:
RUSTFLAGS: "-A warnings"
# Not denying warnings for now.
# We only want to ensure successful compilation for now.
# RUSTFLAGS: "-D warnings -A clippy::todo"
run: just check_v2
run: just clippy_v2 -- -D warnings -Aunused -Aclippy::todo -Aclippy::diverging_sub_expression
- name: Run cargo check enabling only the release and v2 features
shell: bash

View File

@ -63,13 +63,24 @@ impl From<AlphaNumericIdError> for CellIdError {
impl CellId {
/// Create a new cell id from a string
pub fn from_str(cell_id_string: impl AsRef<str>) -> Result<Self, CellIdError> {
fn from_str(cell_id_string: impl AsRef<str>) -> Result<Self, CellIdError> {
let trimmed_input_string = cell_id_string.as_ref().trim().to_string();
let alphanumeric_id = AlphaNumericId::from(trimmed_input_string.into())?;
let length_id = LengthId::from_alphanumeric_id(alphanumeric_id)?;
Ok(Self(length_id))
}
/// Create a new cell id from a string
pub fn from_string(
input_string: impl AsRef<str>,
) -> error_stack::Result<Self, errors::ValidationError> {
Self::from_str(input_string).change_context(
errors::ValidationError::IncorrectValueProvided {
field_name: "cell_id",
},
)
}
/// Get the string representation of the cell id
fn get_string_repr(&self) -> &str {
&self.0 .0 .0
@ -115,7 +126,7 @@ impl GlobalId {
pub(crate) fn from_string(
input_string: std::borrow::Cow<'static, str>,
) -> Result<Self, GlobalIdError> {
let length_id = LengthId::from(input_string.into())?;
let length_id = LengthId::from(input_string)?;
let input_string = &length_id.0 .0;
let (cell_id, remaining) = input_string
.split_once("_")

View File

@ -1,4 +1,3 @@
use diesel::{backend::Backend, deserialize::FromSql, serialize::ToSql, sql_types};
use error_stack::ResultExt;
use crate::{
@ -7,6 +6,7 @@ use crate::{
id_type::global_id::{CellId, GlobalEntity, GlobalId, GlobalIdError},
};
/// A global id that can be used to identify a payment method
#[derive(
Debug,
Clone,
@ -27,7 +27,7 @@ pub enum GlobalPaymentMethodIdError {
}
impl GlobalPaymentMethodId {
/// Create a new GlobalPaymentMethodId from celll id information
/// Create a new GlobalPaymentMethodId from cell id information
pub fn generate(cell_id: &str) -> error_stack::Result<Self, GlobalPaymentMethodIdError> {
let cell_id = CellId::from_str(cell_id)
.change_context(GlobalPaymentMethodIdError::ConstructionError)
@ -36,10 +36,12 @@ impl GlobalPaymentMethodId {
Ok(Self(global_id))
}
/// Get string representation of the id
pub fn get_string_repr(&self) -> &str {
self.0.get_string_repr()
}
/// Construct a new GlobalPaymentMethodId from a string
pub fn generate_from_string(value: String) -> CustomResult<Self, GlobalPaymentMethodIdError> {
let id = GlobalId::from_string(value.into())
.change_context(GlobalPaymentMethodIdError::ConstructionError)?;
@ -47,7 +49,7 @@ impl GlobalPaymentMethodId {
}
}
impl<DB> diesel::Queryable<sql_types::Text, DB> for GlobalPaymentMethodId
impl<DB> diesel::Queryable<diesel::sql_types::Text, DB> for GlobalPaymentMethodId
where
DB: diesel::backend::Backend,
Self: diesel::deserialize::FromSql<diesel::sql_types::Text, DB>,
@ -58,10 +60,10 @@ where
}
}
impl<DB> ToSql<sql_types::Text, DB> for GlobalPaymentMethodId
impl<DB> diesel::serialize::ToSql<diesel::sql_types::Text, DB> for GlobalPaymentMethodId
where
DB: Backend,
GlobalId: ToSql<sql_types::Text, DB>,
DB: diesel::backend::Backend,
GlobalId: diesel::serialize::ToSql<diesel::sql_types::Text, DB>,
{
fn to_sql<'b>(
&'b self,
@ -71,10 +73,10 @@ where
}
}
impl<DB> FromSql<sql_types::Text, DB> for GlobalPaymentMethodId
impl<DB> diesel::deserialize::FromSql<diesel::sql_types::Text, DB> for GlobalPaymentMethodId
where
DB: Backend,
GlobalId: FromSql<sql_types::Text, DB>,
DB: diesel::backend::Backend,
GlobalId: diesel::deserialize::FromSql<diesel::sql_types::Text, DB>,
{
fn from_sql(value: DB::RawValue<'_>) -> diesel::deserialize::Result<Self> {
let global_id = GlobalId::from_sql(value)?;

View File

@ -109,8 +109,8 @@ pub enum SurchargeCalculationOverride {
impl From<Option<bool>> for TaxCalculationOverride {
fn from(value: Option<bool>) -> Self {
match value {
Some(true) => TaxCalculationOverride::Calculate,
_ => TaxCalculationOverride::Skip,
Some(true) => Self::Calculate,
_ => Self::Skip,
}
}
}
@ -119,8 +119,8 @@ impl From<Option<bool>> for TaxCalculationOverride {
impl From<Option<bool>> for SurchargeCalculationOverride {
fn from(value: Option<bool>) -> Self {
match value {
Some(true) => SurchargeCalculationOverride::Calculate,
_ => SurchargeCalculationOverride::Skip,
Some(true) => Self::Calculate,
_ => Self::Skip,
}
}
}
@ -235,7 +235,7 @@ pub struct PaymentIntent {
/// The details of the customer in a denormalized form. Only a subset of fields are stored.
pub customer_details: Option<Encryptable<Secret<serde_json::Value>>>,
/// The reference id for the order in the merchant's system. This value can be passed by the merchant.
pub merchant_reference_id: Option<common_utils::id_type::PaymentId>,
pub merchant_reference_id: Option<id_type::PaymentId>,
/// The billing address for the order in a denormalized form.
pub billing_address: Option<Encryptable<Secret<serde_json::Value>>>,
/// The shipping address for the order in a denormalized form.

View File

@ -1481,7 +1481,7 @@ impl behaviour::Conversion for PaymentIntent {
type NewDstType = DieselPaymentIntentNew;
async fn convert(self) -> CustomResult<Self::DstType, ValidationError> {
let PaymentIntent {
let Self {
merchant_id,
amount_details,
status,
@ -1585,7 +1585,7 @@ impl behaviour::Conversion for PaymentIntent {
async fn convert_back(
state: &KeyManagerState,
storage_model: Self::DstType,
key: &masking::Secret<Vec<u8>>,
key: &Secret<Vec<u8>>,
key_manager_identifier: keymanager::Identifier,
) -> CustomResult<Self, ValidationError>
where

View File

@ -958,7 +958,7 @@ impl Default for CellInformation {
// around the time of deserializing application settings.
// And a panic at application startup is considered acceptable.
#[allow(clippy::expect_used)]
let cell_id = common_utils::id_type::CellId::from_str("defid")
let cell_id = common_utils::id_type::CellId::from_string("defid")
.expect("Failed to create a default for Cell Id");
Self { id: cell_id }
}

View File

@ -198,7 +198,7 @@ impl super::settings::CellInformation {
pub fn validate(&self) -> Result<(), ApplicationError> {
use common_utils::{fp_utils::when, id_type};
when(self == &super::settings::CellInformation::default(), || {
when(self == &Self::default(), || {
Err(ApplicationError::InvalidConfigurationValueError(
"CellId cannot be set to a default".into(),
))

View File

@ -21,13 +21,13 @@ use api_models::payment_methods;
pub use api_models::{enums::PayoutConnectors, payouts as payout_types};
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))]
use common_utils::ext_traits::Encode;
use common_utils::{consts::DEFAULT_LOCALE, id_type::CustomerId};
use common_utils::{consts::DEFAULT_LOCALE, id_type};
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
use common_utils::{
crypto::{self, Encryptable},
ext_traits::{AsyncExt, Encode, ValueExt},
fp_utils::when,
generate_id, id_type,
generate_id,
request::RequestContent,
types as util_types,
};
@ -40,9 +40,7 @@ use hyperswitch_domain_models::api::{GenericLinks, GenericLinksData};
use hyperswitch_domain_models::payments::{payment_attempt::PaymentAttempt, PaymentIntent};
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
use masking::ExposeInterface;
use masking::PeekInterface;
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
use masking::Secret;
use masking::{PeekInterface, Secret};
use router_env::{instrument, tracing};
use time::Duration;
@ -198,10 +196,10 @@ pub async fn initiate_pm_collect_link(
req.return_url.clone(),
)
.await?;
let customer_id = CustomerId::try_from(Cow::from(pm_collect_link.primary_reference))
let customer_id = id_type::CustomerId::try_from(Cow::from(pm_collect_link.primary_reference))
.change_context(errors::ApiErrorResponse::InvalidDataValue {
field_name: "customer_id",
})?;
field_name: "customer_id",
})?;
// Return response
let url = pm_collect_link.url.peek();
@ -321,11 +319,12 @@ pub async fn render_pm_collect_link(
// else, send back form link
} else {
let customer_id =
CustomerId::try_from(Cow::from(pm_collect_link.primary_reference.clone()))
.change_context(errors::ApiErrorResponse::InvalidDataValue {
field_name: "customer_id",
})?;
let customer_id = id_type::CustomerId::try_from(Cow::from(
pm_collect_link.primary_reference.clone(),
))
.change_context(errors::ApiErrorResponse::InvalidDataValue {
field_name: "customer_id",
})?;
// Fetch customer
let customer = db
@ -349,7 +348,7 @@ pub async fn render_pm_collect_link(
))?;
let js_data = payment_methods::PaymentMethodCollectLinkDetails {
publishable_key: masking::Secret::new(merchant_account.publishable_key),
publishable_key: Secret::new(merchant_account.publishable_key),
client_secret: link_data.client_secret.clone(),
pm_collect_link_id: pm_collect_link.link_id,
customer_id: customer.customer_id,
@ -448,7 +447,7 @@ pub async fn add_payment_method_status_update_task(
payment_method: &domain::PaymentMethod,
prev_status: enums::PaymentMethodStatus,
curr_status: enums::PaymentMethodStatus,
merchant_id: &common_utils::id_type::MerchantId,
merchant_id: &id_type::MerchantId,
) -> Result<(), errors::ProcessTrackerError> {
let created_at = payment_method.created_at;
let schedule_time =
@ -496,6 +495,7 @@ pub async fn add_payment_method_status_update_task(
}
#[cfg(feature = "v2")]
#[allow(clippy::too_many_arguments)]
#[instrument(skip_all)]
pub async fn retrieve_payment_method_with_token(
_state: &SessionState,
@ -671,8 +671,8 @@ pub(crate) async fn get_payment_method_create_request(
payment_method_data: Option<&domain::PaymentMethodData>,
payment_method: Option<storage_enums::PaymentMethod>,
payment_method_type: Option<storage_enums::PaymentMethodType>,
customer_id: &Option<CustomerId>,
billing_name: Option<masking::Secret<String>>,
customer_id: &Option<id_type::CustomerId>,
billing_name: Option<Secret<String>>,
) -> RouterResult<payment_methods::PaymentMethodCreate> {
match payment_method_data {
Some(pm_data) => match payment_method {
@ -748,8 +748,8 @@ pub(crate) async fn get_payment_method_create_request(
payment_method_data: Option<&domain::PaymentMethodData>,
payment_method: Option<storage_enums::PaymentMethod>,
payment_method_type: Option<storage_enums::PaymentMethodType>,
customer_id: &Option<CustomerId>,
billing_name: Option<masking::Secret<String>>,
customer_id: &Option<id_type::CustomerId>,
billing_name: Option<Secret<String>>,
) -> RouterResult<payment_methods::PaymentMethodCreate> {
match payment_method_data {
Some(pm_data) => match payment_method {
@ -833,7 +833,7 @@ pub async fn create_payment_method(
req: api::PaymentMethodCreate,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> errors::RouterResponse<api::PaymentMethodResponse> {
) -> RouterResponse<api::PaymentMethodResponse> {
req.validate()?;
let db = &*state.store;
@ -844,7 +844,7 @@ pub async fn create_payment_method(
&(state.into()),
&customer_id,
merchant_account.get_id(),
&key_store,
key_store,
merchant_account.storage_scheme,
)
.await
@ -860,10 +860,9 @@ pub async fn create_payment_method(
.attach_printable("Unable to encrypt Payment method billing address")?;
// create pm
let payment_method_id =
common_utils::id_type::GlobalPaymentMethodId::generate("random_cell_id")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Unable to generate GlobalPaymentMethodId")?;
let payment_method_id = id_type::GlobalPaymentMethodId::generate("random_cell_id")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Unable to generate GlobalPaymentMethodId")?;
let payment_method = create_payment_method_for_intent(
state,
@ -897,7 +896,7 @@ pub async fn create_payment_method(
let payment_method = db
.update_payment_method(
&(state.into()),
&key_store,
key_store,
payment_method,
pm_update,
merchant_account.storage_scheme,
@ -917,7 +916,7 @@ pub async fn create_payment_method(
db.update_payment_method(
&(state.into()),
&key_store,
key_store,
payment_method,
pm_update,
merchant_account.storage_scheme,
@ -940,7 +939,7 @@ pub async fn payment_method_intent_create(
req: api::PaymentMethodIntentCreate,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> errors::RouterResponse<api::PaymentMethodResponse> {
) -> RouterResponse<api::PaymentMethodResponse> {
let db = &*state.store;
let merchant_id = merchant_account.get_id();
let customer_id = req.customer_id.to_owned();
@ -949,7 +948,7 @@ pub async fn payment_method_intent_create(
&(state.into()),
&customer_id,
merchant_account.get_id(),
&key_store,
key_store,
merchant_account.storage_scheme,
)
.await
@ -966,10 +965,9 @@ pub async fn payment_method_intent_create(
// create pm entry
let payment_method_id =
common_utils::id_type::GlobalPaymentMethodId::generate("random_cell_id")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Unable to generate GlobalPaymentMethodId")?;
let payment_method_id = id_type::GlobalPaymentMethodId::generate("random_cell_id")
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Unable to generate GlobalPaymentMethodId")?;
let payment_method = create_payment_method_for_intent(
state,
@ -997,19 +995,19 @@ pub async fn payment_method_intent_confirm(
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
pm_id: String,
) -> errors::RouterResponse<api::PaymentMethodResponse> {
) -> RouterResponse<api::PaymentMethodResponse> {
req.validate()?;
let db = &*state.store;
let client_secret = req.client_secret.clone();
let pm_id = common_utils::id_type::GlobalPaymentMethodId::generate_from_string(pm_id)
let pm_id = id_type::GlobalPaymentMethodId::generate_from_string(pm_id)
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Unable to generate GlobalPaymentMethodId")?;
let payment_method = db
.find_payment_method(
&(state.into()),
&key_store,
key_store,
&pm_id,
merchant_account.storage_scheme,
)
@ -1037,7 +1035,7 @@ pub async fn payment_method_intent_confirm(
&(state.into()),
&customer_id,
merchant_account.get_id(),
&key_store,
key_store,
merchant_account.storage_scheme,
)
.await
@ -1062,7 +1060,7 @@ pub async fn payment_method_intent_confirm(
let payment_method = db
.update_payment_method(
&(state.into()),
&key_store,
key_store,
payment_method,
pm_update,
merchant_account.storage_scheme,
@ -1082,7 +1080,7 @@ pub async fn payment_method_intent_confirm(
db.update_payment_method(
&(state.into()),
&key_store,
key_store,
payment_method,
pm_update,
merchant_account.storage_scheme,
@ -1228,7 +1226,7 @@ pub async fn create_pm_additional_data_update(
vault_id: Option<String>,
payment_method: Option<api_enums::PaymentMethod>,
payment_method_type: Option<api_enums::PaymentMethodType>,
) -> errors::RouterResult<storage::PaymentMethodUpdate> {
) -> RouterResult<storage::PaymentMethodUpdate> {
let card = match pmd.clone() {
api::PaymentMethodCreateData::Card(card) => api::PaymentMethodsData::Card(card.into()),
};
@ -1244,7 +1242,7 @@ pub async fn create_pm_additional_data_update(
locker_id: vault_id,
payment_method,
payment_method_type,
payment_method_data: Some(pmd).map(Into::into),
payment_method_data: Some(pmd.into()),
network_token_requestor_reference_id: None,
network_token_locker_id: None,
network_token_payment_method_data: None,
@ -1260,7 +1258,7 @@ pub async fn vault_payment_method(
pmd: &api::PaymentMethodCreateData,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> errors::RouterResult<pm_types::AddVaultResponse> {
) -> RouterResult<pm_types::AddVaultResponse> {
let db = &*state.store;
// get fingerprint_id from locker
@ -1377,7 +1375,7 @@ pub async fn list_customer_payment_method_util(
req: Option<api::PaymentMethodListRequest>,
customer_id: Option<id_type::CustomerId>,
is_payment_associated: bool,
) -> errors::RouterResponse<api::CustomerPaymentMethodsListResponse> {
) -> RouterResponse<api::CustomerPaymentMethodsListResponse> {
let limit = req.as_ref().and_then(|pml_req| pml_req.limit);
let (customer_id, payment_intent) = if is_payment_associated {
@ -1431,11 +1429,11 @@ pub async fn list_customer_payment_method(
state: &SessionState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
payment_intent: Option<storage::PaymentIntent>,
payment_intent: Option<PaymentIntent>,
customer_id: &id_type::CustomerId,
limit: Option<i64>,
is_payment_associated: bool,
) -> errors::RouterResponse<api::CustomerPaymentMethodsListResponse> {
) -> RouterResponse<api::CustomerPaymentMethodsListResponse> {
let db = &*state.store;
let key_manager_state = &(state).into();
// let key = key_store.key.get_inner().peek();
@ -1661,12 +1659,12 @@ async fn generate_saved_pm_response(
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
impl pm_types::SavedPMLPaymentsInfo {
pub async fn form_payments_info(
payment_intent: storage::PaymentIntent,
payment_intent: PaymentIntent,
merchant_account: &domain::MerchantAccount,
db: &dyn StorageInterface,
key_manager_state: &util_types::keymanager::KeyManagerState,
key_store: &domain::MerchantKeyStore,
) -> errors::RouterResult<Self> {
) -> RouterResult<Self> {
let requires_cvv = db
.find_config_by_key_unwrap_or(
format!(
@ -1718,7 +1716,7 @@ impl pm_types::SavedPMLPaymentsInfo {
parent_payment_method_token: Option<String>,
pma: &api::CustomerPaymentMethod,
pm_list_context: PaymentMethodListContext,
) -> errors::RouterResult<()> {
) -> RouterResult<()> {
let token = parent_payment_method_token
.as_ref()
.get_required_value("parent_payment_method_token")?;

View File

@ -226,7 +226,7 @@ async fn create_vault_request<R: pm_types::VaultingInterface>(
jwekey: &settings::Jwekey,
locker: &settings::Locker,
payload: Vec<u8>,
) -> errors::CustomResult<services::Request, errors::VaultError> {
) -> errors::CustomResult<Request, errors::VaultError> {
let private_key = jwekey.vault_private_key.peek().as_bytes();
let jws = services::encryption::jws_sign_payload(
@ -241,7 +241,7 @@ async fn create_vault_request<R: pm_types::VaultingInterface>(
let mut url = locker.host.to_owned();
url.push_str(R::get_vaulting_request_url());
let mut request = services::Request::new(services::Method::Post, &url);
let mut request = Request::new(services::Method::Post, &url);
request.add_header(
headers::CONTENT_TYPE,
router_consts::VAULT_HEADER_CONTENT_TYPE.into(),

View File

@ -310,15 +310,11 @@ pub async fn create_jwe_body_for_vault(
let public_key = jwekey.vault_encryption_key.peek().as_bytes();
let jwe_encrypted = encryption::encrypt_jwe(
&payload,
public_key,
encryption::EncryptionAlgorithm::A256GCM,
None,
)
.await
.change_context(errors::VaultError::SaveCardFailed)
.attach_printable("Error on jwe encrypt")?;
let jwe_encrypted =
encryption::encrypt_jwe(&payload, public_key, EncryptionAlgorithm::A256GCM, None)
.await
.change_context(errors::VaultError::SaveCardFailed)
.attach_printable("Error on jwe encrypt")?;
let jwe_payload: Vec<&str> = jwe_encrypted.split('.').collect();
let generate_jwe_body = |payload: Vec<&str>| -> Option<encryption::JweBody> {

View File

@ -1788,7 +1788,7 @@ pub async fn retrieve_payment_method_with_temporary_token(
pub async fn retrieve_card_with_permanent_token(
state: &SessionState,
locker_id: &str,
_payment_method_id: &common_utils::id_type::GlobalPaymentMethodId,
_payment_method_id: &id_type::GlobalPaymentMethodId,
payment_intent: &PaymentIntent,
card_token_data: Option<&domain::CardToken>,
_merchant_key_store: &domain::MerchantKeyStore,

View File

@ -785,7 +785,7 @@ impl MerchantConnectorAccountInterface for Store {
format!("{}_{}", _profile_id.get_string_repr(), _connector_name).into(),
),
cache::CacheKind::Accounts(
format!("{}", _merchant_connector_id.get_string_repr()).into(),
_merchant_connector_id.get_string_repr().to_string().into(),
),
cache::CacheKind::CGraph(
format!(

View File

@ -173,7 +173,7 @@ impl ForeignTryFrom<domain::Profile> for ProfileResponse {
}
#[cfg(feature = "v2")]
impl ForeignTryFrom<domain::Profile> for admin::ProfileResponse {
impl ForeignTryFrom<domain::Profile> for ProfileResponse {
type Error = error_stack::Report<errors::ParsingError>;
fn foreign_try_from(item: domain::Profile) -> Result<Self, Self::Error> {
@ -193,7 +193,7 @@ impl ForeignTryFrom<domain::Profile> for admin::ProfileResponse {
let order_fulfillment_time = item
.order_fulfillment_time
.map(api_models::admin::OrderFulfillmentTime::try_new)
.map(admin::OrderFulfillmentTime::try_new)
.transpose()
.change_context(errors::ParsingError::IntegerOverflow)?;

View File

@ -69,25 +69,25 @@ impl PaymentMethodCreateExt for PaymentMethodCreate {
self.payment_method_type,
),
|| {
return Err(report!(errors::ApiErrorResponse::InvalidRequestData {
Err(report!(errors::ApiErrorResponse::InvalidRequestData {
message: "Invalid 'payment_method_type' provided".to_string()
})
.attach_printable("Invalid payment method type"));
.attach_printable("Invalid payment method type"))
},
);
)?;
utils::when(
!PaymentMethodCreate::validate_payment_method_data_against_payment_method(
!Self::validate_payment_method_data_against_payment_method(
self.payment_method,
self.payment_method_data.clone(),
),
|| {
return Err(report!(errors::ApiErrorResponse::InvalidRequestData {
Err(report!(errors::ApiErrorResponse::InvalidRequestData {
message: "Invalid 'payment_method_data' provided".to_string()
})
.attach_printable("Invalid payment method data"));
.attach_printable("Invalid payment method data"))
},
);
)?;
Ok(())
}
}
@ -101,25 +101,25 @@ impl PaymentMethodCreateExt for PaymentMethodIntentConfirm {
self.payment_method_type,
),
|| {
return Err(report!(errors::ApiErrorResponse::InvalidRequestData {
Err(report!(errors::ApiErrorResponse::InvalidRequestData {
message: "Invalid 'payment_method_type' provided".to_string()
})
.attach_printable("Invalid payment method type"));
.attach_printable("Invalid payment method type"))
},
);
)?;
utils::when(
!PaymentMethodIntentConfirm::validate_payment_method_data_against_payment_method(
!Self::validate_payment_method_data_against_payment_method(
self.payment_method,
self.payment_method_data.clone(),
),
|| {
return Err(report!(errors::ApiErrorResponse::InvalidRequestData {
Err(report!(errors::ApiErrorResponse::InvalidRequestData {
message: "Invalid 'payment_method_data' provided".to_string()
})
.attach_printable("Invalid payment method data"));
.attach_printable("Invalid payment method data"))
},
);
)?;
Ok(())
}
}

View File

@ -78,7 +78,7 @@ impl VaultingInterface for GetVaultFingerprint {
impl VaultingDataInterface for api::PaymentMethodCreateData {
fn get_vaulting_data_key(&self) -> String {
match &self {
api::PaymentMethodCreateData::Card(card) => card.card_number.to_string(),
Self::Card(card) => card.card_number.to_string(),
}
}
}

View File

@ -19,7 +19,7 @@ clippy *FLAGS:
#! /usr/bin/env bash
set -euo pipefail
FEATURES="$(cargo metadata --all-features --format-version 1 | \
FEATURES="$(cargo metadata --all-features --format-version 1 --no-deps | \
jq -r '
[ ( .workspace_members | sort ) as $package_ids # Store workspace crate package IDs in `package_ids` array
| .packages[] | select( IN(.id; $package_ids[]) ) | .features | keys[] ] | unique # Select all unique features from all workspace crates
@ -35,7 +35,7 @@ clippy_v2 *FLAGS:
#! /usr/bin/env bash
set -euo pipefail
FEATURES="$(cargo metadata --all-features --format-version 1 | \
FEATURES="$(cargo metadata --all-features --format-version 1 --no-deps | \
jq -r '
[ ( .workspace_members | sort ) as $package_ids # Store workspace crate package IDs in `package_ids` array
| .packages[] | select( IN(.id; $package_ids[]) ) | .features | keys[] ] | unique # Select all unique features from all workspace crates
@ -44,14 +44,14 @@ clippy_v2 *FLAGS:
')"
set -x
cargo clippy {{ check_flags }} --no-default-features --features "${FEATURES}" {{ FLAGS }}
cargo clippy {{ check_flags }} --no-default-features --features "${FEATURES}" {{ FLAGS }}
set +x
check_v2 *FLAGS:
#! /usr/bin/env bash
set -euo pipefail
FEATURES="$(cargo metadata --all-features --format-version 1 | \
FEATURES="$(cargo metadata --all-features --format-version 1 --no-deps | \
jq -r '
[ ( .workspace_members | sort ) as $package_ids # Store workspace crate package IDs in `package_ids` array
| .packages[] | select( IN(.id; $package_ids[]) ) | .features | keys[] ] | unique # Select all unique features from all workspace crates
@ -60,7 +60,7 @@ check_v2 *FLAGS:
')"
set -x
cargo check {{ check_flags }} --no-default-features --features "${FEATURES}" {{ FLAGS }}
cargo check {{ check_flags }} --no-default-features --features "${FEATURES}" {{ FLAGS }}
set +x
run_v2:
@ -82,7 +82,7 @@ check *FLAGS:
#! /usr/bin/env bash
set -euo pipefail
FEATURES="$(cargo metadata --all-features --format-version 1 | \
FEATURES="$(cargo metadata --all-features --format-version 1 --no-deps | \
jq -r '
[ ( .workspace_members | sort ) as $package_ids # Store workspace crate package IDs in `package_ids` array
| .packages[] | select( IN(.id; $package_ids[]) ) | .features | keys[] ] | unique # Select all unique features from all workspace crates
@ -91,7 +91,7 @@ check *FLAGS:
')"
set -x
cargo check {{ check_flags }} --features "${FEATURES}" {{ FLAGS }}
cargo check {{ check_flags }} --features "${FEATURES}" {{ FLAGS }}
set +x
alias cl := clippy