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

Handle partial captures #268

Merged
merged 1 commit into from
Apr 11, 2023
Merged

Conversation

waiting-for-dev
Copy link
Contributor

@waiting-for-dev waiting-for-dev commented Mar 31, 2023

Summary

Stripe allows for a payment to be partially captured, creating a refund for the remaining amount.

We're now acting accordingly by changing how we handle the payment_intent.succeeded webhook. When the capture is total, we do as before. For partial captures, on top of the latter, we create a Solidus refund for the uncaptured amount.

Closes #221

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@codecov
Copy link

codecov bot commented Mar 31, 2023

Codecov Report

Merging #268 (f3632d5) into master (be652e6) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #268      +/-   ##
==========================================
+ Coverage   99.56%   99.58%   +0.01%     
==========================================
  Files          26       26              
  Lines         460      477      +17     
==========================================
+ Hits          458      475      +17     
  Misses          2        2              
Impacted Files Coverage Δ
...ribers/solidus_stripe/webhook/charge_subscriber.rb 100.00% <ø> (ø)
app/models/solidus_stripe/payment_method.rb 100.00% <100.00%> (ø)
...olidus_stripe/webhook/payment_intent_subscriber.rb 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

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

👍

@waiting-for-dev waiting-for-dev marked this pull request as draft March 31, 2023 19:32
@waiting-for-dev waiting-for-dev force-pushed the waiting-for-dev/partial_capture branch from e47d22a to 2e20c51 Compare April 11, 2023 10:07
Stripe allows for a payment to be partially captured, creating a refund
for the remaining amount [1].

We're now acting accordingly by changing how we handle the
`payment_intent.succeeded` webhook. When the capture is total, we do as
before. For partial captures, on top of the latter, we create a Solidus refund
for the uncaptured amount.

[1] - https://stripe.com/docs/payments/place-a-hold-on-a-payment-method#capture-funds

Closes #221
@waiting-for-dev waiting-for-dev force-pushed the waiting-for-dev/partial_capture branch from 2e20c51 to f3632d5 Compare April 11, 2023 10:19
@waiting-for-dev waiting-for-dev marked this pull request as ready for review April 11, 2023 10:30
Copy link
Contributor

@rainerdema rainerdema left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this @waiting-for-dev 🙌 Looks great!

@waiting-for-dev waiting-for-dev merged commit d86549b into master Apr 11, 2023
@waiting-for-dev waiting-for-dev deleted the waiting-for-dev/partial_capture branch April 11, 2023 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle partial captures from the Stripe dashboard
4 participants