Magento 2.1 Payment Method
initialize: Instantiate state and set it to state object. Method that will be executed instead of authorize or capture if flag isInitializeNeeded set to true.
validate: Validate payment method information that means validate payment method is allowed for billing country or not.
- order: Check order availability.
- authorize: Payment process authorize only. After authorize, you need to capture amount manually.
- capture: Capture payment amount. When this method called, system automatically capture amount.
- refund: Refund specified amount for payment.
- cancel: Cancel payment.
- void: void specified amount for payment. Some payment method don't allow refund within 24hrs. So in that case you need to call void for refund that amount.
[Update]
Where actually during checkout process does authorize and capture is being called?
Solution:
Open Magento/Sales/Model/Order/Payment.php Check following method.
- place
- processAction
It's as deprecated approach to extend \Magento\Payment\Model\Method\AbstractMethod
, instead, you should use Magento payment gateway.
You can find the step-by-step guide how to implement payment method on Magento 2 dev docs based on Magento payment gateway.
Also, Magento has sale
(authorize & capture) payment action - it's similar to authorize
, but allows process the capturing action for an authorized transaction.
This post describes how to implement sale
payment action - https://community.magento.com/t5/Magento-DevBlog/The-Magento-Sale-Payment-Operation/ba-p/67251.