-
Notifications
You must be signed in to change notification settings - Fork 4.4k
refactor(connector): add amount conversion framework to Netcetera #9091 #9795
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
base: main
Are you sure you want to change the base?
Conversation
Changed Files
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Remove test cases
- In Request types (netcetera_types.rs and transformers.rs) change all amounts to MinorUnit
} | ||
} | ||
|
||
#[cfg(test)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need test cases here, remove these test cases
field_name: "amount", | ||
})?, | ||
currency, | ||
converted_minor_unit.get_amount_as_i64(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convert this type i64 to minor amount in transformers.rs. No where where we mention amount
field should have i64. eg
@/crates/hyperswitch_connectors/src/connectors/netcetera/netcetera_types.rs
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
.....
pub purchase_amount: Option<i64>, // change to MinorUnit
.request | ||
.currency | ||
.ok_or(ConnectorError::MissingRequiredField { field_name: "currency" })?; | ||
let amount_i64 = req |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use request.minor_amount to get minor amount directly.
} | ||
} | ||
|
||
impl<T> TryFrom<(i64, T)> for NetceteraRouterData<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont use i64, change it to MinorUnit
Type of Change
Description
This PR fixes the amount conversion issue for the Netcetera connector by implementing proper currency-aware amount handling.
Additional Changes
Motivation and Context
Fixes #9091
The Netcetera connector was not handling currency-specific amount conversions correctly. Different currencies have different decimal place requirements (e.g., USD has 2 decimal places, JPY has 0), and the connector was passing amounts without proper conversion. This could lead to incorrect transaction amounts being sent to Netcetera.
This PR implements the same pattern used by other connectors (Gpayments, Multisafepay) to ensure amounts are properly converted based on the currency before being sent to the payment gateway.
How did you test it?
Unit Tests:
test_amount_preserved_in_router_data()
to verify amounts are correctly preserved in router datatest_amount_conversion_for_different_currencies()
to test handling of USD, INR, and JPYChecklist
cargo +nightly fmt --all
cargo clippy