Skip to content

refactor(connector): added amount conversion framework for powertranz #6239

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 6 commits into
base: main
Choose a base branch
from

Conversation

sahil9001
Copy link

@sahil9001 sahil9001 commented Oct 5, 2024

Type of Change

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

Description

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

Closes #6136

How did you test it?

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

@sahil9001 sahil9001 requested a review from a team as a code owner October 5, 2024 20:53
Copy link

semanticdiff-com bot commented Oct 5, 2024

Review changes with SemanticDiff.

Analyzed 4 of 4 files.

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

Filename Status
✔️ crates/router/tests/connectors/powertranz.rs 72.69% smaller
✔️ crates/router/src/types/api.rs 86.06% smaller
✔️ crates/hyperswitch_connectors/src/connectors/powertranz.rs 23.66% smaller
✔️ crates/hyperswitch_connectors/src/connectors/powertranz/transformers.rs 0.0% smaller

@sahil9001 sahil9001 requested a review from a team as a code owner October 5, 2024 20:56
@gorakhnathy7
Copy link
Collaborator

Hey @sahil9001 Can you please link the issue to this PR.
thanks

@sahil9001
Copy link
Author

@ImSagnik007 is there any way to test this out locally? A command or something?

@ImSagnik007
Copy link
Contributor

@ImSagnik007 is there any way to test this out locally? A command or something?

hey @sahil9001 you can do cargo run, to build your branch locally

@gorakhnathy7 gorakhnathy7 added the hacktoberfest Issues that are up for grabs for Hacktoberfest participants label Oct 15, 2024
@deepanshu-iiitu
Copy link
Contributor

Hi @sahil9001
The ci checks are failing for your PR. Please remove the unused imports from
crates/hyperswitch_connectors/src/connectors/powertranz/transformers.rs:2:44
crates/hyperswitch_connectors/src/connectors/powertranz.rs:3:5

@sahil9001
Copy link
Author

Hey @deepanshu-iiitu , are my changes correct? I mean do I only need to remove the unused imports?

@deepanshu-iiitu
Copy link
Contributor

@sahil9001 There are still some errors that need to be fixed.
https://github.com/juspay/hyperswitch/actions/runs/11341994928/job/31541443522?pr=6239

@gorakhnathy7
Copy link
Collaborator

Hey @sahil9001 Kindly look into the changes to resolve them, so that it can be merged within time.

@sahil9001
Copy link
Author

sure , i will make the changes tomorrow

@swangi-kumari swangi-kumari added the A-connector-integration Area: Connector integration label Oct 28, 2024
Copy link
Contributor

@Sakilmostak Sakilmostak left a comment

Choose a reason for hiding this comment

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

Please do the amount conversion for the Capture and Refund flow as well

pub struct Powertranz;
#[derive(Clone)]
pub struct Powertranz {
amount_converter: &'static (dyn AmountConvertor<Output = StringMajorUnit> + Sync),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use FloatMajorUnit for conversion

impl Powertranz {
pub fn new() -> &'static Self {
&Self {
amount_converter: &StringMajorUnitForConnector,
Copy link
Contributor

Choose a reason for hiding this comment

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

Use FloatMajorUnitForConnector here

@@ -20,6 +20,20 @@ use crate::{
utils::{self, CardData, PaymentsAuthorizeRequestData, RouterData as _},
};

pub struct PowertranzRouterData<T> {
pub amount: StringMajorUnit,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use FloatMajorUnit for conversion

Comment on lines +28 to +35
impl<T> From<(StringMajorUnit, T)> for PowertranzRouterData<T> {
fn from((amount, item): (StringMajorUnit, T)) -> Self {
Self {
amount,
router_data: item,
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use FloatMajorUnit for conversion

Comment on lines 160 to 163
total_amount: utils::to_currency_base_unit_asf64(
item.request.amount,
item.request.currency,
item.router_data.request.amount,
item.router_data.request.currency,
)?,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use the amount from PowertranzRouterData instead on converting at place

Copy link
Contributor

@Sakilmostak Sakilmostak left a comment

Choose a reason for hiding this comment

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

Please update to the latest main branch as well

@gorakhnathy7 gorakhnathy7 added the hacktoberfest-accepted Pull requests accepted as Hacktoberfest contributions label Oct 31, 2024
@gorakhnathy7
Copy link
Collaborator

Hey @sahil9001 Can you please look into the comments, and make the changes!

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 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]: [POWERTRANZ] Add amount conversion framework to Powertranz
6 participants