feat(connector): add amount conversion framework to Powertranz#9752
Conversation
Signed-off-by: Arya Pratap Singh <notaryasingh@gmail.com>
Changed Files
|
|
can someone review this please. thanks cc: @pixincreate |
|
Reminder for this @pixincreate . thanks |
|
@jagan-jaya and @mrudulvajpayee4935 , please review |
Vani-1107
left a comment
There was a problem hiding this comment.
Converted all amount fields from f64 to StringMajorUnit in PowertranzPaymentsRequest and PowertranzBaseRequest
Hi @ARYPROGRAMMER ,
We’ve converted f64 to StringMajorUnit here, but it should instead be converted to FloatMajorUnit. Please refer to the implementation here, if needed.
Signed-off-by: Arya Pratap Singh <notaryasingh@gmail.com>
Updated to use Thanks for the response. This is pending since too long |
There was a problem hiding this comment.
@ARYPROGRAMMER , please run cargo check command and address the errors and warnings you get.
Signed-off-by: Arya Pratap Singh <notaryasingh@gmail.com>
hey @Vani-1107 , everything LGTM, here's the
Cached checks are not shown took me 1 hour to debug and check fmt of this small thing. Glad to contribute |
Vani-1107
left a comment
There was a problem hiding this comment.
Sure, thanks for contributing @ARYPROGRAMMER.
The changes looks good to me !
Can you merge it. @Vani-1107 |
@ARYPROGRAMMER , please change the PR description accordingly |
Donee |
|
Please address the required checks failure. |
Signed-off-by: Arya Pratap Singh <notaryasingh@gmail.com>
1fb5dd3
i tried to run all, please check please help me if any further issues thanks edit 2: also the reviews got dismissed as i pushed a new commit @Vani-1107 edit 3: I increased my wsl memory to max , now i was able to run here's the ss:
the thanks @Vani-1107 |
|
this ci-pr/spell check which is failing is originating from other files which this pr does not touch, rest should work. i triple checked |
|
lets actually get this done now, i have updated the branch and ran all commands in local , above ss attached. thanks to all reviewers. let me know further @Vani-1107 , sorry to disturb a lot by pinging. if still there are any issues please help me fix them. thanks |
…y#9752) Signed-off-by: Arya Pratap Singh <notaryasingh@gmail.com>
Signed-off-by: Arya Pratap Singh <notaryasingh@gmail.com>



Type of Change
Description
This PR implements the amount conversion framework for the Powertranz connector, transitioning from deprecated
f64-based amount handling to the standardized type-safeFloatMajorUnitsystem.Changes Made:
AmountConvertortrait implementation withFloatMajorUnitForConnectorto thePowertranzstructnew()constructor for static initialization with the amount converterPowertranzRouterData<T>wrapper struct to hold converted amounts alongside router dataf64toFloatMajorUnitinPowertranzPaymentsRequestandPowertranzBaseRequestTryFromimplementations for Authorize, Capture, and Refund flows to use the wrapper patternto_currency_base_unit_asf64()calls withconvert_amount()utility functionconnector_mapping.rsandfeature_matrix.rsto usePowertranz::new()Files Modified:
crates/hyperswitch_connectors/src/connectors/powertranz.rscrates/hyperswitch_connectors/src/connectors/powertranz/transformers.rscrates/router/src/types/api/connector_mapping.rscrates/router/src/types/api/feature_matrix.rscrates/router/tests/connectors/powertranz.rsAdditional Changes
Motivation and Context
Fixes #9086
This change is required to standardize amount handling across all connectors in the Hyperswitch platform. The old
f64-based approach has been deprecated in favor of a type-safe amount conversion framework that properly handles different currency decimal formats (zero-decimal currencies like JPY, two-decimal currencies like USD, and three-decimal currencies like BHD).The implementation follows the established pattern from PR #8878 (BankofAmerica connector) to ensure consistency across the codebase and proper handling of currency conversions.
How did you test it?
cargo checkcargo +nightly fmt --allto ensure proper formattingto_currency_base_unit_asf64()method callsPayments Create
Request
Response:
Capture
Response:
Void
Refund
Request:
Response:
Checklist
cargo +nightly fmt --allcargo clippy