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

fix(connector): send valid sdk information in authentication flow netcetera #4474

Merged
merged 6 commits into from
May 1, 2024

Conversation

hrithikesh026
Copy link
Contributor

@hrithikesh026 hrithikesh026 commented Apr 29, 2024

Type of Change

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

Description

Two required params in SDK information were not serde renamed properly. This was causing SDK based authentication call to fail. Fixed it.

Other changes:

  • Changed the type of error_message column in authentication table to TEXT from VARCHAR(64). Because when length of error_message was greater than 64 chars, update operation was failing.
  • Pass Device render options in authentication request because it is also required for SDK based authentication.
  • Pass address-state as two character state code.
  • pass country code in phone number after trimming + prefix

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?

Manual

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

@hrithikesh026 hrithikesh026 added C-bug Category: Bug S-waiting-on-review Status: This PR has been implemented and needs to be reviewed M-database-changes Metadata: This PR involves database schema changes labels Apr 29, 2024
@hrithikesh026 hrithikesh026 added this to the April 2024 milestone Apr 29, 2024
@hrithikesh026 hrithikesh026 self-assigned this Apr 29, 2024
@hrithikesh026 hrithikesh026 requested review from a team as code owners April 29, 2024 04:18
@hrithikesh026 hrithikesh026 changed the title fix(connector): send sdk information in authentication flow netcetera fix(connector): send proper sdk information in authentication flow netcetera Apr 29, 2024
@@ -1228,6 +1233,7 @@ pub trait AddressDetailsData {
fn get_country(&self) -> Result<&api_models::enums::CountryAlpha2, Error>;
fn get_combined_address_line(&self) -> Result<Secret<String>, Error>;
fn to_state_code(&self) -> Result<Secret<String>, Error>;
fn to_state_code_option(&self) -> Result<Option<Secret<String>>, Error>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fn to_state_code_option(&self) -> Result<Option<Secret<String>>, Error>;
fn to_state_code_as_optional(&self) -> Result<Option<Secret<String>>, Error>;

@@ -1186,6 +1186,7 @@ pub trait PhoneDetailsData {
fn get_country_code(&self) -> Result<String, Error>;
fn get_number_with_country_code(&self) -> Result<Secret<String>, Error>;
fn get_number_with_hash_country_code(&self) -> Result<Secret<String>, Error>;
fn get_country_code_without_plus(&self) -> Result<String, Error>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please find a better naming than without_plus

home_phone: billing_address
.phone
.clone()
.map(TryInto::try_into)
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather define the try_from here so code navigation is easy

mobile_phone: billing_address
.phone
.clone()
.map(TryInto::try_into)
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather define the try_from here so code navigation is easy

work_phone: billing_address
.phone
.clone()
.map(TryInto::try_into)
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather define the try_from here so code navigation is easy

Comment on lines 1320 to 1325
fn to_state_code_option(&self) -> Result<Option<Secret<String>>, Error> {
self.state
.as_ref()
.map(|_| self.to_state_code())
.transpose()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't return a result, do a map_err and return None in case of error.
Return Option<<Secret> and then update wherever you are using transpose().transpose()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately we cannot return None if Err occurs. to_state_code() will return Err when state is an invalid string. We cannot ignore this Err.

@@ -716,11 +721,24 @@ impl
bill_addr_state: billing_address
.address
.as_ref()
.and_then(|add| add.state.clone()),
.and_then(|add| add.to_state_code_as_optional().transpose())
Copy link
Contributor

Choose a reason for hiding this comment

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

We need not call to_state_code_as_optional here if it's already sent as state code, we should check and call this fn only if required (as state in our request is a String and any value can be sent there)

api_models::payments::DeviceChannel::App => {
Some(netcetera_types::DeviceRenderingOptionsSupported {
// hard-coded until core provides these values.
sdk_interface: netcetera_types::SdkInterface::Both,
Copy link
Contributor

Choose a reason for hiding this comment

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

This should always be Native for us

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per netcetera we are supposed to send this value.

@sai-harsha-vardhan sai-harsha-vardhan changed the title fix(connector): send proper sdk information in authentication flow netcetera fix(connector): send valid sdk information in authentication flow netcetera Apr 30, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue May 1, 2024
Merged via the queue into main with commit 8f0d4d4 May 1, 2024
13 of 15 checks passed
@Gnanasundari24 Gnanasundari24 deleted the send-sdk-info-metcetera branch May 1, 2024 10:52
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Bug M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants