-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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): [Shift4]Enhance currency Mapping with ConnectorCurrencyCommon Trait #2557
Conversation
Hi @sanketmp , Please use following cargo commands -
|
ran the |
You might also should run |
I have done that too. I don't know what is happening. |
@@ -61,6 +61,10 @@ impl ConnectorCommon for Shift4 { | |||
"shift4" | |||
} | |||
|
|||
fn get_currency_unit(&self) -> api::CurrencyUnit { | |||
api::CurrencyUnit::Base |
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.
api::CurrencyUnit::Base | |
api::CurrencyUnit::Minor |
This is because, shift4 accepts amount in minor units
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.
made the changes
{ | ||
type Error = error_stack::Report<errors::ConnectorError>; | ||
fn try_from( | ||
(currency_unit, currency, amount, item): ( |
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.
(currency_unit, currency, amount, item): ( | |
(currency_unit, currency, amount, router_data): ( |
let amount = utils::get_amount_as_string(currency_unit, amount, currency)?; | ||
Ok(Self { | ||
amount, | ||
router_data: item, |
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.
router_data: item, | |
router_data, |
{ | ||
type Error = Error; | ||
type Error = error_stack::Report<errors::ConnectorError>; | ||
// fn try_from( |
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.
can you please remove these comments?
fn try_from( | ||
item: &types::RouterData<T, types::PaymentsAuthorizeData, types::PaymentsResponseData>, | ||
value: (&Shift4RouterData< |
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.
can you please rename value to item
value: (&Shift4RouterData< | |
item: (&Shift4RouterData< |
let currency = item.request.currency; | ||
let payment_method = Shift4PaymentMethod::try_from(item)?; | ||
let submit_for_settlement = value.request.is_auto_capture()?; | ||
let amount = value.request.amount.to_string(); |
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.
let amount = value.request.amount.to_string(); | |
let amount = item.amount.clone(); |
Hello @prasunna09, made the requested changes. |
Hey @sanketmp, could you address the failing CI checks? |
I couldn't figure out @SanchithHegde |
@sanketmp As mentioned earlier in #2557 (comment), you must run |
Type of Change
Description
This pull request introduces the get_currecny_unit from ConnectorCommon trait for shift4. This function allows connectors to declare their accepted currency unit as either "Base" or "Minor".
Additional Changes
Motivation and Context
Closes #2245
How did you test it?
(Please review the changes and let me know if any further issues or changes to be made.)
Checklist
cargo +nightly fmt --all
cargo clippy