Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): implement NameType for name validation #6734

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Sakilmostak
Copy link
Contributor

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

for card holder name in cards, validation is added before creation of request to flag invalid data in case it is present.
Reference is taken from Visa Documetation
image

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@Sakilmostak Sakilmostak added A-core Area: Core flows C-feature Category: Feature request or enhancement labels Dec 3, 2024
@Sakilmostak Sakilmostak added this to the December 2024 Release milestone Dec 3, 2024
@Sakilmostak Sakilmostak self-assigned this Dec 3, 2024
@Sakilmostak Sakilmostak requested review from a team as code owners December 3, 2024 14:27
Copy link

semanticdiff-com bot commented Dec 3, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/connector/nuvei/transformers.rs  96% smaller
  crates/router/src/core/payments/helpers.rs  80% smaller
  crates/router/src/connector/stripe/transformers.rs  79% smaller
  crates/router/src/utils.rs  76% smaller
  crates/router/src/core/payment_methods/cards.rs  74% smaller
  crates/router/tests/connectors/rapyd.rs  71% smaller
  crates/router/src/connector/netcetera/netcetera_types.rs  70% smaller
  crates/router/src/core/payment_methods/vault.rs  65% smaller
  crates/router/tests/connectors/bitpay.rs  49% smaller
  crates/router/tests/connectors/coinbase.rs  49% smaller
  crates/router/tests/connectors/cryptopay.rs  49% smaller
  crates/router/tests/connectors/cybersource.rs  49% smaller
  crates/router/tests/connectors/forte.rs  49% smaller
  crates/router/tests/connectors/iatapay.rs  49% smaller
  crates/router/tests/connectors/opennode.rs  49% smaller
  crates/router/tests/connectors/trustpay.rs  49% smaller
  crates/router/tests/connectors/bluesnap.rs  49% smaller
  crates/router/tests/connectors/multisafepay.rs  48% smaller
  crates/router/tests/connectors/payme.rs  48% smaller
  crates/router/tests/connectors/adyen.rs  46% smaller
  crates/router/tests/connectors/worldline.rs  46% smaller
  crates/router/tests/connectors/airwallex.rs  44% smaller
  crates/router/tests/connectors/utils.rs  44% smaller
  crates/api_models/src/payments.rs  44% smaller
  crates/router/tests/connectors/aci.rs  43% smaller
  crates/router/tests/connectors/fiserv.rs  41% smaller
  crates/router/tests/payments.rs  40% smaller
  crates/router/tests/payments2.rs  40% smaller
  crates/router/src/types/api/payments.rs  39% smaller
  crates/hyperswitch_connectors/src/utils.rs  39% smaller
  crates/router/src/connector/utils.rs  38% smaller
  crates/api_models/src/payment_methods.rs  37% smaller
  crates/router/src/core/payment_methods.rs  24% smaller
  crates/router/src/compatibility/stripe/payment_intents/types.rs  19% smaller
  crates/router/src/core/payment_methods/transformers.rs  19% smaller
  crates/router/src/compatibility/stripe/setup_intents/types.rs  19% smaller
  crates/router/src/connector/cybersource/transformers.rs  11% smaller
  crates/hyperswitch_domain_models/src/address.rs  2% smaller
  crates/cards/src/validate.rs  1% smaller
  crates/router/src/core/utils.rs  1% smaller
  crates/api_models/src/payments/additional_info.rs  1% smaller
  crates/api_models/src/mandates.rs  1% smaller
  crates/api_models/src/payouts.rs  1% smaller
  crates/hyperswitch_domain_models/src/router_request_types/fraud_check.rs  1% smaller
  crates/api_models/src/customers.rs  0% smaller
  crates/cards/src/lib.rs  0% smaller
  crates/cards/tests/basic.rs  0% smaller
  crates/common_utils/src/types.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/bluesnap/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/worldline/transformers.rs  0% smaller
  crates/hyperswitch_domain_models/src/payment_method_data.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_data.rs  0% smaller
  crates/router/src/compatibility/stripe/customers/types.rs  0% smaller
  crates/router/src/connector/adyen/transformers.rs  0% smaller
  crates/router/src/connector/authorizedotnet/transformers.rs  0% smaller
  crates/router/src/connector/bankofamerica/transformers.rs  0% smaller
  crates/router/src/connector/payone/transformers.rs  0% smaller
  crates/router/src/connector/paypal/transformers.rs  0% smaller
  crates/router/src/connector/riskified/transformers/api.rs  0% smaller
  crates/router/src/connector/signifyd/transformers/api.rs  0% smaller
  crates/router/src/connector/stripe/transformers/connect.rs  0% smaller
  crates/router/src/connector/trustpay/transformers.rs  0% smaller
  crates/router/src/connector/wellsfargo/transformers.rs  0% smaller
  crates/router/src/core/customers.rs  0% smaller
  crates/router/src/core/locker_migration.rs  0% smaller
  crates/router/src/core/payouts/helpers.rs  0% smaller
  crates/router/src/types/transformers.rs  0% smaller

@@ -710,6 +712,17 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
payment_method_data_billing.get_billing_address()
});

// validate billing name for card holder name
helpers::validate_billing_name(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create a domain type which will have these validations, use the domain type wherever validations are required

@Sakilmostak Sakilmostak requested review from a team as code owners December 20, 2024 13:28
@Sakilmostak Sakilmostak changed the title feat(router): add card_holder_name pre-validator feat(router): implement NameType for name validation Dec 23, 2024
@Sakilmostak Sakilmostak changed the title feat(router): implement NameType for name validation feat(core): implement NameType for name validation Dec 30, 2024
// pub struct NameTypeValidationErr(&'static str);

#[derive(Clone, Default, Debug, Eq, PartialEq, Serialize)]
pub struct NameType(Secret<LengthString<256, 1>>);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move this to common_utils or common_types, since this is not specific to cards as you have used this in all the other payment methods as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants