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

feat(core): enable surcharge support for all connectors #3109

Merged
merged 10 commits into from
Dec 14, 2023

Conversation

hrithikesh026
Copy link
Contributor

@hrithikesh026 hrithikesh026 commented Dec 11, 2023

Type of Change

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

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

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

Motivation and Context

How did you test it?

Manual

Surcharge on stripe
Screenshot 2023-12-12 at 4 50 12 PM

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

@hrithikesh026 hrithikesh026 added C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Dec 11, 2023
@hrithikesh026 hrithikesh026 added this to the December 2023 Release milestone Dec 11, 2023
@hrithikesh026 hrithikesh026 self-assigned this Dec 11, 2023
@hrithikesh026 hrithikesh026 requested review from a team as code owners December 11, 2023 18:43
Narayanbhat166
Narayanbhat166 previously approved these changes Dec 12, 2023
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> {
Copy link
Contributor

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

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

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?

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Dec 14, 2023
Merged via the queue into main with commit 57e1ae9 Dec 14, 2023
10 of 12 checks passed
@Gnanasundari24 Gnanasundari24 deleted the surcharge-for-all-connectors branch December 14, 2023 06:22
lsampras pushed a commit that referenced this pull request Dec 15, 2023
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants