Add the ability to void an unsettled capture

Created on 29 September 2018, about 6 years ago
Updated 31 May 2023, over 1 year ago

If a transaction was auth+capture, the transaction cannot be voided until it settles.

Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇺🇸United States mglaman WI, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇦Ukraine marchuk.vitaliy Rivne, UA

    New patch compatible with the latest dev version.

  • Status changed to Needs work over 1 year ago
  • 🇮🇱Israel jsacksick

    The patch looks incorrect, in case of error it seems we're looping on the error and recalling the same method? This doesn't seem to make sense, also not really sure why we are allowing voiding completed payments? This doesn't make sense.

  • 🇺🇸United States rszrama

    Looked into this a little more with jsacksick today. Braintree does in fact give us the ability to request the settlement status for a transaction, and it also has the means to push out settlement updates via webhooks. However, Commerce Core does not have a great place to model this information. One problem, for example, is that the same Payment entity is currently used for both an initial payment and its subsequent refund, when both of those are distinct transactions with their own settlement cycles at the processor. Thus, even if we had a way to add a "settlement status" field to a Payment, which one does that refer to? And if we're going to add multiple ... well ... you can endlessly optimize.

    So, we have two basic options:

    1. Use a GET request when building the operations to present the appropriate one based on settlement status (i.e. void vs. refund).
    2. When a refund is attempted, if we get that 91506 error code indicating a refund can't process until settlement occurs, we fall back to voiding the pending settlement at Braintree but still treat it as a refund within Commerce (since we're undoing what we previously treated as a captured payment).

    While #1 is more precise, and I'd normally favor precision, there are two basic problems with it. First, we don't know if a site may have created a custom view of payment entities that adding dozens of external API requests to may degrade. Second, and more important, it isn't foolproof: a form could be presented based on a settlement still being pending but then the form could be submitted after the settlement date is passed, so we'd still need the fallback in #2.

    Therefore, let's go for #2, which is a variation on the current patch. When a refund is attempted, if it fails due to error 91506, we should attempt a void. If the void is successful, we should indicate the refund was successful so it can be recorded appropriately on the payment.

  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States rszrama

    +1 from me

  • Status changed to Fixed over 1 year ago
  • 🇮🇱Israel jsacksick

    Committed, thanks Roman!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024