-
-
Notifications
You must be signed in to change notification settings - Fork 725
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
Stripe stock check #7779
Stripe stock check #7779
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7779 +/- ##
===========================================
- Coverage 93.27% 15.25% -78.02%
===========================================
Files 637 568 -69
Lines 18136 22858 +4722
===========================================
- Hits 16916 3488 -13428
- Misses 1220 19370 +18150
Continue to review full report at Codecov.
|
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.
This looks great, we just need a small update based on #7708 being merged.
@@ -102,7 +102,10 @@ def valid_order_line_items? | |||
distributes_order_variants?(@order) | |||
end | |||
|
|||
def redirect_to_cart_path | |||
def handle_invalid_stock |
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.
Nice renaming 👍
def cancel_incomplete_payments | ||
# The checkout could not complete due to stock running out. We void any pending (incomplete) | ||
# Stripe payments here as the order will need to be changed and resubmitted (or abandoned). | ||
@order.payments.pending.each(&:void!) |
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.
Now that #7708 is merged, I think the payment will be in the requires_authorization
state in OFN. Since this code is being called in the case where the authorization succeeded, we should probably move the payment to the complete
state (to reflect the successful authorization) and then call void
on it because the stock is no longer available. We'll want to rebase before testing as well.
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.
Nice!
I'm moving it back to in-dev for rebasing and conflict resolution.
This can occur when stock is reduced after the user is redirected to Stripe and before they are redirected back. The stock is insufficient, the order is not complete, the user is bounced back to the cart, but a *pending* Stripe payment is left on the order.
9575d3c
to
a199f80
Compare
I've rebased and added a couple of commits here to allow voiding payments in |
Otherwise we can end up with duplicate transaction fees for voided payments.
83980a6
to
8e1631b
Compare
Thanks @filipefurtad0 I added an extra commit so now those transaction fees on canceled payment should be marked as ineligible and should not appear in the order total. |
Hey @Matt-Yorkley , That's great, after this PR and going through the same scenario as before:
So far so good 👍 However, from the notes on this PR:
We still can see both payments on Stripe, (1) and (2): The first payment attempt (1) above appears in Stripe as an authorized, but Should we merge and address this second bit in a separate PR? |
We'll go with this approach, as discussed via DM 👍 |
Merging (following discussion in Slack) 👍 |
What? Why?
Related to #7692
Handles Stripe payments when checkout fails due to stock issues (frontoffice).
This can occur when stock is reduced after the user is redirected to Stripe and before they are redirected back. The stock is insufficient, the order is not complete, the user is bounced back to the cart, but a pending Stripe payment is left on the order.
This explicitly voids the leftover payment when the checkout fails in this case, so it's not sitting there in the Stripe account. Also improves user feedback so the user is informed the payment they just authorized has been canceled instead of captured.
What should we test?
Checkout with Stripe where the user is redirected for authorization and the stock runs out before they have finished authorizing.
Release notes
Changelog Category: Technical changes