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 payment refund when payment is partially captured #2991

Merged
merged 4 commits into from
Nov 28, 2023

Conversation

hrithikesh026
Copy link
Contributor

@hrithikesh026 hrithikesh026 commented Nov 28, 2023

Type of Change

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

Description

Currently, payment refund would only happen when intent status is succeeded(full capture).
With this change, it would be possible to refund the payment even when if is partially captured

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

  1. Create merchant with stripe connector.
  2. Create a payment with confirm = true, capture = manual
  3. Later, partially capture the payment ("amount_to_capture < amount"). (status changes to partially_captured)
  4. Then do a refund on the above payment for the captured amount.

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 A-core Area: Core flows C-feature Category: Feature request or enhancement labels Nov 28, 2023
@hrithikesh026 hrithikesh026 added this to the November 2023 Release milestone Nov 28, 2023
@hrithikesh026 hrithikesh026 self-assigned this Nov 28, 2023
@hrithikesh026 hrithikesh026 requested review from a team as code owners November 28, 2023 07:21
jarnura
jarnura previously approved these changes Nov 28, 2023
@@ -75,7 +81,7 @@ pub async fn refund_create_core(
})?;

payment_attempt = db
.find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(
Copy link
Member

Choose a reason for hiding this comment

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

you can refactor the existing method to accept a vector of payment statuses, you can create an issue for this and take up in a separate PR

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Nov 28, 2023
Merged via the queue into main with commit 837480d Nov 28, 2023
10 of 12 checks passed
@Gnanasundari24 Gnanasundari24 deleted the enable-refund-when-partially-captured branch November 28, 2023 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants