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

Mage_Payment - DOC block update #760

Merged
merged 2 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

/**
* Recurring profile info/options product view block
*
* @method $this setDateHtmlId(string $string)
*/
class Mage_Payment_Block_Catalog_Product_View_Profile extends Mage_Core_Block_Template
{
Expand Down Expand Up @@ -78,7 +80,7 @@ public function getDateHtml()
/**
* Determine current product and initialize its recurring profile model
*
* @return $this
* @inheritDoc
*/
protected function _prepareLayout()
{
Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Payment/Block/Form/Banktransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,4 @@ public function getInstructions()
}
return $this->_instructions;
}

}
1 change: 0 additions & 1 deletion app/code/core/Mage/Payment/Block/Form/Cashondelivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,4 @@ public function getInstructions()
}
return $this->_instructions;
}

}
12 changes: 9 additions & 3 deletions app/code/core/Mage/Payment/Block/Form/Cc.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getCcAvailableTypes()
$availableTypes = $method->getConfigData('cctypes');
if ($availableTypes) {
$availableTypes = explode(',', $availableTypes);
foreach ($types as $code=>$name) {
foreach ($types as $code => $name) {
if (!in_array($code, $availableTypes)) {
unset($types[$code]);
}
Expand Down Expand Up @@ -106,7 +106,7 @@ public function hasVerification()
{
if ($this->getMethod()) {
$configData = $this->getMethod()->getConfigData('useccv');
if(is_null($configData)){
if (is_null($configData)) {
return true;
}
return (bool) $configData;
Expand All @@ -117,6 +117,9 @@ public function hasVerification()
/*
* Whether switch/solo card type available
*/
/**
* @return bool
*/
public function hasSsCardType()
{
$availableTypes = explode(',', $this->getMethod()->getConfigData('cctypes'));
Expand All @@ -131,7 +134,10 @@ public function hasSsCardType()
* solo/switch card start year
* @return array
*/
public function getSsStartYears()
/**
* @return array
*/
public function getSsStartYears()
{
$years = array();
$first = date("Y");
Expand Down
1 change: 0 additions & 1 deletion app/code/core/Mage/Payment/Block/Form/Ccsave.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ protected function _construct()
parent::_construct();
$this->setTemplate('payment/form/ccsave.phtml');
}

}
1 change: 0 additions & 1 deletion app/code/core/Mage/Payment/Block/Form/Checkmo.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ protected function _construct()
parent::_construct();
$this->setTemplate('payment/form/checkmo.phtml');
}

}
15 changes: 7 additions & 8 deletions app/code/core/Mage/Payment/Block/Form/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ protected function _prepareLayout()
*/
foreach ($this->getMethods() as $method) {
$this->setChild(
'payment.method.'.$method->getCode(),
$this->helper('payment')->getMethodFormBlock($method)
'payment.method.' . $method->getCode(),
$this->helper('payment')->getMethodFormBlock($method)
);
}

Expand All @@ -63,8 +63,7 @@ protected function _canUseMethod($method)
{
return $method->isApplicableToQuote($this->getQuote(), Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY
| Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY
| Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX
);
| Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX);
}

/**
Expand All @@ -73,7 +72,7 @@ protected function _canUseMethod($method)
* Redeclare this method in child classes for declaring method info instance
*
* @param Mage_Payment_Model_Method_Abstract $method
* @return bool
* @return $this
*/
protected function _assignMethod($method)
{
Expand All @@ -86,9 +85,9 @@ protected function _assignMethod($method)
*
* @param string $method
* @param string $template
* @return Mage_Payment_Block_Form_Container
* @return $this
*/
public function setMethodFormTemplate($method='', $template='')
public function setMethodFormTemplate($method = '', $template = '')
{
if (!empty($method) && !empty($template)) {
if ($block = $this->getChild('payment.method.'.$method)) {
Expand Down Expand Up @@ -127,7 +126,7 @@ public function getMethods()
/**
* Retrieve code of current payment method
*
* @return mixed
* @return string|false
*/
public function getSelectedMethodCode()
{
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/Payment/Block/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
/**
* Base payment iformation block
*
* @method bool hasIsSecureMode()
*/
class Mage_Payment_Block_Info extends Mage_Core_Block_Template
{
Expand Down Expand Up @@ -110,7 +111,7 @@ public function getSpecificInformation()
*
* @param mixed $value
* @param bool $escapeHtml
* @return $array
* @return array $array
*/
public function getValueAsArray($value, $escapeHtml = false)
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Payment/Block/Info/Banktransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getInstructions()
{
if (is_null($this->_instructions)) {
$this->_instructions = $this->getInfo()->getAdditionalInformation('instructions');
if(empty($this->_instructions)) {
if (empty($this->_instructions)) {
$this->_instructions = $this->getMethod()->getInstructions();
}
}
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Payment/Block/Info/Ccsave.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Mage_Payment_Block_Info_Ccsave extends Mage_Payment_Block_Info_Cc
* Expiration date and full number will show up only in secure mode (only for admin, not in emails or pdfs)
*
* @param Varien_Object|array $transport
* @return Varien_Object
*/
protected function _prepareSpecificInformation($transport = null)
{
Expand All @@ -44,7 +45,8 @@ protected function _prepareSpecificInformation($transport = null)
if (!$this->getIsSecureMode()) {
$transport->addData(array(
Mage::helper('payment')->__('Expiration Date') => $this->_formatCardDate(
$info->getCcExpYear(), $this->getCcExpMonth()
$info->getCcExpYear(),
$this->getCcExpMonth()
),
Mage::helper('payment')->__('Credit Card Number') => $info->getCcNumber(),
));
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Payment/Block/Info/Checkmo.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ protected function _convertAdditionalData()
return $this;
}

/**
* @return string
*/
public function toPdf()
{
$this->setTemplate('payment/info/pdf/checkmo.phtml');
return $this->toHtml();
}

}
8 changes: 4 additions & 4 deletions app/code/core/Mage/Payment/Block/Info/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Mage_Payment_Block_Info_Container extends Mage_Core_Block_Template
/**
* Add payment info block to layout
*
* @return $this
* @inheritDoc
*/
protected function _prepareLayout()
{
Expand All @@ -52,7 +52,7 @@ protected function _prepareLayout()
/**
* Retrieve info block name
*
* @return unknown
* @return false|string
*/
protected function _getInfoBlockName()
{
Expand All @@ -65,7 +65,7 @@ protected function _getInfoBlockName()
/**
* Retrieve payment info model
*
* @return Mage_Payment_Model_Info
* @return Mage_Payment_Model_Info|false
*/
public function getPaymentInfo()
{
Expand All @@ -79,7 +79,7 @@ public function getPaymentInfo()
* @param string $template
* @return Mage_Payment_Block_Info_Container
*/
public function setInfoTemplate($method='', $template='')
public function setInfoTemplate($method = '', $template = '')
{
if ($info = $this->getPaymentInfo()) {
if ($info->getMethodInstance()->getCode() == $method) {
Expand Down
3 changes: 3 additions & 0 deletions app/code/core/Mage/Payment/Block/Info/Purchaseorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ protected function _construct()
$this->setTemplate('payment/info/purchaseorder.phtml');
}

/**
* @return string
*/
public function toPdf()
{
$this->setTemplate('payment/info/pdf/purchaseorder.phtml');
Expand Down
8 changes: 8 additions & 0 deletions app/code/core/Mage/Payment/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,20 @@ class Mage_Payment_Exception extends Exception
{
protected $_code = null;

/**
* Mage_Payment_Exception constructor.
* @param null $message
* @param int $code
*/
public function __construct($message = null, $code = 0)
{
$this->_code = $code;
parent::__construct($message, 0);
}

/**
* @return int|null
*/
public function getFields()
{
return $this->_code;
Expand Down
17 changes: 11 additions & 6 deletions app/code/core/Mage/Payment/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getMethodInstance($code)
*
* @param mixed $store
* @param Mage_Sales_Model_Quote $quote
* @return array
* @return Mage_Payment_Model_Method_Abstract[]
*/
public function getStoreMethods($store = null, $quote = null)
{
Expand Down Expand Up @@ -83,6 +83,11 @@ public function getStoreMethods($store = null, $quote = null)
return $res;
}

/**
* @param $a
* @param $b
* @return int
*/
protected function _sortMethods($a, $b)
{
if (is_object($a)) {
Expand All @@ -94,8 +99,8 @@ protected function _sortMethods($a, $b)
/**
* Retreive payment method form html
*
* @param Mage_Payment_Model_Abstract $method
* @return Mage_Payment_Block_Form
* @param Mage_Payment_Model_Method_Abstract $method
* @return Mage_Payment_Block_Form|Mage_Core_Block_Abstract
*/
public function getMethodFormBlock(Mage_Payment_Model_Method_Abstract $method)
{
Expand All @@ -112,15 +117,14 @@ public function getMethodFormBlock(Mage_Payment_Model_Method_Abstract $method)
* Retrieve payment information block
*
* @param Mage_Payment_Model_Info $info
* @return Mage_Core_Block_Template
* @return Mage_Core_Block_Template|Mage_Core_Block_Abstract
*/
public function getInfoBlock(Mage_Payment_Model_Info $info)
{
$blockType = $info->getMethodInstance()->getInfoBlockType();
if ($this->getLayout()) {
$block = $this->getLayout()->createBlock($blockType);
}
else {
} else {
$className = Mage::getConfig()->getBlockClassName($blockType);
$block = new $className;
}
Expand Down Expand Up @@ -194,6 +198,7 @@ public function getPaymentMethods($store = null)
* @param bool $sorted
* @param bool $asLabelValue
* @param bool $withGroups
* @param null $store
* @return array
*/
public function getPaymentMethodList($sorted = true, $asLabelValue = false, $withGroups = false, $store = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
* Billing Agreement abstaract class
*
* @author Magento Core Team <core@magentocommerce.com>
*
* @method string getMethodCode()
* @method string getReferenceId()
* @method int getStoreId()
*/
abstract class Mage_Payment_Model_Billing_AgreementAbstract extends Mage_Core_Model_Abstract
{
Expand Down
15 changes: 10 additions & 5 deletions app/code/core/Mage/Payment/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Mage_Payment_Model_Config
* @param mixed $store
* @return array
*/
public function getActiveMethods($store=null)
public function getActiveMethods($store = null)
{
$methods = array();
$config = Mage::getStoreConfig('payment', $store);
Expand All @@ -66,7 +66,7 @@ public function getActiveMethods($store=null)
* @param mixed $store
* @return array
*/
public function getAllMethods($store=null)
public function getAllMethods($store = null)
{
$methods = array();
$config = Mage::getStoreConfig('payment', $store);
Expand All @@ -79,7 +79,13 @@ public function getAllMethods($store=null)
return $methods;
}

protected function _getMethod($code, $config, $store=null)
/**
* @param $code
* @param $config
* @param null $store
* @return bool
*/
protected function _getMethod($code, $config, $store = null)
{
if (isset(self::$_methods[$code])) {
return self::$_methods[$code];
Expand Down Expand Up @@ -171,11 +177,10 @@ static function compareCcTypes($a, $b)

if ($a['order'] == $b['order']) {
return 0;
} else if ($a['order'] > $b['order']) {
} elseif ($a['order'] > $b['order']) {
return 1;
} else {
return -1;
}

}
}
Loading