I have doubts about how quotes and orders are triggered in the payment method. I know Quote is a set of products or services offered. In magento Quote, data is created immediately before clicking the "Order Order" Onepage Checkout button. After placing an order, order data is created in Magento. An invoice is delivered next to the order if the order is confirmed.
But I was wondering why the Mage_Payment_Model_Method_Abstract class in the method check checks an instance of the Info class, if it is an instance of Mage_Sales_Model_Order_Payment, take getOrder (), take getQuote ()
I do not understand. Does the function Validate () call two times the first time when creating a quote and the second time when creating an order, or does the class of the payment method itself be called twice.
Please clarify my confusion.
public function validate() { $paymentInfo = $this->getInfoInstance(); if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) { $billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId(); } else { $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId(); } if (!$this->canUseForCountry($billingCountry)) { Mage::throwException($this->_getHelper()->__('Selected payment type is not allowed for billing country.')); } return $this; }
source share