Skip to content

Conversation

JeelGajera
Copy link

Type of Change

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

Description

This PR fixes the amount conversion issue for the Netcetera connector by implementing proper currency-aware amount handling.

Additional Changes

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

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:

  • Added test_amount_preserved_in_router_data() to verify amounts are correctly preserved in router data
  • Added test_amount_conversion_for_different_currencies() to test handling of USD, INR, and JPY

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

Copy link

semanticdiff-com bot commented Oct 11, 2025

@JeelGajera JeelGajera marked this pull request as ready for review October 11, 2025 13:22
@JeelGajera JeelGajera requested review from a team as code owners October 11, 2025 13:22
Copy link
Contributor

@Nithin1506200 Nithin1506200 left a 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)]
Copy link
Contributor

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(),
Copy link
Contributor

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
Copy link
Contributor

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> {
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR]: [connector] Add amount conversion framework to Netcetera

2 participants