@ihor-sviziev, thank you for your note. We have plan to reducing complexity in the system. This issue will be added to our backlog. We will update you when it will be ready. Also, you may want to provide proposal on how you see this class might be refactored.
Now this class logic looks much better, but now it still contains ~2600 lines of code, I think we may separate class functionality to two or more classes and use delegation.
I think first of all we should move methods like place, capture, registerCaptureNotification, refund, registerRefundNotification, accept, deny, update, authorize.
@ihor-sviziev, when we have time we try to decrease code complexity and re-implement complicated classes in sales/payment infrastructure, but this work doesn't have high priority, that's why we can't promise that suggested refactoring will be done in the near future.
@ihor-sviziev, we've done some work around complicated Sales Order Payment. If you compare this class in develop and master branch, you will see that about 400 lines of code were removed from it. Please, look at our changes. All feedback from your side is welcome.
@vpelipenko really good progress, now it looks better, but not enough. What I think we should improve:
There is a lot of methods have public methods (not public only), that will receive object, but object type is not declared in method. As result we may got not expected method and fatal error if retrieved null. Example methods: pay(), cancelInvoice(), refund(), cancelCreditmemo(), updateBaseAmountPaidOnlineTotal(), _updateTotals(), prepareCreditMemo(),
In few methods we have comaration "==" instead of "===", as result we may have some unexpected behavior. Examples: updateOrder(), _void(), isCaptureFinal(), isSameCurrency(), _getInvoiceForTransactionId(), setOrderStatePaymentReview(), registerRefundNotification(),
This class still contains a lot of getters, setters and business logic (as example place(), pay(), cancelInvoice() ). Would be great move this business logic to some another class(es) and just execute methods (as it done for capture() method).