Skip to content

feat(router): [Nuvei] add amount conversion framework for connectors #6166

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

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

Conversation

kaustubh1106
Copy link
Contributor

Type of Change

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

Description

This feature introduces a new Unit struct along with the MinorUnit type to standardize amount handling across all connectors within the application. The primary objective is to centralize the conversion logic within the core framework, eliminating the need for each connector to handle its own conversion.

By standardizing the format and placing the conversion logic in one location, this change simplifies the codebase and reduces potential inconsistencies in how amounts are managed across different connectors. Each connector can now simply invoke the convert function to receive amounts in their required format, based on their documentation.

This update will make future modifications and bug fixes easier to implement, as all amount conversions are now handled by a single, unified system.

fixes #6023

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

@kaustubh1106 kaustubh1106 requested review from a team as code owners September 30, 2024 16:20
Copy link

semanticdiff-com bot commented Sep 30, 2024

Review changes with SemanticDiff.

Analyzed 4 of 4 files.

Overall, the semantic diff is 11% smaller than the GitHub diff.

Filename Status
✔️ crates/router/tests/connectors/nuvei.rs Analyzed
✔️ crates/router/src/types/api.rs Analyzed
✔️ crates/router/src/connector/nuvei.rs 19.78% smaller
✔️ crates/router/src/connector/nuvei/transformers.rs Analyzed

@swangi-kumari swangi-kumari added A-connector-integration Area: Connector integration C-refactor Category: Refactor labels Oct 1, 2024
@swangi-kumari swangi-kumari changed the title feat(router): add amount conversion framework for connectors feat(router): [Nuvei] add amount conversion framework for connectors Oct 1, 2024
@deepanshu-iiitu deepanshu-iiitu added the hacktoberfest Issues that are up for grabs for Hacktoberfest participants label Oct 1, 2024
let connector_req = nuvei::NuveiPaymentFlowRequest::try_from(req)?;
let amount = connector_utils::convert_amount(
self.amount_converter,
req.request.minor_amount,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please take the amount value for capture from minor_amount_to_capture

let connector_req = nuvei::NuveiPaymentFlowRequest::try_from(req)?;
let refund_amount = connector_utils::convert_amount(
self.amount_converter,
req.request.minor_amount,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please take the amount value for refund from minor_refund_amount

@Sakilmostak
Copy link
Contributor

Add the amount conversion for the following api flows as well: Authorize, Preprocessing, and CompleteAuthorize

@mrudulvajpayee4935
Copy link
Contributor

Add the amount conversion for the following api flows as well: Authorize, Preprocessing, and CompleteAuthorize

hey @kaustubh1106 kindly look into the changes requested

@kaustubh1106
Copy link
Contributor Author

@mrudulvajpayee4935 sure

@gorakhnathy7
Copy link
Collaborator

gorakhnathy7 commented Oct 15, 2024

Hey @kaustubh1106 Were you able to work on the changes?

@deepanshu-iiitu
Copy link
Contributor

Hi @kaustubh1106
Please compile the code before raising the pr
cargo build

@gorakhnathy7
Copy link
Collaborator

Hey @kaustubh1106 any update on the changes!

@gorakhnathy7 gorakhnathy7 added the hacktoberfest-accepted Pull requests accepted as Hacktoberfest contributions label Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration C-refactor Category: Refactor hacktoberfest Issues that are up for grabs for Hacktoberfest participants hacktoberfest-accepted Pull requests accepted as Hacktoberfest contributions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REFACTOR]: [NUVEI] Add amount conversion framework to Nuvei
6 participants