| Server IP : 213.186.33.4 / Your IP : 216.73.216.193 Web Server : Apache System : Linux webm006.cluster103.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : awebpaca ( 35430) PHP Version : 8.5.0 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/awebpaca/boutiques/app/code/core/Mage/Sales/Model/Quote/ |
Upload File : |
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Sales
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Quote payment information
*/
class Mage_Sales_Model_Quote_Payment extends Mage_Payment_Model_Info
{
protected $_eventPrefix = 'sales_quote_payment';
protected $_eventObject = 'payment';
protected $_quote;
/**
* Initialize resource model
*/
protected function _construct()
{
$this->_init('sales/quote_payment');
}
/**
* Declare quote model instance
*
* @param Mage_Sales_Model_Quote $quote
* @return Mage_Sales_Model_Quote_Payment
*/
public function setQuote(Mage_Sales_Model_Quote $quote)
{
$this->_quote = $quote;
$this->setQuoteId($quote->getId());
return $this;
}
/**
* Retrieve quote model instance
*
* @return Mage_Sales_Model_Quote
*/
public function getQuote()
{
return $this->_quote;
}
/**
* Import data array to payment method object,
* Method calls quote totals collect because payment method availability
* can be related to quote totals
*
* @param array $data
* @throws Mage_Core_Exception
* @return Mage_Sales_Model_Quote_Payment
*/
public function importData(array $data)
{
$data = new Varien_Object($data);
Mage::dispatchEvent(
$this->_eventPrefix . '_import_data_before',
array(
$this->_eventObject=>$this,
'input'=>$data,
)
);
$this->setMethod($data->getMethod());
$method = $this->getMethodInstance();
/**
* Payment avalability related with quote totals.
* We have recollect quote totals before checking
*/
$this->getQuote()->collectTotals();
if (!$method->isAvailable($this->getQuote())) {
Mage::throwException(Mage::helper('sales')->__('The requested Payment Method is not available.'));
}
$method->assignData($data);
/*
* validating the payment data
*/
$method->validate();
return $this;
}
/**
* Prepare object for save
*
* @return Mage_Sales_Model_Quote_Payment
*/
protected function _beforeSave()
{
try {
$method = $this->getMethodInstance();
} catch (Mage_Core_Exception $e) {
return parent::_beforeSave();
}
$method->prepareSave();
if ($this->getQuote()) {
$this->setQuoteId($this->getQuote()->getId());
}
return parent::_beforeSave();
}
/**
* Checkout redirect URL getter
*
* @return string
*/
public function getCheckoutRedirectUrl()
{
$method = $this->getMethodInstance();
if ($method) {
return $method->getCheckoutRedirectUrl();
}
return '';
}
/**
* Checkout order place redirect URL getter
*
* @return string
*/
public function getOrderPlaceRedirectUrl()
{
$method = $this->getMethodInstance();
if ($method) {
return $method->getOrderPlaceRedirectUrl();
}
return '';
}
/**
* Retrieve payment method model object
*
* @return Mage_Payment_Model_Method_Abstract
*/
public function getMethodInstance()
{
$method = parent::getMethodInstance();
return $method->setStore($this->getQuote()->getStore());
}
}