711 | 713 | }); | |
712 | 714 | ||
715 | // validate billing name for card holder name | ||
716 | helpers::validate_billing_name( |
create a domain type which will have these validations, use the domain type wherever validations are required
238 | // pub struct NameTypeValidationErr(&'static str); | ||
239 | |||
240 | #[derive(Clone, Default, Debug, Eq, PartialEq, Serialize)] | ||
241 | pub struct NameType(Secret<LengthString<256, 1>>); |
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
1786 | 1786 | .next() | |
1787 | 1787 | .map(ToOwned::to_owned) | |
1788 | .map(Secret::new); | ||
1788 | .and_then(|name| NameType::try_from(name).ok()); |
do not use .ok(), log the error
replace all instances of .ok() with logging the error, and if possible qualify the imports
wherever possible try to use the nametype, and if the domain is expanding too much convert the type, and raise errors when the conversion might fail
Please ensure that the values that we read from the database are backwards compatible.
connector related files LGTM!
Routing related changes LGTM!!
Login to write a write a comment.
Type of Change
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
Additional Changes
Motivation and Context
How did you test it?
Tested through Postman:
Case 1: Create a Payment with valid name:
Case 2: Create a Payment with invalid name:
Response should contain 400 error with below response:
Checklist
cargo +nightly fmt --all
cargo clippy