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

Support sale operation by Magento payment provider gateway #9

Merged
merged 3 commits into from
Jan 3, 2019

Conversation

viktym
Copy link
Contributor

@viktym viktym commented Jul 24, 2018

Design for task "Support sale operation out of the box" from Payment Improvements organization scope.

https://app.zenhub.com/workspace/o/magento/payment-improvements/issues/11

For the current moment, we have next relations in order payment workflow.
![](sale_payment_operation_img/order_payment_current.png)

I propose to introduce `SaleOperationInterface` and `Magento\Payment\Model\Method\Adapter` should implement this interface along with `Magento\Payment\Model\MethodInterface`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please describe this interface with methods signatures. For sure it would be similar to canAuthorize/authorize, canCapture/capture methods but it's better to document this explicitly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the diagram, there are no full methods signatures (input and output types)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@paliarush paliarush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. On the order_payment_current diagram PaymentAdapter does not have order method defined, but it is invoked by OrderOperation::order if I'm not mistaken
  2. On the order_payment_new diagram PaymentAdapter does not have order and authorize methods defined, but they are invoked by other classes
  3. It looks like it would be cleaner if we split MethodInterface into smaller ones, like SaleOperationInterface. At least in 2.3+, which still allows breaking changes. In this case we should deprecate the MethodInterface and redirect all calls to the new interfaces


## Backward compatibility
- New @api interface `SaleOperationInterface` should be introduced - **MINOR** change according to SemVer
- Two public methods should be added in `Magento\Payment\Model\Method\Adapter` @api class - *sale()* and *canSale()*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods will have implementation as far as I understand, if so - this will be minor change, otherwise it will be a major change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The base implementation of sale() and canSale() will be in Magento\Payment\Model\Method\Adapter as it is the main extension point for payment integrations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they will

@joni-jones
Copy link
Contributor

joni-jones commented Jul 25, 2018

Hi, @paliarush.
1-2.The PaymentAdapter on the diagram it is \Magento\Payment\Model\Method\Adapter but not the \Magento\Sales\Model\Order\PaymentAdapter (it does not implement \Magento\Payment\Model\MethodInterface). All methods like authorize, capture, sale, order are present in \Magento\Payment\Model\MethodInterface.
3. This is not a part of this task. Decomposition of MethodInterface requires deep refactoring of \Magento\Payment\Model\Method\Adapter which now is the main extension point for all payments integrations. Such changes will require rework of all payment integrations based on Payment Adapter. Changing only interfaces won't get a practical profit.

@viktym
Copy link
Contributor Author

viktym commented Jul 26, 2018

Hi Alex
As @joni-jones already mentioned, PaymentAdapter is actually \Magento\Payment\Model\Method\Adapter. For compactness, I used short class names on diagrams and it caused some misunderstanding. Diagrams have been corrected.
MethodInterface splitting requires serious changes and should be investigated. We must evaluate the benefits of such a separation against risks and complexity. I suppose it can be done in the separate scope.

@buskamuza buskamuza merged commit 818c18e into magento:master Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants