-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix(connector): [NEXIXPAY] Add Validation Checks for Request Fields #8345
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
Conversation
Changed Files
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add test case where the payment id is passed explicitly in the payment request and the length of payment id is more than 18
} else { | ||
get_random_string() | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to throw a validation error here, and all other places
We should not send a random orderId which is not stored in HS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright
fn get_random_string() -> String { | ||
Alphanumeric.sample_string(&mut rand::thread_rng(), MAX_ORDER_ID_LENGTH) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
if val.clone().expose().len() > MAX_BILLING_ADDRESS_NAME_LENGTH { | ||
return Err(error_stack::Report::from( | ||
errors::ConnectorError::MaxFieldLengthViolated { | ||
field_name: "Billing Name".to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - better to add the field path here - which corresponds to Nexi's request
so something like address.billing.name
depending on the field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright
amount: item.amount.clone(), | ||
currency: item.router_data.request.currency, | ||
description: item.router_data.description.clone(), | ||
description: item.router_data.description.clone(), //check for description length already in core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove comment or address the validation
1c3a43d
295192e
Type of Change
Description
The OrderId field in Nexixpay request is limited to 18 characters in size.
Along with that added validation checks for fields inside shipping and billing addresses.
Additional Changes
Motivation and Context
https://developer.nexi.it/en/api/post-orders-3steps-payment

How did you test it?
Nexixpay Payments - Create
payment_id
is not passed in req (doesn't throw any error but creates a new string to map it withorderId
because when HS createspayment_id
it is always > 18 characters) :cURL:
Upon confirming the payment and doing a PSync, we get this
Response:
payment_id
is passed in req but more than 18 characters longcURL:
Response:
payment_id
is passed in req but <=18 characterscURL:
Response:
name/description/cardHolderName/address
anythingcURL:
(Made
zip
code more than 16 characters long)Response:
Checklist
cargo +nightly fmt --all
cargo clippy