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

Sales Order Payment is complicated #744

Closed
ihor-sviziev opened this issue Nov 14, 2014 · 8 comments
Closed

Sales Order Payment is complicated #744

ihor-sviziev opened this issue Nov 14, 2014 · 8 comments
Assignees
Labels
improvement Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@ihor-sviziev
Copy link
Contributor

For now this class is very complicated and hard to understand their logic
https://github.com/magento/magento2/blob/master/app/code/Magento/Sales/Model/Order/Payment.php#L1036

@ooxi
Copy link

ooxi commented Nov 18, 2014

I like how trivalent logic is implemented using true, false and -1. However it would be even better if we could replace -1 with file not found ;)

@mcspronko
Copy link

@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.

Thanks.

@vpelipenko
Copy link
Contributor

Internal ticket: MAGETWO-31585

@vpelipenko vpelipenko removed the TECH label Jan 27, 2015
@vpelipenko vpelipenko added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development PROD labels Feb 16, 2015
@ilol ilol assigned asemenenko and unassigned elenleonova Mar 2, 2015
@ihor-sviziev
Copy link
Contributor Author

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.

@vpelipenko
Copy link
Contributor

@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.

@vpelipenko
Copy link
Contributor

@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.

@ihor-sviziev
Copy link
Contributor Author

@vpelipenko really good progress, now it looks better, but not enough. What I think we should improve:

  1. 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(),
  2. In few methods we have comaration "==" instead of "===", as result we may have some unexpected behavior. Examples: updateOrder(), _void(), isCaptureFinal(), isSameCurrency(), _getInvoiceForTransactionId(), setOrderStatePaymentReview(), registerRefundNotification(),
  3. 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).

@piotrekkaminski
Copy link
Contributor

Thank you for your submission.

We recently made some changes to the way we process GitHub submissions to more quickly identify and respond to core code issues.

Feature Requests and Improvements should now be submitted to the new Magento 2 Feature Requests and Improvements forum (see details here).

We are closing this GitHub ticket and have moved your request to the new forum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

10 participants