Skip to content
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

refactor(connector): [CyberSource] Enhance currency Mapping with ConnectorCurrencyCommon Trait #2626

Merged

Conversation

mdrokz
Copy link
Contributor

@mdrokz mdrokz commented Oct 18, 2023

Type of Change

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

Description

This PR implements get_currency_unit for cybersource to convert payments from Base to Minor it also implements router data to handle the conversion.

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 #2222

How did you test it?

I tested by sending a payment request & verifying the amount is showed in minor units in the cybersource console

image

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
  • I added a CHANGELOG entry if applicable

@mdrokz mdrokz requested a review from a team as a code owner October 18, 2023 09:03
@github-actions github-actions bot added the S-conventions-not-followed Status: This PR does not follow contributing guidelines label Oct 18, 2023
@mdrokz mdrokz changed the title Feature/cybersource minor currency conversion refactor(connector): [CyberSource] Enhance currency Mapping with ConnectorCurrencyCommon Trait Oct 18, 2023
@github-actions github-actions bot removed the S-conventions-not-followed Status: This PR does not follow contributing guidelines label Oct 18, 2023
@SanchithHegde
Copy link
Member

Hey @mdrokz, could you address the failing CI checks?

@SanchithHegde SanchithHegde added A-connector-integration Area: Connector integration S-waiting-on-author Status: This PR is incomplete or needs to address review comments C-refactor Category: Refactor hacktoberfest Issues that are up for grabs for Hacktoberfest participants labels Oct 18, 2023
@mdrokz
Copy link
Contributor Author

mdrokz commented Oct 19, 2023

Hey @mdrokz, could you address the failing CI checks?

Just synced the changes from main can you run the CI checks again ?

@SanchithHegde
Copy link
Member

@mdrokz The formatting check is failing, could you please address it?

@mdrokz
Copy link
Contributor Author

mdrokz commented Oct 19, 2023

@mdrokz The formatting check is failing, could you please address it?

Done

@mdrokz
Copy link
Contributor Author

mdrokz commented Oct 20, 2023

@SanchithHegde can you review this ?

@SanchithHegde SanchithHegde added S-waiting-on-review Status: This PR has been implemented and needs to be reviewed and removed S-waiting-on-author Status: This PR is incomplete or needs to address review comments labels Oct 22, 2023
@@ -109,6 +140,70 @@ fn build_bill_to(
})
}

impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>>
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using new try_from , you can edit the exisiting try_from

Comment on lines 207 to 209
impl TryFrom<&types::PaymentsAuthorizeRouterData> for CybersourcePaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
impl TryFrom<&types::PaymentsAuthorizeRouterData> for CybersourcePaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> for CybersourcePaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(item: &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>) -> Result<Self, Self::Error> {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done i removed the old try form since both of them were same.

Copy link
Contributor

@srujanchikke srujanchikke left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@SanchithHegde SanchithHegde left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Thanks for the PR, @mdrokz!

@SanchithHegde SanchithHegde added this pull request to the merge queue Oct 25, 2023
@SanchithHegde SanchithHegde added hacktoberfest-accepted Pull requests accepted as Hacktoberfest contributions and removed S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Oct 25, 2023
Merged via the queue into juspay:main with commit f2f8170 Oct 25, 2023
10 checks passed
@swangi-kumari
Copy link
Contributor

Hey @mdrokz ,
Thanks a bunch for all your contributions! We've got a little something for you to show our appreciation.
Just take a moment to fill out this form, and get ready for some awesome swag coming your way.
Thanks!

@mdrokz
Copy link
Contributor Author

mdrokz commented Oct 25, 2023

Hey @mdrokz ,
Thanks a bunch for all your contributions! We've got a little something for you to show our appreciation.
Just take a moment to fill out this form, and get ready for some awesome swag coming your way.
Thanks!

Hey thanks a lot for this let me fill it up :)

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 C-refactor Category: Refactor 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.

[FEATURE]: [Cybersource] Currency Unit Conversion
5 participants