-
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
feat(core): enable surcharge support for all connectors #3109
Conversation
pub fn get_total_amount(&self) -> i64 { | ||
self.amount + self.surcharge_amount.unwrap_or(0) + self.tax_amount.unwrap_or(0) | ||
} | ||
pub fn get_total_surcharge_amount(&self) -> Option<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.
Why can't this method return i64 instead of option, However we are always using unwrap_or(0) on the results of this method
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.
Purpose of this method is to return total surcharge amount only if surcharge is present in payment_attempt. Otherwise None.
@@ -178,6 +178,8 @@ impl MultipleCaptureData { | |||
|
|||
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] | |||
pub struct SurchargeDetails { | |||
/// original_amount | |||
pub original_amount: 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.
Shall we rename this to payment amount instead of original_amount?
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.
There is another field in this struct called final_amount
. The idea was final_amount = original_amount + surcharge_amount + tax_on_surcharge_amount
.
So final_amount is treated as payment_amount.
Wouldn't changing original_amount to payment_amount be contradicting?
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Type of Change
Description
Bring support for surcharge feature for all connector by handling all surcharge_amount related calculation at core and send the final amount to connector side.
Also remove connector surcharge_validation check in decide_flows() of authorize flow.
Additional Changes
Motivation and Context
How did you test it?
Manual
Surcharge on stripe
Checklist
cargo +nightly fmt --all
cargo clippy