feat(router): [Nuvei] add amount conversion framework for connectors
Type of Change
- [ ] Bugfix
- [ ] New feature
- [ ] Enhancement
- [x] 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
Review changes with SemanticDiff.
Analyzed 4 of 4 files.
Overall, the semantic diff is 11% smaller than the GitHub diff.
| Filename | Status | |
|---|---|---|
| :heavy_check_mark: | crates/router/tests/connectors/nuvei.rs | Analyzed |
| :heavy_check_mark: | crates/router/src/types/api.rs | Analyzed |
| :heavy_check_mark: | crates/router/src/connector/nuvei.rs | 19.78% smaller |
| :heavy_check_mark: | crates/router/src/connector/nuvei/transformers.rs | Analyzed |
Add the amount conversion for the following api flows as well: Authorize, Preprocessing, and CompleteAuthorize
Add the amount conversion for the following api flows as well:
Authorize,Preprocessing, andCompleteAuthorize
hey @kaustubh1106 kindly look into the changes requested
@mrudulvajpayee4935 sure
Hey @kaustubh1106 Were you able to work on the changes?
Hi @kaustubh1106
Please compile the code before raising the pr
cargo build
Hey @kaustubh1106 any update on the changes!