- 🇺🇦Ukraine marchuk.vitaliy Rivne, UA
New patch compatible with the latest dev version.
- Status changed to Needs work
over 1 year ago 2:28pm 29 May 2023 - 🇮🇱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:
- Use a GET request when building the operations to present the appropriate one based on settlement status (i.e. void vs. refund).
- 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 3:40pm 30 May 2023 - Status changed to Fixed
over 1 year ago 6:38am 31 May 2023 -
jsacksick →
committed c36cf0d9 on 8.x-1.x authored by
khiminrm →
Issue #3003273 by khiminrm, marchuk.vitaliy, rszrama, jsacksick: Add the...
-
jsacksick →
committed c36cf0d9 on 8.x-1.x authored by
khiminrm →
Automatically closed - issue fixed for 2 weeks with no activity.