Version Notes
1.New secure communication protocal.
Download this release
Release Info
| Developer | Warrin |
| Extension | Ced_LayBuy |
| Version | 2.1.8.4 |
| Comparing to | |
| See all releases | |
Code changes from version 2.1.8.3 to 2.1.8.4
- app/code/local/Ced/LayBuy/Block/Express/Layform.php +43 -0
- app/code/local/Ced/LayBuy/Block/Express/Layshortcut.php +28 -0
- app/code/local/Ced/LayBuy/Block/Express/Redirect.php +55 -0
- app/code/local/Ced/LayBuy/Block/Express/Review.php +259 -0
- app/code/local/Ced/LayBuy/Block/Express/Review/Billing.php +59 -0
- app/code/local/Ced/LayBuy/Block/Express/Review/Details.php +60 -0
- app/code/local/Ced/LayBuy/Block/Express/Review/Shipping.php +53 -0
- app/code/local/Ced/LayBuy/Block/Payment/Info.php +63 -0
- app/code/local/Ced/LayBuy/Helper/Data.php +25 -3
- app/code/local/Ced/LayBuy/Model/Abstract.php +168 -0
- app/code/local/Ced/LayBuy/Model/Config.php +1419 -0
- app/code/local/Ced/LayBuy/Model/Express.php +771 -0
- app/code/local/Ced/LayBuy/Model/Laybuyresp.php +12 -0
- app/code/local/Ced/LayBuy/Model/Mysql4/Laybuyresp.php +11 -0
- app/code/local/Ced/LayBuy/Model/Mysql4/Laybuyresp/Collection.php +37 -0
- app/code/local/Ced/LayBuy/Model/Mysql4/Region/Collection.php +50 -0
- app/code/local/Ced/LayBuy/Model/Pro.php +484 -0
- app/code/local/Ced/LayBuy/controllers/ExpressController.php +1841 -0
- app/code/local/Ced/LayBuy/etc/config.xml +213 -189
- app/code/local/Ced/LayBuy/etc/system.xml +296 -278
- app/code/local/Ced/LayBuy/sql/laybuy_setup/mysql4-upgrade-1.0.0-1.0.1.php +16 -0
- app/design/frontend/base/default/layout/laybuy.xml +81 -0
- app/design/frontend/base/default/template/laybuy/express/extraexpress.phtml +154 -0
- app/design/frontend/base/default/template/laybuy/express/layshortcut.phtml +41 -0
- app/design/frontend/base/default/template/laybuy/express/layshortcut1.phtml +17 -0
- app/design/frontend/base/default/template/laybuy/express/review.phtml +176 -0
- app/design/frontend/base/default/template/laybuy/express/review/address.phtml +146 -0
- app/design/frontend/base/default/template/laybuy/express/review/details.phtml +64 -0
- app/design/frontend/base/default/template/laybuy/express/review/shipping/method.phtml +53 -0
- package.xml +6 -7
- skin/frontend/base/default/images/laybuy/closeBtn.png +0 -0
app/code/local/Ced/LayBuy/Block/Express/Layform.php
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ced_LayBuy_Block_Express_Layform extends Mage_Core_Block_Template
|
| 3 |
+
{
|
| 4 |
+
protected $_storeId = null;
|
| 5 |
+
|
| 6 |
+
public function getStoreId(){
|
| 7 |
+
if(empty($this->_storeId)){
|
| 8 |
+
$this->_storeId = Mage::app()->getStore()->getId();
|
| 9 |
+
}
|
| 10 |
+
return $this->_storeId;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Block construction. Set block template.
|
| 15 |
+
*/
|
| 16 |
+
protected function _construct()
|
| 17 |
+
{
|
| 18 |
+
//parent::_construct();
|
| 19 |
+
|
| 20 |
+
$laybuyMark = Mage::getConfig()->getBlockClassName('core/template');
|
| 21 |
+
$laybuyMark = new $laybuyMark;
|
| 22 |
+
//$laybuyMark->setTemplate('laybuy/form/laybuy.phtml')
|
| 23 |
+
//->setLayBuyTitle(Mage::helper('laybuy')->__('A recurring payment solution'))
|
| 24 |
+
//->setPaymentAcceptanceMarkSrc('https://lay-buys.com/gateway/LAY-BUY.png')
|
| 25 |
+
//->setPaymentAcceptanceMarkHref('https://lay-buys.com/');
|
| 26 |
+
$note = 'Please Choose Your Payment Plan';
|
| 27 |
+
$this->setTemplate('laybuy/express/extraexpress.phtml')
|
| 28 |
+
->setMethodTitle('')
|
| 29 |
+
->setExtraMessage('<b>'.$this->__('%s',$note).'</b>');
|
| 30 |
+
//->setMethodLabelAfterHtml($laybuyMark->toHtml());
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
public function getArray($type){
|
| 34 |
+
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
|
| 35 |
+
$grandtotal = round($totals["grand_total"]->getValue());
|
| 36 |
+
return Mage::getModel('laybuy/report')->getArray($type,$grandtotal,$this->getStoreId());
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
public function getConfigData($field){
|
| 40 |
+
return Mage::getStoreConfig('payment/laybuy/'.$field,$this->getStoreId());
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
}
|
app/code/local/Ced/LayBuy/Block/Express/Layshortcut.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ced_LayBuy_Block_Express_Layshortcut extends Mage_Core_Block_Template
|
| 3 |
+
{
|
| 4 |
+
const POSITION_BEFORE = 'before';
|
| 5 |
+
const POSITION_AFTER = 'after';
|
| 6 |
+
/**
|
| 7 |
+
* Check is "OR" label position before shortcut
|
| 8 |
+
*
|
| 9 |
+
* @return bool
|
| 10 |
+
*/
|
| 11 |
+
public function isOrPositionBefore()
|
| 12 |
+
{
|
| 13 |
+
return ($this->getIsInCatalogProduct() && !$this->getShowOrPosition())
|
| 14 |
+
|| ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_BEFORE);
|
| 15 |
+
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Check is "OR" label position after shortcut
|
| 20 |
+
*
|
| 21 |
+
* @return bool
|
| 22 |
+
*/
|
| 23 |
+
public function isOrPositionAfter()
|
| 24 |
+
{
|
| 25 |
+
return (!$this->getIsInCatalogProduct() && !$this->getShowOrPosition())
|
| 26 |
+
|| ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_AFTER);
|
| 27 |
+
}
|
| 28 |
+
}
|
app/code/local/Ced/LayBuy/Block/Express/Redirect.php
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Lay-Buys
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Ced
|
| 22 |
+
* @package Ced_LayBuy
|
| 23 |
+
* @author Asheesh Singh<asheeshsingh@cedcoss.com>
|
| 24 |
+
* @copyright Copyright LAY-BUYS (2011). (http://lay-buys.com/)
|
| 25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 26 |
+
*/
|
| 27 |
+
class Ced_LayBuy_Block_Express_Redirect extends Mage_Core_Block_Abstract
|
| 28 |
+
{
|
| 29 |
+
|
| 30 |
+
protected function _toHtml()
|
| 31 |
+
{
|
| 32 |
+
$redirectURL="http://lay-buys.com/expressgateway/";
|
| 33 |
+
$session = Mage::getSingleton('checkout/session');
|
| 34 |
+
$session->setLayBuyStandardQuoteId($session->getQuoteId());
|
| 35 |
+
if ($token=$this->getData('token')) {
|
| 36 |
+
$session->setLayBuyToken($token);
|
| 37 |
+
$redirectURL .= '?TOKEN='.$token;
|
| 38 |
+
$html = '<html><body>';
|
| 39 |
+
$html.= $this->__('You will be redirected to the PayPal website in a few seconds.');
|
| 40 |
+
$html.= '<br><input type="button" onClick="window.location=\''.$redirectURL.'\' " value="'.$this->__('Click here if you are not redirected within 10 seconds...').'" />';
|
| 41 |
+
$html.= '<script type="text/javascript">setTimeout(\'window.location="'.$redirectURL.'"\',1000);</script>';
|
| 42 |
+
$html.= '</body></html>';
|
| 43 |
+
}else{
|
| 44 |
+
$html = '<html><body>';
|
| 45 |
+
$html.= $this->__('You will be redirected to the PayPal website in a few seconds.');
|
| 46 |
+
$html.= '<br><input type="button" onClick="window.location=window.location;" value="'.$this->__('Click here if you are not redirected within 10 seconds...').'" />';
|
| 47 |
+
$html.= '<script type="text/javascript">setTimeout("window.location=window.location;",1000);</script>';
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Paypal Express Onepage checkout block
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Ced_LayBuy_Block_Express_Review extends Mage_Core_Block_Template
|
| 35 |
+
{
|
| 36 |
+
/**
|
| 37 |
+
* @var Mage_Sales_Model_Quote
|
| 38 |
+
*/
|
| 39 |
+
protected $_quote;
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Currently selected shipping rate
|
| 43 |
+
*
|
| 44 |
+
* @var Mage_Sales_Model_Quote_Address_Rate
|
| 45 |
+
*/
|
| 46 |
+
protected $_currentShippingRate = null;
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* Paypal action prefix
|
| 50 |
+
*
|
| 51 |
+
* @var string
|
| 52 |
+
*/
|
| 53 |
+
protected $_paypalActionPrefix = 'paypal';
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Quote object setter
|
| 57 |
+
*
|
| 58 |
+
* @param Mage_Sales_Model_Quote $quote
|
| 59 |
+
* @return Mage_Paypal_Block_Express_Review
|
| 60 |
+
*/
|
| 61 |
+
public function setQuote(Mage_Sales_Model_Quote $quote)
|
| 62 |
+
{
|
| 63 |
+
$this->_quote = $quote;
|
| 64 |
+
return $this;
|
| 65 |
+
}
|
| 66 |
+
public function getPlaceOrderUrl(){
|
| 67 |
+
$url="";
|
| 68 |
+
$url=Mage::getUrl('laybuy/express/placeOrder');
|
| 69 |
+
return $url;
|
| 70 |
+
|
| 71 |
+
}
|
| 72 |
+
public function getUpdateShippingMethodsUrl(){
|
| 73 |
+
$url="";
|
| 74 |
+
$url=Mage::getUrl('laybuy/express/updateShippingMethods');
|
| 75 |
+
return $url;
|
| 76 |
+
|
| 77 |
+
}
|
| 78 |
+
public function getUpdateOrderSubmitUrl(){
|
| 79 |
+
$url="";
|
| 80 |
+
$url=Mage::getUrl('laybuy/express/updateOrder');
|
| 81 |
+
return $url;
|
| 82 |
+
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* Return quote billing address
|
| 88 |
+
*
|
| 89 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 90 |
+
*/
|
| 91 |
+
public function getBillingAddress()
|
| 92 |
+
{
|
| 93 |
+
return $this->_quote->getBillingAddress();
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* Return quote shipping address
|
| 98 |
+
*
|
| 99 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 100 |
+
*/
|
| 101 |
+
public function getShippingAddress()
|
| 102 |
+
{
|
| 103 |
+
if ($this->_quote->getIsVirtual()) {
|
| 104 |
+
return false;
|
| 105 |
+
}
|
| 106 |
+
return $this->_quote->getShippingAddress();
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
/**
|
| 110 |
+
* Get HTML output for specified address
|
| 111 |
+
*
|
| 112 |
+
* @param Mage_Sales_Model_Quote_Address
|
| 113 |
+
* @return string
|
| 114 |
+
*/
|
| 115 |
+
public function renderAddress($address)
|
| 116 |
+
{
|
| 117 |
+
return $address->getFormated(true);
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
/**
|
| 121 |
+
* Return carrier name from config, base on carrier code
|
| 122 |
+
*
|
| 123 |
+
* @param $carrierCode string
|
| 124 |
+
* @return string
|
| 125 |
+
*/
|
| 126 |
+
public function getCarrierName($carrierCode)
|
| 127 |
+
{
|
| 128 |
+
if ($name = Mage::getStoreConfig("carriers/{$carrierCode}/title")) {
|
| 129 |
+
return $name;
|
| 130 |
+
}
|
| 131 |
+
return $carrierCode;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
/**
|
| 135 |
+
* Get either shipping rate code or empty value on error
|
| 136 |
+
*
|
| 137 |
+
* @param Varien_Object $rate
|
| 138 |
+
* @return string
|
| 139 |
+
*/
|
| 140 |
+
public function renderShippingRateValue(Varien_Object $rate)
|
| 141 |
+
{
|
| 142 |
+
if ($rate->getErrorMessage()) {
|
| 143 |
+
return '';
|
| 144 |
+
}
|
| 145 |
+
return $rate->getCode();
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
/**
|
| 149 |
+
* Get shipping rate code title and its price or error message
|
| 150 |
+
*
|
| 151 |
+
* @param Varien_Object $rate
|
| 152 |
+
* @param string $format
|
| 153 |
+
* @param string $inclTaxFormat
|
| 154 |
+
* @return string
|
| 155 |
+
*/
|
| 156 |
+
public function renderShippingRateOption($rate, $format = '%s - %s%s', $inclTaxFormat = ' (%s %s)')
|
| 157 |
+
{
|
| 158 |
+
$renderedInclTax = '';
|
| 159 |
+
if ($rate->getErrorMessage()) {
|
| 160 |
+
$price = $rate->getErrorMessage();
|
| 161 |
+
} else {
|
| 162 |
+
$price = $this->_getShippingPrice($rate->getPrice(),
|
| 163 |
+
$this->helper('tax')->displayShippingPriceIncludingTax());
|
| 164 |
+
|
| 165 |
+
$incl = $this->_getShippingPrice($rate->getPrice(), true);
|
| 166 |
+
if (($incl != $price) && $this->helper('tax')->displayShippingBothPrices()) {
|
| 167 |
+
$renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl);
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
return sprintf($format, $this->escapeHtml($rate->getMethodTitle()), $price, $renderedInclTax);
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
/**
|
| 174 |
+
* Getter for current shipping rate
|
| 175 |
+
*
|
| 176 |
+
* @return Mage_Sales_Model_Quote_Address_Rate
|
| 177 |
+
*/
|
| 178 |
+
public function getCurrentShippingRate()
|
| 179 |
+
{
|
| 180 |
+
return $this->_currentShippingRate;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
/**
|
| 184 |
+
* Set paypal actions prefix
|
| 185 |
+
*/
|
| 186 |
+
public function setPaypalActionPrefix($prefix)
|
| 187 |
+
{
|
| 188 |
+
$this->_paypalActionPrefix = $prefix;
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
/**
|
| 192 |
+
* Return formatted shipping price
|
| 193 |
+
*
|
| 194 |
+
* @param float $price
|
| 195 |
+
* @param bool $isInclTax
|
| 196 |
+
*
|
| 197 |
+
* @return bool
|
| 198 |
+
*/
|
| 199 |
+
protected function _getShippingPrice($price, $isInclTax)
|
| 200 |
+
{
|
| 201 |
+
return $this->_formatPrice($this->helper('tax')->getShippingPrice($price, $isInclTax, $this->_address));
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
/**
|
| 205 |
+
* Format price base on store convert price method
|
| 206 |
+
*
|
| 207 |
+
* @param float $price
|
| 208 |
+
* @return string
|
| 209 |
+
*/
|
| 210 |
+
protected function _formatPrice($price)
|
| 211 |
+
{
|
| 212 |
+
return $this->_quote->getStore()->convertPrice($price, true);
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
/**
|
| 216 |
+
* Retrieve payment method and assign additional template values
|
| 217 |
+
*
|
| 218 |
+
* @return Mage_Paypal_Block_Express_Review
|
| 219 |
+
*/
|
| 220 |
+
protected function _beforeToHtml()
|
| 221 |
+
{
|
| 222 |
+
$methodInstance = $this->_quote->getPayment()->getMethodInstance();
|
| 223 |
+
$this->setPaymentMethodTitle($methodInstance->getTitle());
|
| 224 |
+
$this->setUpdateOrderSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateOrder"));
|
| 225 |
+
$this->setUpdateShippingMethodsUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateShippingMethods"));
|
| 226 |
+
|
| 227 |
+
$this->setShippingRateRequired(true);
|
| 228 |
+
if ($this->_quote->getIsVirtual()) {
|
| 229 |
+
$this->setShippingRateRequired(false);
|
| 230 |
+
} else {
|
| 231 |
+
// prepare shipping rates
|
| 232 |
+
$this->_address = $this->_quote->getShippingAddress();
|
| 233 |
+
$groups = $this->_address->getGroupedAllShippingRates();
|
| 234 |
+
if ($groups && $this->_address) {
|
| 235 |
+
$this->setShippingRateGroups($groups);
|
| 236 |
+
// determine current selected code & name
|
| 237 |
+
foreach ($groups as $code => $rates) {
|
| 238 |
+
foreach ($rates as $rate) {
|
| 239 |
+
if ($this->_address->getShippingMethod() == $rate->getCode()) {
|
| 240 |
+
$this->_currentShippingRate = $rate;
|
| 241 |
+
break(2);
|
| 242 |
+
}
|
| 243 |
+
}
|
| 244 |
+
}
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
// misc shipping parameters
|
| 248 |
+
$this->setShippingMethodSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/saveShippingMethod"))
|
| 249 |
+
->setCanEditShippingAddress($this->_quote->getMayEditShippingAddress())
|
| 250 |
+
->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod())
|
| 251 |
+
;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
$this->setEditUrl($this->getUrl("{$this->_paypalActionPrefix}/express/edit"))
|
| 255 |
+
->setPlaceOrderUrl($this->getUrl("{$this->_paypalActionPrefix}/express/placeOrder"));
|
| 256 |
+
|
| 257 |
+
return parent::_beforeToHtml();
|
| 258 |
+
}
|
| 259 |
+
}
|
app/code/local/Ced/LayBuy/Block/Express/Review/Billing.php
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Paypal Express Onepage checkout block for Billing Address
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Ced_LayBuy_Block_Express_Review_Billing extends Mage_Checkout_Block_Onepage_Billing
|
| 35 |
+
{
|
| 36 |
+
/**
|
| 37 |
+
* Return Sales Quote Address model
|
| 38 |
+
*
|
| 39 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 40 |
+
*/
|
| 41 |
+
public function getAddress()
|
| 42 |
+
{
|
| 43 |
+
if (is_null($this->_address)) {
|
| 44 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getBillingAddress()) {
|
| 45 |
+
$this->_address = $this->getQuote()->getBillingAddress();
|
| 46 |
+
if (!$this->_address->getFirstname()) {
|
| 47 |
+
$this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname());
|
| 48 |
+
}
|
| 49 |
+
if (!$this->_address->getLastname()) {
|
| 50 |
+
$this->_address->setLastname($this->getQuote()->getCustomer()->getLastname());
|
| 51 |
+
}
|
| 52 |
+
} else {
|
| 53 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
return $this->_address;
|
| 58 |
+
}
|
| 59 |
+
}
|
app/code/local/Ced/LayBuy/Block/Express/Review/Details.php
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Paypal Express Onepage checkout block
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Ced_LayBuy_Block_Express_Review_Details extends Mage_Checkout_Block_Cart_Totals
|
| 35 |
+
{
|
| 36 |
+
protected $_address;
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Return review shipping address
|
| 40 |
+
*
|
| 41 |
+
* @return Mage_Sales_Model_Order_Address
|
| 42 |
+
*/
|
| 43 |
+
public function getAddress()
|
| 44 |
+
{
|
| 45 |
+
if (empty($this->_address)) {
|
| 46 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
| 47 |
+
}
|
| 48 |
+
return $this->_address;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Return review quote totals
|
| 53 |
+
*
|
| 54 |
+
* @return array
|
| 55 |
+
*/
|
| 56 |
+
public function getTotals()
|
| 57 |
+
{
|
| 58 |
+
return $this->getQuote()->getTotals();
|
| 59 |
+
}
|
| 60 |
+
}
|
app/code/local/Ced/LayBuy/Block/Express/Review/Shipping.php
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Paypal Express Onepage checkout block for Shipping Address
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Paypal
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Ced_LayBuy_Block_Express_Review_Shipping extends Mage_Checkout_Block_Onepage_Shipping
|
| 35 |
+
{
|
| 36 |
+
/**
|
| 37 |
+
* Return Sales Quote Address model (shipping address)
|
| 38 |
+
*
|
| 39 |
+
* @return Mage_Sales_Model_Quote_Address
|
| 40 |
+
*/
|
| 41 |
+
public function getAddress()
|
| 42 |
+
{
|
| 43 |
+
if (is_null($this->_address)) {
|
| 44 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getShippingAddress()) {
|
| 45 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
| 46 |
+
} else {
|
| 47 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
return $this->_address;
|
| 52 |
+
}
|
| 53 |
+
}
|
app/code/local/Ced/LayBuy/Block/Payment/Info.php
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* PayPal common payment info block
|
| 29 |
+
* Uses default templates
|
| 30 |
+
*/
|
| 31 |
+
class Ced_LayBuy_Block_Payment_Info extends Mage_Payment_Block_Info_Cc
|
| 32 |
+
{
|
| 33 |
+
/**
|
| 34 |
+
* Don't show CC type for non-CC methods
|
| 35 |
+
*
|
| 36 |
+
* @return string|null
|
| 37 |
+
*/
|
| 38 |
+
public function getCcTypeName()
|
| 39 |
+
{
|
| 40 |
+
if (Mage_Paypal_Model_Config::getIsCreditCardMethod($this->getInfo()->getMethod())) {
|
| 41 |
+
return parent::getCcTypeName();
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Prepare PayPal-specific payment information
|
| 47 |
+
*
|
| 48 |
+
* @param Varien_Object|array $transport
|
| 49 |
+
* return Varien_Object
|
| 50 |
+
*/
|
| 51 |
+
protected function _prepareSpecificInformation($transport = null)
|
| 52 |
+
{
|
| 53 |
+
$transport = parent::_prepareSpecificInformation($transport);
|
| 54 |
+
$payment = $this->getInfo();
|
| 55 |
+
$paypalInfo = Mage::getModel('paypal/info');
|
| 56 |
+
if (!$this->getIsSecureMode()) {
|
| 57 |
+
$info = $paypalInfo->getPaymentInfo($payment, true);
|
| 58 |
+
} else {
|
| 59 |
+
$info = $paypalInfo->getPublicPaymentInfo($payment, true);
|
| 60 |
+
}
|
| 61 |
+
return $transport->addData($info);
|
| 62 |
+
}
|
| 63 |
+
}
|
app/code/local/Ced/LayBuy/Helper/Data.php
CHANGED
|
@@ -291,15 +291,37 @@ class Ced_LayBuy_Helper_Data extends Mage_Core_Helper_Abstract{
|
|
| 291 |
}
|
| 292 |
}
|
| 293 |
|
| 294 |
-
public function getPaidOrders() {
|
| 295 |
$code = Mage::getModel('laybuy/standard')->_code;
|
| 296 |
$collection = Mage::getResourceModel('sales/order_grid_collection');
|
| 297 |
$collection->join(array('payment'=>'sales/order_payment'),'main_table.entity_id=parent_id && main_table.status = "processing"','method');
|
| 298 |
$collection->join(array('order'=>'sales/order'),'payment.parent_id = order.entity_id','*');
|
| 299 |
$collection->addFieldToFilter('method',$code);
|
| 300 |
return $collection->getAllIds();
|
| 301 |
-
}
|
| 302 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
public function fetchBeforeRevise($profileId = 0) {
|
| 304 |
if($profileId) {
|
| 305 |
$this->_matchingData = array('orderIds'=>'','profileIds'=>$profileId);
|
| 291 |
}
|
| 292 |
}
|
| 293 |
|
| 294 |
+
/*public function getPaidOrders() {
|
| 295 |
$code = Mage::getModel('laybuy/standard')->_code;
|
| 296 |
$collection = Mage::getResourceModel('sales/order_grid_collection');
|
| 297 |
$collection->join(array('payment'=>'sales/order_payment'),'main_table.entity_id=parent_id && main_table.status = "processing"','method');
|
| 298 |
$collection->join(array('order'=>'sales/order'),'payment.parent_id = order.entity_id','*');
|
| 299 |
$collection->addFieldToFilter('method',$code);
|
| 300 |
return $collection->getAllIds();
|
| 301 |
+
}*/
|
| 302 |
+
public function getPaidOrders() {
|
| 303 |
+
$code = Mage::getModel('laybuy/standard')->_code;
|
| 304 |
+
$collection = Mage::getResourceModel('sales/order_grid_collection');
|
| 305 |
+
$paymentTable = Mage::getModel('core/resource')->getTableName("sales/order_payment");
|
| 306 |
+
//$paymentTable =$collection->getTable("sales/order_payment");
|
| 307 |
+
//$orderTable = $collection->getTable("sales/order");
|
| 308 |
+
$orderTable = Mage::getModel('core/resource')->getTableName("sales/order");
|
| 309 |
+
$collection->getSelect()->join(
|
| 310 |
+
array('e1'=>$paymentTable),
|
| 311 |
+
'`e1`.`parent_id`=`main_table`.`entity_id` and `main_table`.`status`="processing"',
|
| 312 |
+
array('method')
|
| 313 |
+
);
|
| 314 |
+
//$collection->join($paymentTable,'`main_table`.`entity_id`=`'.$paymentTable.'`.`parent_id` && `main_table`.`status` = "processing"','method');
|
| 315 |
+
|
| 316 |
+
$collection->getSelect()->join(
|
| 317 |
+
array('e2'=>$orderTable),
|
| 318 |
+
'`e1`.`parent_id`=`e2`.`entity_id`',
|
| 319 |
+
array('*')
|
| 320 |
+
);
|
| 321 |
+
//$collection->join($orderTable,'`'.$paymentTable.'`.`parent_id` = '.$orderTable.'.entity_id','*');
|
| 322 |
+
$collection->addFieldToFilter('method',$code);
|
| 323 |
+
return $collection->getAllIds();
|
| 324 |
+
}
|
| 325 |
public function fetchBeforeRevise($profileId = 0) {
|
| 326 |
if($profileId) {
|
| 327 |
$this->_matchingData = array('orderIds'=>'','profileIds'=>$profileId);
|
app/code/local/Ced/LayBuy/Model/Abstract.php
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ced_LayBuy_Model_Abstract extends Varien_Object
|
| 3 |
+
{
|
| 4 |
+
protected $_importFromRequestFilters = array(
|
| 5 |
+
'REDIRECTREQUIRED' => '_filterToBool',
|
| 6 |
+
'SUCCESSPAGEREDIRECTREQUESTED' => '_filterToBool',
|
| 7 |
+
'PAYMENTSTATUS' => '_filterPaymentStatusFromNvpToInfo',
|
| 8 |
+
);
|
| 9 |
+
protected $_laybuyresponse=null;
|
| 10 |
+
/**
|
| 11 |
+
* Global public interface map
|
| 12 |
+
* @var array
|
| 13 |
+
*/
|
| 14 |
+
protected $_globalMap = array(
|
| 15 |
+
// each call
|
| 16 |
+
'VERSION' => 'version',
|
| 17 |
+
'USER' => 'api_username',
|
| 18 |
+
'PWD' => 'api_password',
|
| 19 |
+
'SIGNATURE' => 'api_signature',
|
| 20 |
+
'BUTTONSOURCE' => 'build_notation_code',
|
| 21 |
+
|
| 22 |
+
// for Unilateral payments
|
| 23 |
+
'SUBJECT' => 'business_account',
|
| 24 |
+
|
| 25 |
+
// commands
|
| 26 |
+
'PAYMENTACTION' => 'payment_action',
|
| 27 |
+
'RETURNURL' => 'return_url',
|
| 28 |
+
'CANCELURL' => 'cancel_url',
|
| 29 |
+
'INVNUM' => 'inv_num',
|
| 30 |
+
'TOKEN' => 'token',
|
| 31 |
+
'CORRELATIONID' => 'correlation_id',
|
| 32 |
+
'SOLUTIONTYPE' => 'solution_type',
|
| 33 |
+
'GIROPAYCANCELURL' => 'giropay_cancel_url',
|
| 34 |
+
'GIROPAYSUCCESSURL' => 'giropay_success_url',
|
| 35 |
+
'BANKTXNPENDINGURL' => 'giropay_bank_txn_pending_url',
|
| 36 |
+
'IPADDRESS' => 'ip_address',
|
| 37 |
+
'NOTIFYURL' => 'notify_url',
|
| 38 |
+
'RETURNFMFDETAILS' => 'fraud_management_filters_enabled',
|
| 39 |
+
'NOTE' => 'note',
|
| 40 |
+
'REFUNDTYPE' => 'refund_type',
|
| 41 |
+
'ACTION' => 'action',
|
| 42 |
+
'REDIRECTREQUIRED' => 'redirect_required',
|
| 43 |
+
'SUCCESSPAGEREDIRECTREQUESTED' => 'redirect_requested',
|
| 44 |
+
'REQBILLINGADDRESS' => 'require_billing_address',
|
| 45 |
+
// style settings
|
| 46 |
+
'PAGESTYLE' => 'page_style',
|
| 47 |
+
'HDRIMG' => 'hdrimg',
|
| 48 |
+
'HDRBORDERCOLOR' => 'hdrbordercolor',
|
| 49 |
+
'HDRBACKCOLOR' => 'hdrbackcolor',
|
| 50 |
+
'PAYFLOWCOLOR' => 'payflowcolor',
|
| 51 |
+
'LOCALECODE' => 'locale_code',
|
| 52 |
+
'PAL' => 'pal',
|
| 53 |
+
|
| 54 |
+
// transaction info
|
| 55 |
+
'TRANSACTIONID' => 'transaction_id',
|
| 56 |
+
'AUTHORIZATIONID' => 'authorization_id',
|
| 57 |
+
'REFUNDTRANSACTIONID' => 'refund_transaction_id',
|
| 58 |
+
'COMPLETETYPE' => 'complete_type',
|
| 59 |
+
'AMT' => 'amount',
|
| 60 |
+
'ITEMAMT' => 'subtotal_amount',
|
| 61 |
+
'GROSSREFUNDAMT' => 'refunded_amount', // possible mistake, check with API reference
|
| 62 |
+
|
| 63 |
+
// payment/billing info
|
| 64 |
+
'CURRENCYCODE' => 'currency_code',
|
| 65 |
+
'PAYMENTSTATUS' => 'payment_status',
|
| 66 |
+
'PENDINGREASON' => 'pending_reason',
|
| 67 |
+
'PROTECTIONELIGIBILITY' => 'protection_eligibility',
|
| 68 |
+
'PAYERID' => 'payer_id',
|
| 69 |
+
'PAYERSTATUS' => 'payer_status',
|
| 70 |
+
'ADDRESSID' => 'address_id',
|
| 71 |
+
'ADDRESSSTATUS' => 'address_status',
|
| 72 |
+
'EMAIL' => 'email',
|
| 73 |
+
// backwards compatibility
|
| 74 |
+
'FIRSTNAME' => 'firstname',
|
| 75 |
+
'LASTNAME' => 'lastname',
|
| 76 |
+
|
| 77 |
+
// shipping rate
|
| 78 |
+
'SHIPPINGOPTIONNAME' => 'shipping_rate_code',
|
| 79 |
+
'NOSHIPPING' => 'suppress_shipping',
|
| 80 |
+
|
| 81 |
+
// paypal direct credit card information
|
| 82 |
+
'CREDITCARDTYPE' => 'credit_card_type',
|
| 83 |
+
'ACCT' => 'credit_card_number',
|
| 84 |
+
'EXPDATE' => 'credit_card_expiration_date',
|
| 85 |
+
'CVV2' => 'credit_card_cvv2',
|
| 86 |
+
'STARTDATE' => 'maestro_solo_issue_date', // MMYYYY, always six chars, including leading zero
|
| 87 |
+
'ISSUENUMBER' => 'maestro_solo_issue_number',
|
| 88 |
+
'CVV2MATCH' => 'cvv2_check_result',
|
| 89 |
+
'AVSCODE' => 'avs_result',
|
| 90 |
+
// cardinal centinel
|
| 91 |
+
'AUTHSTATUS3DS' => 'centinel_authstatus',
|
| 92 |
+
'MPIVENDOR3DS' => 'centinel_mpivendor',
|
| 93 |
+
'CAVV' => 'centinel_cavv',
|
| 94 |
+
'ECI3DS' => 'centinel_eci',
|
| 95 |
+
'XID' => 'centinel_xid',
|
| 96 |
+
'VPAS' => 'centinel_vpas_result',
|
| 97 |
+
'ECISUBMITTED3DS' => 'centinel_eci_result',
|
| 98 |
+
|
| 99 |
+
// recurring payment profiles
|
| 100 |
+
//'TOKEN' => 'token',
|
| 101 |
+
'SUBSCRIBERNAME' =>'subscriber_name',
|
| 102 |
+
'PROFILESTARTDATE' => 'start_datetime',
|
| 103 |
+
'PROFILEREFERENCE' => 'internal_reference_id',
|
| 104 |
+
'DESC' => 'schedule_description',
|
| 105 |
+
'MAXFAILEDPAYMENTS' => 'suspension_threshold',
|
| 106 |
+
'AUTOBILLAMT' => 'bill_failed_later',
|
| 107 |
+
'BILLINGPERIOD' => 'period_unit',
|
| 108 |
+
'BILLINGFREQUENCY' => 'period_frequency',
|
| 109 |
+
'TOTALBILLINGCYCLES' => 'period_max_cycles',
|
| 110 |
+
//'AMT' => 'billing_amount', // have to use 'amount', see above
|
| 111 |
+
'TRIALBILLINGPERIOD' => 'trial_period_unit',
|
| 112 |
+
'TRIALBILLINGFREQUENCY' => 'trial_period_frequency',
|
| 113 |
+
'TRIALTOTALBILLINGCYCLES' => 'trial_period_max_cycles',
|
| 114 |
+
'TRIALAMT' => 'trial_billing_amount',
|
| 115 |
+
// 'CURRENCYCODE' => 'currency_code',
|
| 116 |
+
'SHIPPINGAMT' => 'shipping_amount',
|
| 117 |
+
'TAXAMT' => 'tax_amount',
|
| 118 |
+
'INITAMT' => 'init_amount',
|
| 119 |
+
'FAILEDINITAMTACTION' => 'init_may_fail',
|
| 120 |
+
'PROFILEID' => 'recurring_profile_id',
|
| 121 |
+
'PROFILESTATUS' => 'recurring_profile_status',
|
| 122 |
+
'STATUS' => 'status',
|
| 123 |
+
|
| 124 |
+
//Next two fields are used for Brazil only
|
| 125 |
+
'TAXID' => 'buyer_tax_id',
|
| 126 |
+
'TAXIDTYPE' => 'buyer_tax_id_type',
|
| 127 |
+
|
| 128 |
+
'BILLINGAGREEMENTID' => 'billing_agreement_id',
|
| 129 |
+
'REFERENCEID' => 'reference_id',
|
| 130 |
+
'BILLINGAGREEMENTSTATUS' => 'billing_agreement_status',
|
| 131 |
+
'BILLINGTYPE' => 'billing_type',
|
| 132 |
+
'SREET' => 'street',
|
| 133 |
+
'CITY' => 'city',
|
| 134 |
+
'STATE' => 'state',
|
| 135 |
+
'COUNTRYCODE' => 'countrycode',
|
| 136 |
+
'ZIP' => 'zip',
|
| 137 |
+
'PAYERBUSINESS' => 'payer_business',
|
| 138 |
+
);
|
| 139 |
+
/**
|
| 140 |
+
* Import $this public data from a private response array
|
| 141 |
+
*
|
| 142 |
+
* @param array $privateResponseMap
|
| 143 |
+
* @param array $response
|
| 144 |
+
*/
|
| 145 |
+
public function _importFromResponse(array $privateResponseMap, array $response)
|
| 146 |
+
{
|
| 147 |
+
$map = array();
|
| 148 |
+
foreach ($privateResponseMap as $key) {
|
| 149 |
+
if (isset($this->_globalMap[$key])) {
|
| 150 |
+
$map[$key] = $this->_globalMap[$key];
|
| 151 |
+
}
|
| 152 |
+
if (isset($response[$key]) && isset($this->_importFromRequestFilters[$key])) {
|
| 153 |
+
$callback = $this->_importFromRequestFilters[$key];
|
| 154 |
+
$response[$key] = call_user_func(array($this, $callback), $response[$key], $key, $map[$key]);
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
Varien_Object_Mapper::accumulateByMap($response, array($this, 'setDataUsingMethod'), $map);
|
| 158 |
+
}
|
| 159 |
+
public function setLaybuyResponse($resp="")
|
| 160 |
+
{
|
| 161 |
+
$this->_laybuyresponse=$resp;
|
| 162 |
+
}
|
| 163 |
+
public function getLaybuyResponse()
|
| 164 |
+
{
|
| 165 |
+
return $this->_laybuyresponse;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
}
|
app/code/local/Ced/LayBuy/Model/Config.php
ADDED
|
@@ -0,0 +1,1419 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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TICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Config model that is aware of all Mage_Paypal payment methods
|
| 29 |
+
* Works with PayPal-specific system configuration
|
| 30 |
+
*/
|
| 31 |
+
class Ced_LayBuy_Model_Config
|
| 32 |
+
{
|
| 33 |
+
/**
|
| 34 |
+
* PayPal Standard
|
| 35 |
+
* @var string
|
| 36 |
+
*/
|
| 37 |
+
const METHOD_WPS = 'laybuy_standard';
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* PayPal Website Payments Pro - Express Checkout
|
| 41 |
+
* @var string
|
| 42 |
+
*/
|
| 43 |
+
const METHOD_WPP_EXPRESS = 'laybuy_express';
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* PayPal Website Payments Pro - Direct Payments
|
| 47 |
+
* @var string
|
| 48 |
+
*/
|
| 49 |
+
const METHOD_WPP_DIRECT = 'laybuy_direct';
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Direct Payments (Payflow Edition)
|
| 53 |
+
* @var string
|
| 54 |
+
*/
|
| 55 |
+
const METHOD_WPP_PE_DIRECT = 'laybuyuk_direct';
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* Express Checkout (Payflow Edition)
|
| 59 |
+
* @var string
|
| 60 |
+
*/
|
| 61 |
+
const METHOD_WPP_PE_EXPRESS = 'laybuyuk_express';
|
| 62 |
+
|
| 63 |
+
/**
|
| 64 |
+
* Payflow Pro Gateway
|
| 65 |
+
* @var string
|
| 66 |
+
*/
|
| 67 |
+
const METHOD_PAYFLOWPRO = 'verisign';
|
| 68 |
+
|
| 69 |
+
const METHOD_PAYFLOWLINK = 'payflow_link';
|
| 70 |
+
const METHOD_PAYFLOWADVANCED = 'payflow_advanced';
|
| 71 |
+
|
| 72 |
+
const METHOD_HOSTEDPRO = 'hosted_pro';
|
| 73 |
+
|
| 74 |
+
const METHOD_BILLING_AGREEMENT = 'laybuy_billing_agreement';
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* Buttons and images
|
| 78 |
+
* @var string
|
| 79 |
+
*/
|
| 80 |
+
const EC_FLAVOR_DYNAMIC = 'dynamic';
|
| 81 |
+
const EC_FLAVOR_STATIC = 'static';
|
| 82 |
+
const EC_BUTTON_TYPE_SHORTCUT = 'ecshortcut';
|
| 83 |
+
const EC_BUTTON_TYPE_MARK = 'ecmark';
|
| 84 |
+
const PAYMENT_MARK_37x23 = '37x23';
|
| 85 |
+
const PAYMENT_MARK_50x34 = '50x34';
|
| 86 |
+
const PAYMENT_MARK_60x38 = '60x38';
|
| 87 |
+
const PAYMENT_MARK_180x113 = '180x113';
|
| 88 |
+
|
| 89 |
+
const DEFAULT_LOGO_TYPE = 'wePrefer_150x60';
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* Payment actions
|
| 93 |
+
* @var string
|
| 94 |
+
*/
|
| 95 |
+
const PAYMENT_ACTION_SALE = 'Sale';
|
| 96 |
+
const PAYMENT_ACTION_ORDER = 'Order';
|
| 97 |
+
const PAYMENT_ACTION_AUTH = 'Authorization';
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* Authorization amounts for Account Verification
|
| 101 |
+
*
|
| 102 |
+
* @deprecated since 1.6.2.0
|
| 103 |
+
* @var int
|
| 104 |
+
*/
|
| 105 |
+
const AUTHORIZATION_AMOUNT_ZERO = 0;
|
| 106 |
+
const AUTHORIZATION_AMOUNT_ONE = 1;
|
| 107 |
+
const AUTHORIZATION_AMOUNT_FULL = 2;
|
| 108 |
+
|
| 109 |
+
/**
|
| 110 |
+
* Require Billing Address
|
| 111 |
+
* @var int
|
| 112 |
+
*/
|
| 113 |
+
const REQUIRE_BILLING_ADDRESS_NO = 0;
|
| 114 |
+
const REQUIRE_BILLING_ADDRESS_ALL = 1;
|
| 115 |
+
const REQUIRE_BILLING_ADDRESS_VIRTUAL = 2;
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
* Fraud management actions
|
| 119 |
+
* @var string
|
| 120 |
+
*/
|
| 121 |
+
const FRAUD_ACTION_ACCEPT = 'Acept';
|
| 122 |
+
const FRAUD_ACTION_DENY = 'Deny';
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
* Refund types
|
| 126 |
+
* @var string
|
| 127 |
+
*/
|
| 128 |
+
const REFUND_TYPE_FULL = 'Full';
|
| 129 |
+
const REFUND_TYPE_PARTIAL = 'Partial';
|
| 130 |
+
|
| 131 |
+
/**
|
| 132 |
+
* Express Checkout flows
|
| 133 |
+
* @var string
|
| 134 |
+
*/
|
| 135 |
+
const EC_SOLUTION_TYPE_SOLE = 'Sole';
|
| 136 |
+
const EC_SOLUTION_TYPE_MARK = 'Mark';
|
| 137 |
+
|
| 138 |
+
/**
|
| 139 |
+
* Payment data transfer methods (Standard)
|
| 140 |
+
*
|
| 141 |
+
* @var string
|
| 142 |
+
*/
|
| 143 |
+
const WPS_TRANSPORT_IPN = 'ipn';
|
| 144 |
+
const WPS_TRANSPORT_PDT = 'pdt';
|
| 145 |
+
const WPS_TRANSPORT_IPN_PDT = 'ipn_n_pdt';
|
| 146 |
+
|
| 147 |
+
/**
|
| 148 |
+
* Billing Agreement Signup
|
| 149 |
+
*
|
| 150 |
+
* @var string
|
| 151 |
+
*/
|
| 152 |
+
const EC_BA_SIGNUP_AUTO = 'auto';
|
| 153 |
+
const EC_BA_SIGNUP_ASK = 'ask';
|
| 154 |
+
const EC_BA_SIGNUP_NEVER = 'never';
|
| 155 |
+
|
| 156 |
+
/**
|
| 157 |
+
* Default URL for centinel API (PayPal Direct)
|
| 158 |
+
*
|
| 159 |
+
* @var string
|
| 160 |
+
*/
|
| 161 |
+
// public $centinelDefaultApiUrl = 'https://paypal.cardinalcommerce.com/maps/txns.asp';
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
* Current payment method code
|
| 165 |
+
* @var string
|
| 166 |
+
*/
|
| 167 |
+
protected $_methodCode = null;
|
| 168 |
+
|
| 169 |
+
/**
|
| 170 |
+
* Current store id
|
| 171 |
+
*
|
| 172 |
+
* @var int
|
| 173 |
+
*/
|
| 174 |
+
protected $_storeId = null;
|
| 175 |
+
|
| 176 |
+
/**
|
| 177 |
+
* Instructions for generating proper BN code
|
| 178 |
+
*
|
| 179 |
+
* @var array
|
| 180 |
+
*/
|
| 181 |
+
protected $_buildNotationPPMap = array(
|
| 182 |
+
'paypal_standard' => 'WPS',
|
| 183 |
+
'paypal_express' => 'EC',
|
| 184 |
+
'paypal_direct' => 'DP',
|
| 185 |
+
'paypaluk_express' => 'EC',
|
| 186 |
+
'paypaluk_direct' => 'DP',
|
| 187 |
+
);
|
| 188 |
+
|
| 189 |
+
/**
|
| 190 |
+
* Style system config map (Express Checkout)
|
| 191 |
+
*
|
| 192 |
+
* @var array
|
| 193 |
+
*/
|
| 194 |
+
protected $_ecStyleConfigMap = array(
|
| 195 |
+
'page_style' => 'page_style',
|
| 196 |
+
'paypal_hdrimg' => 'hdrimg',
|
| 197 |
+
'paypal_hdrbordercolor' => 'hdrbordercolor',
|
| 198 |
+
'paypal_hdrbackcolor' => 'hdrbackcolor',
|
| 199 |
+
'paypal_payflowcolor' => 'payflowcolor',
|
| 200 |
+
);
|
| 201 |
+
|
| 202 |
+
/**
|
| 203 |
+
* Currency codes supported by PayPal methods
|
| 204 |
+
*
|
| 205 |
+
* @var array
|
| 206 |
+
*/
|
| 207 |
+
protected $_supportedCurrencyCodes = array('AUD', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN',
|
| 208 |
+
'NOK', 'NZD', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'USD', 'TWD', 'THB');
|
| 209 |
+
|
| 210 |
+
/**
|
| 211 |
+
* Merchant country supported by PayPal
|
| 212 |
+
*
|
| 213 |
+
* @var array
|
| 214 |
+
*/
|
| 215 |
+
protected $_supportedCountryCodes = array(
|
| 216 |
+
'AE','AR','AT','AU','BE','BG','BR','CA','CH','CL','CR','CY','CZ','DE','DK','DO','EC','EE','ES','FI','FR','GB',
|
| 217 |
+
'GF','GI','GP','GR','HK','HU','ID','IE','IL','IN','IS','IT','JM','JP','KR','LI','LT','LU','LV','MQ','MT','MX',
|
| 218 |
+
'MY','NL','NO','NZ','PH','PL','PT','RE','RO','SE','SG','SI','SK','SM','TH','TR','TW','US','UY','VE','VN','ZA');
|
| 219 |
+
|
| 220 |
+
/**
|
| 221 |
+
* Buyer country supported by PayPal
|
| 222 |
+
*
|
| 223 |
+
* @var array
|
| 224 |
+
*/
|
| 225 |
+
protected $_supportedBuyerCountryCodes = array(
|
| 226 |
+
'AF ', 'AX ', 'AL ', 'DZ ', 'AS ', 'AD ', 'AO ', 'AI ', 'AQ ', 'AG ', 'AR ', 'AM ', 'AW ', 'AU ', 'AT ', 'AZ ',
|
| 227 |
+
'BS ', 'BH ', 'BD ', 'BB ', 'BY ', 'BE ', 'BZ ', 'BJ ', 'BM ', 'BT ', 'BO ', 'BA ', 'BW ', 'BV ', 'BR ', 'IO ',
|
| 228 |
+
'BN ', 'BG ', 'BF ', 'BI ', 'KH ', 'CM ', 'CA ', 'CV ', 'KY ', 'CF ', 'TD ', 'CL ', 'CN ', 'CX ', 'CC ', 'CO ',
|
| 229 |
+
'KM ', 'CG ', 'CD ', 'CK ', 'CR ', 'CI ', 'HR ', 'CU ', 'CY ', 'CZ ', 'DK ', 'DJ ', 'DM ', 'DO ', 'EC ', 'EG ',
|
| 230 |
+
'SV ', 'GQ ', 'ER ', 'EE ', 'ET ', 'FK ', 'FO ', 'FJ ', 'FI ', 'FR ', 'GF ', 'PF ', 'TF ', 'GA ', 'GM ', 'GE ',
|
| 231 |
+
'DE ', 'GH ', 'GI ', 'GR ', 'GL ', 'GD ', 'GP ', 'GU ', 'GT ', 'GG ', 'GN ', 'GW ', 'GY ', 'HT ', 'HM ', 'VA ',
|
| 232 |
+
'HN ', 'HK ', 'HU ', 'IS ', 'IN ', 'ID ', 'IR ', 'IQ ', 'IE ', 'IM ', 'IL ', 'IT ', 'JM ', 'JP ', 'JE ', 'JO ',
|
| 233 |
+
'KZ ', 'KE ', 'KI ', 'KP ', 'KR ', 'KW ', 'KG ', 'LA ', 'LV ', 'LB ', 'LS ', 'LR ', 'LY ', 'LI ', 'LT ', 'LU ',
|
| 234 |
+
'MO ', 'MK ', 'MG ', 'MW ', 'MY ', 'MV ', 'ML ', 'MT ', 'MH ', 'MQ ', 'MR ', 'MU ', 'YT ', 'MX ', 'FM ', 'MD ',
|
| 235 |
+
'MC ', 'MN ', 'MS ', 'MA ', 'MZ ', 'MM ', 'NA ', 'NR ', 'NP ', 'NL ', 'AN ', 'NC ', 'NZ ', 'NI ', 'NE ', 'NG ',
|
| 236 |
+
'NU ', 'NF ', 'MP ', 'NO ', 'OM ', 'PK ', 'PW ', 'PS ', 'PA ', 'PG ', 'PY ', 'PE ', 'PH ', 'PN ', 'PL ', 'PT ',
|
| 237 |
+
'PR ', 'QA ', 'RE ', 'RO ', 'RU ', 'RW ', 'SH ', 'KN ', 'LC ', 'PM ', 'VC ', 'WS ', 'SM ', 'ST ', 'SA ', 'SN ',
|
| 238 |
+
'CS ', 'SC ', 'SL ', 'SG ', 'SK ', 'SI ', 'SB ', 'SO ', 'ZA ', 'GS ', 'ES ', 'LK ', 'SD ', 'SR ', 'SJ ', 'SZ ',
|
| 239 |
+
'SE ', 'CH ', 'SY ', 'TW ', 'TJ ', 'TZ ', 'TH ', 'TL ', 'TG ', 'TK ', 'TO ', 'TT ', 'TN ', 'TR ', 'TM ', 'TC ',
|
| 240 |
+
'TV ', 'UG ', 'UA ', 'AE ', 'GB ', 'US ', 'UM ', 'UY ', 'UZ ', 'VU ', 'VE ', 'VN ', 'VG ', 'VI ', 'WF ', 'EH ',
|
| 241 |
+
'YE ', 'ZM ', 'ZW'
|
| 242 |
+
);
|
| 243 |
+
|
| 244 |
+
/**
|
| 245 |
+
* Locale codes supported by misc images (marks, shortcuts etc)
|
| 246 |
+
*
|
| 247 |
+
* @var array
|
| 248 |
+
* @link https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECButtonIntegration#id089QD0O0TX4__id08AH904I0YK
|
| 249 |
+
*/
|
| 250 |
+
protected $_supportedImageLocales = array('de_DE', 'en_AU', 'en_GB', 'en_US', 'es_ES', 'es_XC', 'fr_FR',
|
| 251 |
+
'fr_XC', 'it_IT', 'ja_JP', 'nl_NL', 'pl_PL', 'zh_CN', 'zh_XC',
|
| 252 |
+
);
|
| 253 |
+
|
| 254 |
+
/**
|
| 255 |
+
* Set method and store id, if specified
|
| 256 |
+
*
|
| 257 |
+
* @param array $params
|
| 258 |
+
*/
|
| 259 |
+
public function __construct($params = array())
|
| 260 |
+
{
|
| 261 |
+
if ($params) {
|
| 262 |
+
$method = array_shift($params);
|
| 263 |
+
$this->setMethod($method);
|
| 264 |
+
if ($params) {
|
| 265 |
+
$storeId = array_shift($params);
|
| 266 |
+
$this->setStoreId($storeId);
|
| 267 |
+
}
|
| 268 |
+
}
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
/**
|
| 272 |
+
* Method code setter
|
| 273 |
+
*
|
| 274 |
+
* @param string|Mage_Payment_Model_Method_Abstract $method
|
| 275 |
+
* @return Mage_Paypal_Model_Config
|
| 276 |
+
*/
|
| 277 |
+
public function setMethod($method)
|
| 278 |
+
{
|
| 279 |
+
if ($method instanceof Mage_Payment_Model_Method_Abstract) {
|
| 280 |
+
$this->_methodCode = $method->getCode();
|
| 281 |
+
} elseif (is_string($method)) {
|
| 282 |
+
$this->_methodCode = $method;
|
| 283 |
+
}
|
| 284 |
+
return $this;
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
/**
|
| 288 |
+
* Payment method instance code getter
|
| 289 |
+
*
|
| 290 |
+
* @return string
|
| 291 |
+
*/
|
| 292 |
+
public function getMethodCode()
|
| 293 |
+
{
|
| 294 |
+
return $this->_methodCode;
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
/**
|
| 298 |
+
* Store ID setter
|
| 299 |
+
*
|
| 300 |
+
* @param int $storeId
|
| 301 |
+
* @return Mage_Paypal_Model_Config
|
| 302 |
+
*/
|
| 303 |
+
public function setStoreId($storeId)
|
| 304 |
+
{
|
| 305 |
+
$this->_storeId = (int)$storeId;
|
| 306 |
+
return $this;
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
/**
|
| 310 |
+
* Check whether method active in configuration and supported for merchant country or not
|
| 311 |
+
*
|
| 312 |
+
* @param string $method Method code
|
| 313 |
+
* @return bool
|
| 314 |
+
*/
|
| 315 |
+
public function isMethodActive($method)
|
| 316 |
+
{
|
| 317 |
+
if ($this->isMethodSupportedForCountry($method)
|
| 318 |
+
&& Mage::getStoreConfigFlag("payment/{$method}/active", $this->_storeId)
|
| 319 |
+
) {
|
| 320 |
+
return true;
|
| 321 |
+
}
|
| 322 |
+
return false;
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
/**
|
| 326 |
+
* Check whether method available for checkout or not
|
| 327 |
+
* Logic based on merchant country, methods dependence
|
| 328 |
+
*
|
| 329 |
+
* @param string $method Method code
|
| 330 |
+
* @return bool
|
| 331 |
+
*/
|
| 332 |
+
public function isMethodAvailable($methodCode = null)
|
| 333 |
+
{
|
| 334 |
+
if ($methodCode === null) {
|
| 335 |
+
$methodCode = $this->getMethodCode();
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
$result = true;
|
| 339 |
+
|
| 340 |
+
if (!$this->isMethodActive($methodCode)) {
|
| 341 |
+
$result = false;
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
switch ($methodCode) {
|
| 345 |
+
case self::METHOD_WPS:
|
| 346 |
+
if (!$this->businessAccount) {
|
| 347 |
+
$result = false;
|
| 348 |
+
break;
|
| 349 |
+
}
|
| 350 |
+
// check for direct payments dependence
|
| 351 |
+
if ($this->isMethodActive(self::METHOD_WPP_DIRECT)
|
| 352 |
+
|| $this->isMethodActive(self::METHOD_WPP_PE_DIRECT)) {
|
| 353 |
+
$result = false;
|
| 354 |
+
}
|
| 355 |
+
break;
|
| 356 |
+
case self::METHOD_WPP_EXPRESS:
|
| 357 |
+
// check for direct payments dependence
|
| 358 |
+
if ($this->isMethodActive(self::METHOD_WPP_PE_DIRECT)) {
|
| 359 |
+
$result = false;
|
| 360 |
+
} elseif ($this->isMethodActive(self::METHOD_WPP_DIRECT)) {
|
| 361 |
+
$result = true;
|
| 362 |
+
}
|
| 363 |
+
break;
|
| 364 |
+
case self::METHOD_WPP_PE_EXPRESS:
|
| 365 |
+
// check for direct payments dependence
|
| 366 |
+
if ($this->isMethodActive(self::METHOD_WPP_PE_DIRECT)) {
|
| 367 |
+
$result = true;
|
| 368 |
+
} elseif (!$this->isMethodActive(self::METHOD_WPP_PE_DIRECT)
|
| 369 |
+
&& !$this->isMethodActive(self::METHOD_PAYFLOWPRO)) {
|
| 370 |
+
$result = false;
|
| 371 |
+
}
|
| 372 |
+
break;
|
| 373 |
+
case self::METHOD_BILLING_AGREEMENT:
|
| 374 |
+
$result = $this->isWppApiAvailabe();
|
| 375 |
+
break;
|
| 376 |
+
case self::METHOD_WPP_DIRECT:
|
| 377 |
+
case self::METHOD_WPP_PE_DIRECT:
|
| 378 |
+
break;
|
| 379 |
+
}
|
| 380 |
+
return $result;
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
/**
|
| 384 |
+
* Config field magic getter
|
| 385 |
+
* The specified key can be either in camelCase or under_score format
|
| 386 |
+
* Tries to map specified value according to set payment method code, into the configuration value
|
| 387 |
+
* Sets the values into public class parameters, to avoid redundant calls of this method
|
| 388 |
+
*
|
| 389 |
+
* @param string $key
|
| 390 |
+
* @return string|null
|
| 391 |
+
*/
|
| 392 |
+
public function __get($key)
|
| 393 |
+
{
|
| 394 |
+
$underscored = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $key));
|
| 395 |
+
$value = Mage::getStoreConfig($this->_getSpecificConfigPath($underscored), $this->_storeId);
|
| 396 |
+
$value = $this->_prepareValue($underscored, $value);
|
| 397 |
+
$this->$key = $value;
|
| 398 |
+
$this->$underscored = $value;
|
| 399 |
+
return $value;
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
/**
|
| 403 |
+
* Perform additional config value preparation and return new value if needed
|
| 404 |
+
*
|
| 405 |
+
* @param string $key Underscored key
|
| 406 |
+
* @param string $value Old value
|
| 407 |
+
* @return string Modified value or old value
|
| 408 |
+
*/
|
| 409 |
+
protected function _prepareValue($key, $value)
|
| 410 |
+
{
|
| 411 |
+
// Always set payment action as "Sale" for Unilateral payments in EC
|
| 412 |
+
if ($key == 'payment_action'
|
| 413 |
+
&& $value != self::PAYMENT_ACTION_SALE
|
| 414 |
+
&& $this->_methodCode == self::METHOD_WPP_EXPRESS
|
| 415 |
+
&& $this->shouldUseUnilateralPayments())
|
| 416 |
+
{
|
| 417 |
+
return self::PAYMENT_ACTION_SALE;
|
| 418 |
+
}
|
| 419 |
+
return $value;
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
/**
|
| 423 |
+
* Return merchant country codes supported by PayPal
|
| 424 |
+
*
|
| 425 |
+
* @return array
|
| 426 |
+
*/
|
| 427 |
+
public function getSupportedMerchantCountryCodes()
|
| 428 |
+
{
|
| 429 |
+
return $this->_supportedCountryCodes;
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
/**
|
| 433 |
+
* Return buyer country codes supported by PayPal
|
| 434 |
+
*
|
| 435 |
+
* @return array
|
| 436 |
+
*/
|
| 437 |
+
public function getSupportedBuyerCountryCodes()
|
| 438 |
+
{
|
| 439 |
+
return $this->_supportedBuyerCountryCodes;
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
/**
|
| 443 |
+
* Return merchant country code, use default country if it not specified in General settings
|
| 444 |
+
*
|
| 445 |
+
* @return string
|
| 446 |
+
*/
|
| 447 |
+
public function getMerchantCountry()
|
| 448 |
+
{
|
| 449 |
+
$countryCode = Mage::getStoreConfig($this->_mapGeneralFieldset('merchant_country'), $this->_storeId);
|
| 450 |
+
if (!$countryCode) {
|
| 451 |
+
$countryCode = Mage::helper('core')->getDefaultCountry($this->_storeId);
|
| 452 |
+
}
|
| 453 |
+
return $countryCode;
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
/**
|
| 457 |
+
* Check whether method supported for specified country or not
|
| 458 |
+
* Use $_methodCode and merchant country by default
|
| 459 |
+
*
|
| 460 |
+
* @return bool
|
| 461 |
+
*/
|
| 462 |
+
public function isMethodSupportedForCountry($method = null, $countryCode = null)
|
| 463 |
+
{
|
| 464 |
+
if ($method === null) {
|
| 465 |
+
$method = $this->getMethodCode();
|
| 466 |
+
}
|
| 467 |
+
if ($countryCode === null) {
|
| 468 |
+
$countryCode = $this->getMerchantCountry();
|
| 469 |
+
}
|
| 470 |
+
$countryMethods = $this->getCountryMethods($countryCode);
|
| 471 |
+
if (in_array($method, $countryMethods)) {
|
| 472 |
+
return true;
|
| 473 |
+
}
|
| 474 |
+
return false;
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
/**
|
| 478 |
+
* Return list of allowed methods for specified country iso code
|
| 479 |
+
*
|
| 480 |
+
* @param string $countryCode 2-letters iso code
|
| 481 |
+
* @return array
|
| 482 |
+
*/
|
| 483 |
+
public function getCountryMethods($countryCode = null)
|
| 484 |
+
{
|
| 485 |
+
$countryMethods = array(
|
| 486 |
+
'other' => array(
|
| 487 |
+
self::METHOD_WPS,
|
| 488 |
+
self::METHOD_WPP_EXPRESS,
|
| 489 |
+
self::METHOD_BILLING_AGREEMENT,
|
| 490 |
+
),
|
| 491 |
+
'US' => array(
|
| 492 |
+
self::METHOD_PAYFLOWADVANCED,
|
| 493 |
+
self::METHOD_WPP_DIRECT,
|
| 494 |
+
self::METHOD_WPS,
|
| 495 |
+
self::METHOD_PAYFLOWPRO,
|
| 496 |
+
self::METHOD_PAYFLOWLINK,
|
| 497 |
+
self::METHOD_WPP_EXPRESS,
|
| 498 |
+
self::METHOD_BILLING_AGREEMENT,
|
| 499 |
+
self::METHOD_WPP_PE_EXPRESS,
|
| 500 |
+
),
|
| 501 |
+
'CA' => array(
|
| 502 |
+
self::METHOD_WPP_DIRECT,
|
| 503 |
+
self::METHOD_WPS,
|
| 504 |
+
self::METHOD_PAYFLOWPRO,
|
| 505 |
+
self::METHOD_PAYFLOWLINK,
|
| 506 |
+
self::METHOD_WPP_EXPRESS,
|
| 507 |
+
self::METHOD_BILLING_AGREEMENT,
|
| 508 |
+
),
|
| 509 |
+
'GB' => array(
|
| 510 |
+
self::METHOD_WPP_DIRECT,
|
| 511 |
+
self::METHOD_WPS,
|
| 512 |
+
self::METHOD_WPP_PE_DIRECT,
|
| 513 |
+
self::METHOD_HOSTEDPRO,
|
| 514 |
+
self::METHOD_WPP_EXPRESS,
|
| 515 |
+
self::METHOD_BILLING_AGREEMENT,
|
| 516 |
+
self::METHOD_WPP_PE_EXPRESS,
|
| 517 |
+
),
|
| 518 |
+
'AU' => array(
|
| 519 |
+
self::METHOD_WPS,
|
| 520 |
+
self::METHOD_PAYFLOWPRO,
|
| 521 |
+
self::METHOD_HOSTEDPRO,
|
| 522 |
+
self::METHOD_WPP_EXPRESS,
|
| 523 |
+
self::METHOD_BILLING_AGREEMENT,
|
| 524 |
+
),
|
| 525 |
+
'NZ' => array(
|
| 526 |
+
self::METHOD_WPS,
|
| 527 |
+
self::METHOD_PAYFLOWPRO,
|
| 528 |
+
self::METHOD_WPP_EXPRESS,
|
| 529 |
+
self::METHOD_BILLING_AGREEMENT,
|
| 530 |
+
),
|
| 531 |
+
'JP' => array(
|
| 532 |
+
self::METHOD_WPS,
|
| 533 |
+
self::METHOD_HOSTEDPRO,
|
| 534 |
+
self::METHOD_WPP_EXPRESS,
|
| 535 |
+
self::METHOD_BILLING_AGREEMENT,
|
| 536 |
+
),
|
| 537 |
+
'FR' => array(
|
| 538 |
+
self::METHOD_WPS,
|
| 539 |
+
self::METHOD_HOSTEDPRO,
|
| 540 |
+
self::METHOD_WPP_EXPRESS,
|
| 541 |
+
self::METHOD_BILLING_AGREEMENT,
|
| 542 |
+
),
|
| 543 |
+
'IT' => array(
|
| 544 |
+
self::METHOD_WPS,
|
| 545 |
+
self::METHOD_HOSTEDPRO,
|
| 546 |
+
self::METHOD_WPP_EXPRESS,
|
| 547 |
+
self::METHOD_BILLING_AGREEMENT,
|
| 548 |
+
),
|
| 549 |
+
'ES' => array(
|
| 550 |
+
self::METHOD_WPS,
|
| 551 |
+
self::METHOD_HOSTEDPRO,
|
| 552 |
+
self::METHOD_WPP_EXPRESS,
|
| 553 |
+
self::METHOD_BILLING_AGREEMENT,
|
| 554 |
+
),
|
| 555 |
+
'HK' => array(
|
| 556 |
+
self::METHOD_WPS,
|
| 557 |
+
self::METHOD_HOSTEDPRO,
|
| 558 |
+
self::METHOD_WPP_EXPRESS,
|
| 559 |
+
self::METHOD_BILLING_AGREEMENT,
|
| 560 |
+
),
|
| 561 |
+
);
|
| 562 |
+
if ($countryCode === null) {
|
| 563 |
+
return $countryMethods;
|
| 564 |
+
}
|
| 565 |
+
return isset($countryMethods[$countryCode]) ? $countryMethods[$countryCode] : $countryMethods['other']; }
|
| 566 |
+
|
| 567 |
+
/**
|
| 568 |
+
* Get url for dispatching customer to express checkout start
|
| 569 |
+
*
|
| 570 |
+
* @param string $token
|
| 571 |
+
* @return string
|
| 572 |
+
*/
|
| 573 |
+
public function getExpressCheckoutStartUrl($token)
|
| 574 |
+
{
|
| 575 |
+
return $this->getPaypalUrl(array(
|
| 576 |
+
'cmd' => '_express-checkout',
|
| 577 |
+
'token' => $token,
|
| 578 |
+
));
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
/**
|
| 582 |
+
* Get url that allows to edit checkout details on paypal side
|
| 583 |
+
*
|
| 584 |
+
* @param $token
|
| 585 |
+
* @return string
|
| 586 |
+
*/
|
| 587 |
+
public function getExpressCheckoutEditUrl($token)
|
| 588 |
+
{
|
| 589 |
+
return $this->getPaypalUrl(array(
|
| 590 |
+
'cmd' => '_express-checkout',
|
| 591 |
+
'useraction' => 'continue',
|
| 592 |
+
'token' => $token,
|
| 593 |
+
));
|
| 594 |
+
}
|
| 595 |
+
|
| 596 |
+
/**
|
| 597 |
+
* Get url for additional actions that PayPal may require customer to do after placing the order.
|
| 598 |
+
* For instance, redirecting customer to bank for payment confirmation.
|
| 599 |
+
*
|
| 600 |
+
* @param string $token
|
| 601 |
+
* @return string
|
| 602 |
+
*/
|
| 603 |
+
public function getExpressCheckoutCompleteUrl($token)
|
| 604 |
+
{
|
| 605 |
+
return $this->getPaypalUrl(array(
|
| 606 |
+
'cmd' => '_complete-express-checkout',
|
| 607 |
+
'token' => $token,
|
| 608 |
+
));
|
| 609 |
+
}
|
| 610 |
+
|
| 611 |
+
/**
|
| 612 |
+
* Retrieve url for initialization of billing agreement
|
| 613 |
+
*
|
| 614 |
+
* @param string $token
|
| 615 |
+
* @return string
|
| 616 |
+
*/
|
| 617 |
+
public function getStartBillingAgreementUrl($token)
|
| 618 |
+
{
|
| 619 |
+
return $this->getPaypalUrl(array(
|
| 620 |
+
'cmd' => '_customer-billing-agreement',
|
| 621 |
+
'token' => $token,
|
| 622 |
+
));
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
/**
|
| 626 |
+
* PayPal web URL generic getter
|
| 627 |
+
*
|
| 628 |
+
* @param array $params
|
| 629 |
+
* @return string
|
| 630 |
+
*/
|
| 631 |
+
public function getPaypalUrl(array $params = array())
|
| 632 |
+
{
|
| 633 |
+
return sprintf('https://www.%spaypal.com/cgi-bin/webscr%s',
|
| 634 |
+
$this->sandboxFlag ? 'sandbox.' : '',
|
| 635 |
+
$params ? '?' . http_build_query($params) : ''
|
| 636 |
+
);
|
| 637 |
+
}
|
| 638 |
+
|
| 639 |
+
/**
|
| 640 |
+
* Whether Express Checkout button should be rendered dynamically
|
| 641 |
+
*
|
| 642 |
+
* @return bool
|
| 643 |
+
*/
|
| 644 |
+
public function areButtonsDynamic()
|
| 645 |
+
{
|
| 646 |
+
return $this->buttonFlavor === self::EC_FLAVOR_DYNAMIC;
|
| 647 |
+
}
|
| 648 |
+
|
| 649 |
+
/**
|
| 650 |
+
* Express checkout shortcut pic URL getter
|
| 651 |
+
* PayPal will ignore "pal", if there is no total amount specified
|
| 652 |
+
*
|
| 653 |
+
* @param string $localeCode
|
| 654 |
+
* @param float $orderTotal
|
| 655 |
+
* @param string $pal encrypted summary about merchant
|
| 656 |
+
* @see Paypal_Model_Api_Nvp::callGetPalDetails()
|
| 657 |
+
*/
|
| 658 |
+
public function getExpressCheckoutShortcutImageUrl($localeCode, $orderTotal = null, $pal = null)
|
| 659 |
+
{
|
| 660 |
+
if ($this->areButtonsDynamic()) {
|
| 661 |
+
return $this->_getDynamicImageUrl(self::EC_BUTTON_TYPE_SHORTCUT, $localeCode, $orderTotal, $pal);
|
| 662 |
+
}
|
| 663 |
+
if ($this->buttonType === self::EC_BUTTON_TYPE_MARK) {
|
| 664 |
+
return $this->getPaymentMarkImageUrl($localeCode);
|
| 665 |
+
}
|
| 666 |
+
return sprintf('https://www.paypal.com/%s/i/btn/btn_xpressCheckout.gif',
|
| 667 |
+
$this->_getSupportedLocaleCode($localeCode));
|
| 668 |
+
}
|
| 669 |
+
|
| 670 |
+
/**
|
| 671 |
+
* Get PayPal "mark" image URL
|
| 672 |
+
* Supposed to be used on payment methods selection
|
| 673 |
+
* $staticSize is applicable for static images only
|
| 674 |
+
*
|
| 675 |
+
* @param string $localeCode
|
| 676 |
+
* @param float $orderTotal
|
| 677 |
+
* @param string $pal
|
| 678 |
+
* @param string $staticSize
|
| 679 |
+
*/
|
| 680 |
+
public function getPaymentMarkImageUrl($localeCode, $orderTotal = null, $pal = null, $staticSize = null)
|
| 681 |
+
{
|
| 682 |
+
if ($this->areButtonsDynamic()) {
|
| 683 |
+
return $this->_getDynamicImageUrl(self::EC_BUTTON_TYPE_MARK, $localeCode, $orderTotal, $pal);
|
| 684 |
+
}
|
| 685 |
+
|
| 686 |
+
if (null === $staticSize) {
|
| 687 |
+
$staticSize = $this->paymentMarkSize;
|
| 688 |
+
}
|
| 689 |
+
switch ($staticSize) {
|
| 690 |
+
case self::PAYMENT_MARK_37x23:
|
| 691 |
+
case self::PAYMENT_MARK_50x34:
|
| 692 |
+
case self::PAYMENT_MARK_60x38:
|
| 693 |
+
case self::PAYMENT_MARK_180x113:
|
| 694 |
+
break;
|
| 695 |
+
default:
|
| 696 |
+
$staticSize = self::PAYMENT_MARK_37x23;
|
| 697 |
+
}
|
| 698 |
+
return sprintf('https://www.paypal.com/%s/i/logo/PayPal_mark_%s.gif',
|
| 699 |
+
$this->_getSupportedLocaleCode($localeCode), $staticSize);
|
| 700 |
+
}
|
| 701 |
+
|
| 702 |
+
/**
|
| 703 |
+
* Get "What Is PayPal" localized URL
|
| 704 |
+
* Supposed to be used with "mark" as popup window
|
| 705 |
+
*
|
| 706 |
+
* @param Mage_Core_Model_Locale $locale
|
| 707 |
+
*/
|
| 708 |
+
public function getPaymentMarkWhatIsPaypalUrl(Mage_Core_Model_Locale $locale = null)
|
| 709 |
+
{
|
| 710 |
+
$countryCode = 'US';
|
| 711 |
+
if (null !== $locale) {
|
| 712 |
+
$shouldEmulate = (null !== $this->_storeId) && (Mage::app()->getStore()->getId() != $this->_storeId);
|
| 713 |
+
if ($shouldEmulate) {
|
| 714 |
+
$locale->emulate($this->_storeId);
|
| 715 |
+
}
|
| 716 |
+
$countryCode = $locale->getLocale()->getRegion();
|
| 717 |
+
if ($shouldEmulate) {
|
| 718 |
+
$locale->revert();
|
| 719 |
+
}
|
| 720 |
+
}
|
| 721 |
+
return sprintf('https://www.paypal.com/%s/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside',
|
| 722 |
+
strtolower($countryCode)
|
| 723 |
+
);
|
| 724 |
+
}
|
| 725 |
+
|
| 726 |
+
/**
|
| 727 |
+
* Getter for Solution banner images
|
| 728 |
+
*
|
| 729 |
+
* @param string $localeCode
|
| 730 |
+
* @param bool $isVertical
|
| 731 |
+
* @param bool $isEcheck
|
| 732 |
+
*/
|
| 733 |
+
public function getSolutionImageUrl($localeCode, $isVertical = false, $isEcheck = false)
|
| 734 |
+
{
|
| 735 |
+
return sprintf('https://www.paypal.com/%s/i/bnr/%s_solution_PP%s.gif',
|
| 736 |
+
$this->_getSupportedLocaleCode($localeCode),
|
| 737 |
+
$isVertical ? 'vertical' : 'horizontal', $isEcheck ? 'eCheck' : ''
|
| 738 |
+
);
|
| 739 |
+
}
|
| 740 |
+
|
| 741 |
+
/**
|
| 742 |
+
* Getter for Payment form logo images
|
| 743 |
+
*
|
| 744 |
+
* @param string $localeCode
|
| 745 |
+
*/
|
| 746 |
+
public function getPaymentFormLogoUrl($localeCode)
|
| 747 |
+
{
|
| 748 |
+
$locale = $this->_getSupportedLocaleCode($localeCode);
|
| 749 |
+
|
| 750 |
+
$imageType = 'logo';
|
| 751 |
+
$domain = 'paypal.com';
|
| 752 |
+
list (,$country) = explode('_', $locale);
|
| 753 |
+
$countryPrefix = $country . '/';
|
| 754 |
+
|
| 755 |
+
switch ($locale) {
|
| 756 |
+
case 'en_GB':
|
| 757 |
+
$imageName = 'horizontal_solution_PP';
|
| 758 |
+
$imageType = 'bnr';
|
| 759 |
+
$countryPrefix = '';
|
| 760 |
+
break;
|
| 761 |
+
case 'de_DE':
|
| 762 |
+
$imageName = 'lockbox_150x47';
|
| 763 |
+
break;
|
| 764 |
+
case 'fr_FR':
|
| 765 |
+
$imageName = 'bnr_horizontal_solution_PP_327wx80h';
|
| 766 |
+
$imageType = 'bnr';
|
| 767 |
+
$locale = 'en_US';
|
| 768 |
+
$domain = 'paypalobjects.com';
|
| 769 |
+
break;
|
| 770 |
+
case 'it_IT':
|
| 771 |
+
$imageName = 'bnr_horizontal_solution_PP_178wx80h';
|
| 772 |
+
$imageType = 'bnr';
|
| 773 |
+
$domain = 'paypalobjects.com';
|
| 774 |
+
break;
|
| 775 |
+
default:
|
| 776 |
+
$imageName='PayPal_mark_60x38';
|
| 777 |
+
$countryPrefix = '';
|
| 778 |
+
break;
|
| 779 |
+
}
|
| 780 |
+
return sprintf('https://www.%s/%s/%si/%s/%s.gif', $domain, $locale, $countryPrefix, $imageType, $imageName);
|
| 781 |
+
}
|
| 782 |
+
|
| 783 |
+
/**
|
| 784 |
+
* Return supported types for PayPal logo
|
| 785 |
+
*
|
| 786 |
+
* @return array
|
| 787 |
+
*/
|
| 788 |
+
public function getAdditionalOptionsLogoTypes()
|
| 789 |
+
{
|
| 790 |
+
return array(
|
| 791 |
+
'wePrefer_150x60' => Mage::helper('paypal')->__('We prefer PayPal (150 X 60)'),
|
| 792 |
+
'wePrefer_150x40' => Mage::helper('paypal')->__('We prefer PayPal (150 X 40)'),
|
| 793 |
+
'nowAccepting_150x60' => Mage::helper('paypal')->__('Now accepting PayPal (150 X 60)'),
|
| 794 |
+
'nowAccepting_150x40' => Mage::helper('paypal')->__('Now accepting PayPal (150 X 40)'),
|
| 795 |
+
'paymentsBy_150x60' => Mage::helper('paypal')->__('Payments by PayPal (150 X 60)'),
|
| 796 |
+
'paymentsBy_150x40' => Mage::helper('paypal')->__('Payments by PayPal (150 X 40)'),
|
| 797 |
+
'shopNowUsing_150x60' => Mage::helper('paypal')->__('Shop now using (150 X 60)'),
|
| 798 |
+
'shopNowUsing_150x40' => Mage::helper('paypal')->__('Shop now using (150 X 40)'),
|
| 799 |
+
);
|
| 800 |
+
}
|
| 801 |
+
|
| 802 |
+
/**
|
| 803 |
+
* Return PayPal logo URL with additional options
|
| 804 |
+
*
|
| 805 |
+
* @param string $localeCode Supported locale code
|
| 806 |
+
* @param string $type One of supported logo types
|
| 807 |
+
* @return string|bool Logo Image URL or false if logo disabled in configuration
|
| 808 |
+
*/
|
| 809 |
+
public function getAdditionalOptionsLogoUrl($localeCode, $type = false)
|
| 810 |
+
{
|
| 811 |
+
$configType = Mage::getStoreConfig($this->_mapGenericStyleFieldset('logo'), $this->_storeId);
|
| 812 |
+
if (!$configType) {
|
| 813 |
+
return false;
|
| 814 |
+
}
|
| 815 |
+
$type = $type ? $type : $configType;
|
| 816 |
+
$locale = $this->_getSupportedLocaleCode($localeCode);
|
| 817 |
+
$supportedTypes = array_keys($this->getAdditionalOptionsLogoTypes());
|
| 818 |
+
if (!in_array($type, $supportedTypes)) {
|
| 819 |
+
$type = self::DEFAULT_LOGO_TYPE;
|
| 820 |
+
}
|
| 821 |
+
return sprintf('https://www.paypalobjects.com/%s/i/bnr/bnr_%s.gif', $locale, $type);
|
| 822 |
+
}
|
| 823 |
+
|
| 824 |
+
/**
|
| 825 |
+
* BN code getter
|
| 826 |
+
*
|
| 827 |
+
* @param string $countryCode ISO 3166-1
|
| 828 |
+
*/
|
| 829 |
+
public function getBuildNotationCode($countryCode = null)
|
| 830 |
+
{
|
| 831 |
+
$product = 'WPP';
|
| 832 |
+
if ($this->_methodCode && isset($this->_buildNotationPPMap[$this->_methodCode])) {
|
| 833 |
+
$product = $this->_buildNotationPPMap[$this->_methodCode];
|
| 834 |
+
}
|
| 835 |
+
if (null === $countryCode) {
|
| 836 |
+
$countryCode = $this->_matchBnCountryCode($this->getMerchantCountry());
|
| 837 |
+
}
|
| 838 |
+
if ($countryCode) {
|
| 839 |
+
$countryCode = '_' . $countryCode;
|
| 840 |
+
}
|
| 841 |
+
return sprintf('Varien_Cart_%s%s', $product, $countryCode);
|
| 842 |
+
}
|
| 843 |
+
|
| 844 |
+
/**
|
| 845 |
+
* Express Checkout button "flavors" source getter
|
| 846 |
+
*
|
| 847 |
+
* @return array
|
| 848 |
+
*/
|
| 849 |
+
public function getExpressCheckoutButtonFlavors()
|
| 850 |
+
{
|
| 851 |
+
return array(
|
| 852 |
+
self::EC_FLAVOR_DYNAMIC => Mage::helper('paypal')->__('Dynamic'),
|
| 853 |
+
self::EC_FLAVOR_STATIC => Mage::helper('paypal')->__('Static'),
|
| 854 |
+
);
|
| 855 |
+
}
|
| 856 |
+
|
| 857 |
+
/**
|
| 858 |
+
* Express Checkout button types source getter
|
| 859 |
+
*
|
| 860 |
+
* @return array
|
| 861 |
+
*/
|
| 862 |
+
public function getExpressCheckoutButtonTypes()
|
| 863 |
+
{
|
| 864 |
+
return array(
|
| 865 |
+
self::EC_BUTTON_TYPE_SHORTCUT => Mage::helper('paypal')->__('Shortcut'),
|
| 866 |
+
self::EC_BUTTON_TYPE_MARK => Mage::helper('paypal')->__('Acceptance Mark Image'),
|
| 867 |
+
);
|
| 868 |
+
}
|
| 869 |
+
|
| 870 |
+
/**
|
| 871 |
+
* Payment actions source getter
|
| 872 |
+
*
|
| 873 |
+
* @return array
|
| 874 |
+
*/
|
| 875 |
+
public function getPaymentActions()
|
| 876 |
+
{
|
| 877 |
+
$paymentActions = array(
|
| 878 |
+
self::PAYMENT_ACTION_AUTH => Mage::helper('paypal')->__('Authorization'),
|
| 879 |
+
self::PAYMENT_ACTION_SALE => Mage::helper('paypal')->__('Sale')
|
| 880 |
+
);
|
| 881 |
+
if (!is_null($this->_methodCode) && $this->_methodCode == self::METHOD_WPP_EXPRESS) {
|
| 882 |
+
$paymentActions[self::PAYMENT_ACTION_ORDER] = Mage::helper('paypal')->__('Order');
|
| 883 |
+
}
|
| 884 |
+
return $paymentActions;
|
| 885 |
+
}
|
| 886 |
+
|
| 887 |
+
/**
|
| 888 |
+
* Require Billing Address source getter
|
| 889 |
+
*
|
| 890 |
+
* @return array
|
| 891 |
+
*/
|
| 892 |
+
public function getRequireBillingAddressOptions()
|
| 893 |
+
{
|
| 894 |
+
return array(
|
| 895 |
+
self::REQUIRE_BILLING_ADDRESS_ALL => Mage::helper('paypal')->__('Yes'),
|
| 896 |
+
self::REQUIRE_BILLING_ADDRESS_NO => Mage::helper('paypal')->__('No'),
|
| 897 |
+
self::REQUIRE_BILLING_ADDRESS_VIRTUAL => Mage::helper('paypal')->__('For Virtual Quotes Only'),
|
| 898 |
+
);
|
| 899 |
+
}
|
| 900 |
+
|
| 901 |
+
/**
|
| 902 |
+
* Mapper from PayPal-specific payment actions to Magento payment actions
|
| 903 |
+
*
|
| 904 |
+
* @return string|null
|
| 905 |
+
*/
|
| 906 |
+
public function getPaymentAction()
|
| 907 |
+
{
|
| 908 |
+
switch ($this->paymentAction) {
|
| 909 |
+
case self::PAYMENT_ACTION_AUTH:
|
| 910 |
+
return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
|
| 911 |
+
case self::PAYMENT_ACTION_SALE:
|
| 912 |
+
return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE;
|
| 913 |
+
case self::PAYMENT_ACTION_ORDER:
|
| 914 |
+
return Mage_Payment_Model_Method_Abstract::ACTION_ORDER;
|
| 915 |
+
}
|
| 916 |
+
}
|
| 917 |
+
|
| 918 |
+
/**
|
| 919 |
+
* Returns array of possible Authorization Amounts for Account Verification
|
| 920 |
+
*
|
| 921 |
+
* @deprecated since 1.6.2.0
|
| 922 |
+
* @return array
|
| 923 |
+
*/
|
| 924 |
+
public function getAuthorizationAmounts()
|
| 925 |
+
{
|
| 926 |
+
return array();
|
| 927 |
+
}
|
| 928 |
+
|
| 929 |
+
/**
|
| 930 |
+
* Express Checkout "solution types" source getter
|
| 931 |
+
* "sole" = "Express Checkout for Auctions" - PayPal allows guest checkout
|
| 932 |
+
* "mark" = "Normal Express Checkout" - PayPal requires to checkout with PayPal buyer account only
|
| 933 |
+
*
|
| 934 |
+
* @return array
|
| 935 |
+
*/
|
| 936 |
+
public function getExpressCheckoutSolutionTypes()
|
| 937 |
+
{
|
| 938 |
+
return array(
|
| 939 |
+
self::EC_SOLUTION_TYPE_SOLE => Mage::helper('paypal')->__('Yes'),
|
| 940 |
+
self::EC_SOLUTION_TYPE_MARK => Mage::helper('paypal')->__('No'),
|
| 941 |
+
);
|
| 942 |
+
}
|
| 943 |
+
|
| 944 |
+
/**
|
| 945 |
+
* Retrieve express checkout billing agreement signup options
|
| 946 |
+
*
|
| 947 |
+
* @return array
|
| 948 |
+
*/
|
| 949 |
+
public function getExpressCheckoutBASignupOptions()
|
| 950 |
+
{
|
| 951 |
+
return array(
|
| 952 |
+
self::EC_BA_SIGNUP_AUTO => Mage::helper('paypal')->__('Auto'),
|
| 953 |
+
self::EC_BA_SIGNUP_ASK => Mage::helper('paypal')->__('Ask Customer'),
|
| 954 |
+
self::EC_BA_SIGNUP_NEVER => Mage::helper('paypal')->__('Never')
|
| 955 |
+
);
|
| 956 |
+
}
|
| 957 |
+
|
| 958 |
+
/**
|
| 959 |
+
* Whether to ask customer to create billing agreements
|
| 960 |
+
* Unilateral payments are incompatible with the billing agreements
|
| 961 |
+
*
|
| 962 |
+
* @return bool
|
| 963 |
+
*/
|
| 964 |
+
public function shouldAskToCreateBillingAgreement()
|
| 965 |
+
{
|
| 966 |
+
return ($this->allow_ba_signup === self::EC_BA_SIGNUP_ASK) && !$this->shouldUseUnilateralPayments();
|
| 967 |
+
}
|
| 968 |
+
|
| 969 |
+
/**
|
| 970 |
+
* Check whether only Unilateral payments (Accelerated Boarding) possible for Express method or not
|
| 971 |
+
*
|
| 972 |
+
* @return bool
|
| 973 |
+
*/
|
| 974 |
+
public function shouldUseUnilateralPayments()
|
| 975 |
+
{
|
| 976 |
+
return $this->business_account && !$this->isWppApiAvailabe();
|
| 977 |
+
}
|
| 978 |
+
|
| 979 |
+
/**
|
| 980 |
+
* Check whether WPP API credentials are available for this method
|
| 981 |
+
*
|
| 982 |
+
* @return bool
|
| 983 |
+
*/
|
| 984 |
+
public function isWppApiAvailabe()
|
| 985 |
+
{
|
| 986 |
+
return $this->api_username && $this->api_password && ($this->api_signature || $this->api_cert);
|
| 987 |
+
}
|
| 988 |
+
|
| 989 |
+
/**
|
| 990 |
+
* Payment data delivery methods getter for PayPal Standard
|
| 991 |
+
*
|
| 992 |
+
* @return array
|
| 993 |
+
*/
|
| 994 |
+
public function getWpsPaymentDeliveryMethods()
|
| 995 |
+
{
|
| 996 |
+
return array(
|
| 997 |
+
self::WPS_TRANSPORT_IPN => Mage::helper('adminhtml')->__('IPN (Instant Payment Notification) Only'),
|
| 998 |
+
// not supported yet:
|
| 999 |
+
// self::WPS_TRANSPORT_PDT => Mage::helper('adminhtml')->__('PDT (Payment Data Transfer) Only'),
|
| 1000 |
+
// self::WPS_TRANSPORT_IPN_PDT => Mage::helper('adminhtml')->__('Both IPN and PDT'),
|
| 1001 |
+
);
|
| 1002 |
+
}
|
| 1003 |
+
|
| 1004 |
+
/**
|
| 1005 |
+
* Return list of supported credit card types by Paypal Direct gateway
|
| 1006 |
+
*
|
| 1007 |
+
* @return array
|
| 1008 |
+
*/
|
| 1009 |
+
public function getWppCcTypesAsOptionArray()
|
| 1010 |
+
{
|
| 1011 |
+
$model = Mage::getModel('payment/source_cctype')->setAllowedTypes(array('AE', 'VI', 'MC', 'SM', 'SO', 'DI'));
|
| 1012 |
+
return $model->toOptionArray();
|
| 1013 |
+
}
|
| 1014 |
+
|
| 1015 |
+
/**
|
| 1016 |
+
* Return list of supported credit card types by Paypal Direct (Payflow Edition) gateway
|
| 1017 |
+
*
|
| 1018 |
+
* @return array
|
| 1019 |
+
*/
|
| 1020 |
+
public function getWppPeCcTypesAsOptionArray()
|
| 1021 |
+
{
|
| 1022 |
+
$model = Mage::getModel('payment/source_cctype')->setAllowedTypes(array('VI', 'MC', 'SM', 'SO', 'OT', 'AE'));
|
| 1023 |
+
return $model->toOptionArray();
|
| 1024 |
+
}
|
| 1025 |
+
|
| 1026 |
+
/**
|
| 1027 |
+
* Return list of supported credit card types by Payflow Pro gateway
|
| 1028 |
+
*
|
| 1029 |
+
* @return array
|
| 1030 |
+
*/
|
| 1031 |
+
public function getPayflowproCcTypesAsOptionArray()
|
| 1032 |
+
{
|
| 1033 |
+
$model = Mage::getModel('payment/source_cctype')->setAllowedTypes(array('AE', 'VI', 'MC', 'JCB', 'DI'));
|
| 1034 |
+
return $model->toOptionArray();
|
| 1035 |
+
}
|
| 1036 |
+
|
| 1037 |
+
/**
|
| 1038 |
+
* Check whether the specified payment method is a CC-based one
|
| 1039 |
+
*
|
| 1040 |
+
* @param string $code
|
| 1041 |
+
* @return bool
|
| 1042 |
+
*/
|
| 1043 |
+
public static function getIsCreditCardMethod($code)
|
| 1044 |
+
{
|
| 1045 |
+
switch ($code) {
|
| 1046 |
+
case self::METHOD_WPP_DIRECT:
|
| 1047 |
+
case self::METHOD_WPP_PE_DIRECT:
|
| 1048 |
+
case self::METHOD_PAYFLOWPRO:
|
| 1049 |
+
case self::METHOD_PAYFLOWLINK:
|
| 1050 |
+
case self::METHOD_PAYFLOWADVANCED:
|
| 1051 |
+
case self::METHOD_HOSTEDPRO:
|
| 1052 |
+
return true;
|
| 1053 |
+
}
|
| 1054 |
+
return false;
|
| 1055 |
+
}
|
| 1056 |
+
|
| 1057 |
+
/**
|
| 1058 |
+
* Check whether specified currency code is supported
|
| 1059 |
+
*
|
| 1060 |
+
* @param string $code
|
| 1061 |
+
* @return bool
|
| 1062 |
+
*/
|
| 1063 |
+
public function isCurrencyCodeSupported($code)
|
| 1064 |
+
{
|
| 1065 |
+
if (in_array($code, $this->_supportedCurrencyCodes)) {
|
| 1066 |
+
return true;
|
| 1067 |
+
}
|
| 1068 |
+
if ($this->getMerchantCountry() == 'BR' && $code == 'BRL') {
|
| 1069 |
+
return true;
|
| 1070 |
+
}
|
| 1071 |
+
if ($this->getMerchantCountry() == 'MY' && $code == 'MYR') {
|
| 1072 |
+
return true;
|
| 1073 |
+
}
|
| 1074 |
+
return false;
|
| 1075 |
+
}
|
| 1076 |
+
|
| 1077 |
+
/**
|
| 1078 |
+
* Export page style current settings to specified object
|
| 1079 |
+
*
|
| 1080 |
+
* @param Varien_Object $to
|
| 1081 |
+
*/
|
| 1082 |
+
public function exportExpressCheckoutStyleSettings(Varien_Object $to)
|
| 1083 |
+
{
|
| 1084 |
+
foreach ($this->_ecStyleConfigMap as $key => $exportKey) {
|
| 1085 |
+
if ($this->$key) {
|
| 1086 |
+
$to->setData($exportKey, $this->$key);
|
| 1087 |
+
}
|
| 1088 |
+
}
|
| 1089 |
+
}
|
| 1090 |
+
|
| 1091 |
+
/**
|
| 1092 |
+
* Dynamic PayPal image URL getter
|
| 1093 |
+
* Also can render dynamic Acceptance Mark
|
| 1094 |
+
*
|
| 1095 |
+
* @param string $type
|
| 1096 |
+
* @param string $localeCode
|
| 1097 |
+
* @param float $orderTotal
|
| 1098 |
+
* @param string $pal
|
| 1099 |
+
*/
|
| 1100 |
+
protected function _getDynamicImageUrl($type, $localeCode, $orderTotal, $pal)
|
| 1101 |
+
{
|
| 1102 |
+
$params = array(
|
| 1103 |
+
'cmd' => '_dynamic-image',
|
| 1104 |
+
'buttontype' => $type,
|
| 1105 |
+
'locale' => $this->_getSupportedLocaleCode($localeCode),
|
| 1106 |
+
);
|
| 1107 |
+
if ($orderTotal) {
|
| 1108 |
+
$params['ordertotal'] = sprintf('%.2F', $orderTotal);
|
| 1109 |
+
if ($pal) {
|
| 1110 |
+
$params['pal'] = $pal;
|
| 1111 |
+
}
|
| 1112 |
+
}
|
| 1113 |
+
return sprintf('https://fpdbs%s.paypal.com/dynamicimageweb?%s',
|
| 1114 |
+
$this->sandboxFlag ? '.sandbox' : '', http_build_query($params)
|
| 1115 |
+
);
|
| 1116 |
+
}
|
| 1117 |
+
|
| 1118 |
+
/**
|
| 1119 |
+
* Check whether specified locale code is supported. Fallback to en_US
|
| 1120 |
+
*
|
| 1121 |
+
* @param string $localeCode
|
| 1122 |
+
* @return string
|
| 1123 |
+
*/
|
| 1124 |
+
protected function _getSupportedLocaleCode($localeCode = null)
|
| 1125 |
+
{
|
| 1126 |
+
if (!$localeCode || !in_array($localeCode, $this->_supportedImageLocales)) {
|
| 1127 |
+
return 'en_US';
|
| 1128 |
+
}
|
| 1129 |
+
return $localeCode;
|
| 1130 |
+
}
|
| 1131 |
+
|
| 1132 |
+
/**
|
| 1133 |
+
* Map any supported payment method into a config path by specified field name
|
| 1134 |
+
*
|
| 1135 |
+
* @param string $fieldName
|
| 1136 |
+
* @return string|null
|
| 1137 |
+
*/
|
| 1138 |
+
protected function _getSpecificConfigPath($fieldName)
|
| 1139 |
+
{
|
| 1140 |
+
$path = null;
|
| 1141 |
+
switch ($this->_methodCode) {
|
| 1142 |
+
case self::METHOD_WPS:
|
| 1143 |
+
$path = $this->_mapStandardFieldset($fieldName);
|
| 1144 |
+
break;
|
| 1145 |
+
case self::METHOD_WPP_EXPRESS:
|
| 1146 |
+
case self::METHOD_WPP_PE_EXPRESS:
|
| 1147 |
+
$path = $this->_mapExpressFieldset($fieldName);
|
| 1148 |
+
break;
|
| 1149 |
+
case self::METHOD_WPP_DIRECT:
|
| 1150 |
+
case self::METHOD_WPP_PE_DIRECT:
|
| 1151 |
+
$path = $this->_mapDirectFieldset($fieldName);
|
| 1152 |
+
break;
|
| 1153 |
+
case self::METHOD_BILLING_AGREEMENT:
|
| 1154 |
+
case self::METHOD_HOSTEDPRO:
|
| 1155 |
+
$path = $this->_mapMethodFieldset($fieldName);
|
| 1156 |
+
break;
|
| 1157 |
+
}
|
| 1158 |
+
|
| 1159 |
+
if ($path === null) {
|
| 1160 |
+
switch ($this->_methodCode) {
|
| 1161 |
+
case self::METHOD_WPP_EXPRESS:
|
| 1162 |
+
case self::METHOD_WPP_DIRECT:
|
| 1163 |
+
case self::METHOD_BILLING_AGREEMENT:
|
| 1164 |
+
case self::METHOD_HOSTEDPRO:
|
| 1165 |
+
$path = $this->_mapWppFieldset($fieldName);
|
| 1166 |
+
break;
|
| 1167 |
+
case self::METHOD_WPP_PE_EXPRESS:
|
| 1168 |
+
case self::METHOD_WPP_PE_DIRECT:
|
| 1169 |
+
case self::METHOD_PAYFLOWADVANCED:
|
| 1170 |
+
case self::METHOD_PAYFLOWLINK:
|
| 1171 |
+
$path = $this->_mapWpukFieldset($fieldName);
|
| 1172 |
+
break;
|
| 1173 |
+
}
|
| 1174 |
+
}
|
| 1175 |
+
|
| 1176 |
+
if ($path === null) {
|
| 1177 |
+
$path = $this->_mapGeneralFieldset($fieldName);
|
| 1178 |
+
}
|
| 1179 |
+
if ($path === null) {
|
| 1180 |
+
$path = $this->_mapGenericStyleFieldset($fieldName);
|
| 1181 |
+
}
|
| 1182 |
+
return $path;
|
| 1183 |
+
}
|
| 1184 |
+
|
| 1185 |
+
/**
|
| 1186 |
+
* Check wheter specified country code is supported by build notation codes for specific countries
|
| 1187 |
+
*
|
| 1188 |
+
* @param $code
|
| 1189 |
+
* @return string|null
|
| 1190 |
+
*/
|
| 1191 |
+
private function _matchBnCountryCode($code)
|
| 1192 |
+
{
|
| 1193 |
+
switch ($code) {
|
| 1194 |
+
// GB == UK
|
| 1195 |
+
case 'GB':
|
| 1196 |
+
return 'UK';
|
| 1197 |
+
// Australia, Austria, Belgium, Canada, China, France, Germany, Hong Kong, Italy
|
| 1198 |
+
case 'AU': case 'AT': case 'BE': case 'CA': case 'CN': case 'FR': case 'DE': case 'HK': case 'IT':
|
| 1199 |
+
// Japan, Mexico, Netherlands, Poland, Singapore, Spain, Switzerland, United Kingdom, United States
|
| 1200 |
+
case 'JP': case 'MX': case 'NL': case 'PL': case 'SG': case 'ES': case 'CH': case 'UK': case 'US':
|
| 1201 |
+
return $code;
|
| 1202 |
+
}
|
| 1203 |
+
}
|
| 1204 |
+
|
| 1205 |
+
/**
|
| 1206 |
+
* Map PayPal Standard config fields
|
| 1207 |
+
*
|
| 1208 |
+
* @param string $fieldName
|
| 1209 |
+
* @return string|null
|
| 1210 |
+
*/
|
| 1211 |
+
protected function _mapStandardFieldset($fieldName)
|
| 1212 |
+
{
|
| 1213 |
+
switch ($fieldName)
|
| 1214 |
+
{
|
| 1215 |
+
case 'line_items_summary':
|
| 1216 |
+
case 'sandbox_flag':
|
| 1217 |
+
return 'payment/' . self::METHOD_WPS . "/{$fieldName}";
|
| 1218 |
+
default:
|
| 1219 |
+
return $this->_mapMethodFieldset($fieldName);
|
| 1220 |
+
}
|
| 1221 |
+
}
|
| 1222 |
+
|
| 1223 |
+
/**
|
| 1224 |
+
* Map PayPal Express config fields
|
| 1225 |
+
*
|
| 1226 |
+
* @param string $fieldName
|
| 1227 |
+
* @return string|null
|
| 1228 |
+
*/
|
| 1229 |
+
protected function _mapExpressFieldset($fieldName)
|
| 1230 |
+
{
|
| 1231 |
+
switch ($fieldName)
|
| 1232 |
+
{
|
| 1233 |
+
case 'transfer_shipping_options':
|
| 1234 |
+
case 'solution_type':
|
| 1235 |
+
case 'visible_on_cart':
|
| 1236 |
+
case 'visible_on_product':
|
| 1237 |
+
case 'require_billing_address':
|
| 1238 |
+
case 'authorization_honor_period':
|
| 1239 |
+
case 'order_valid_period':
|
| 1240 |
+
case 'child_authorization_number':
|
| 1241 |
+
case 'allow_ba_signup':
|
| 1242 |
+
return "payment/{$this->_methodCode}/{$fieldName}";
|
| 1243 |
+
default:
|
| 1244 |
+
return $this->_mapMethodFieldset($fieldName);
|
| 1245 |
+
}
|
| 1246 |
+
}
|
| 1247 |
+
|
| 1248 |
+
/**
|
| 1249 |
+
* Map PayPal Direct config fields
|
| 1250 |
+
*
|
| 1251 |
+
* @param string $fieldName
|
| 1252 |
+
* @return string|null
|
| 1253 |
+
*/
|
| 1254 |
+
protected function _mapDirectFieldset($fieldName)
|
| 1255 |
+
{
|
| 1256 |
+
switch ($fieldName)
|
| 1257 |
+
{
|
| 1258 |
+
case 'useccv':
|
| 1259 |
+
case 'centinel':
|
| 1260 |
+
case 'centinel_is_mode_strict':
|
| 1261 |
+
case 'centinel_api_url':
|
| 1262 |
+
return "payment/{$this->_methodCode}/{$fieldName}";
|
| 1263 |
+
default:
|
| 1264 |
+
return $this->_mapMethodFieldset($fieldName);
|
| 1265 |
+
}
|
| 1266 |
+
}
|
| 1267 |
+
|
| 1268 |
+
/**
|
| 1269 |
+
* Map PayPal Website Payments Pro common config fields
|
| 1270 |
+
*
|
| 1271 |
+
* @param string $fieldName
|
| 1272 |
+
* @return string|null
|
| 1273 |
+
*/
|
| 1274 |
+
protected function _mapWppFieldset($fieldName)
|
| 1275 |
+
{
|
| 1276 |
+
switch ($fieldName)
|
| 1277 |
+
{
|
| 1278 |
+
case 'api_authentication':
|
| 1279 |
+
case 'api_username':
|
| 1280 |
+
case 'api_password':
|
| 1281 |
+
case 'api_signature':
|
| 1282 |
+
case 'api_cert':
|
| 1283 |
+
case 'sandbox_flag':
|
| 1284 |
+
case 'use_proxy':
|
| 1285 |
+
case 'proxy_host':
|
| 1286 |
+
case 'proxy_port':
|
| 1287 |
+
case 'button_flavor':
|
| 1288 |
+
return "paypal/wpp/{$fieldName}";
|
| 1289 |
+
default:
|
| 1290 |
+
return null;
|
| 1291 |
+
}
|
| 1292 |
+
}
|
| 1293 |
+
|
| 1294 |
+
/**
|
| 1295 |
+
* Map PayPal Website Payments Pro common config fields
|
| 1296 |
+
*
|
| 1297 |
+
* @param string $fieldName
|
| 1298 |
+
* @return string|null
|
| 1299 |
+
*/
|
| 1300 |
+
protected function _mapWpukFieldset($fieldName)
|
| 1301 |
+
{
|
| 1302 |
+
$pathPrefix = 'paypal/wpuk';
|
| 1303 |
+
// Use PUMP credentials from Verisign for EC when Direct Payments are unavailable
|
| 1304 |
+
if ($this->_methodCode == self::METHOD_WPP_PE_EXPRESS
|
| 1305 |
+
&& !$this->isMethodAvailable(self::METHOD_WPP_PE_DIRECT)) {
|
| 1306 |
+
$pathPrefix = 'payment/verisign';
|
| 1307 |
+
} elseif ($this->_methodCode == self::METHOD_PAYFLOWADVANCED
|
| 1308 |
+
|| $this->_methodCode == self::METHOD_PAYFLOWLINK
|
| 1309 |
+
) {
|
| 1310 |
+
$pathPrefix = 'payment/' . $this->_methodCode;
|
| 1311 |
+
}
|
| 1312 |
+
switch ($fieldName) {
|
| 1313 |
+
case 'partner':
|
| 1314 |
+
case 'user':
|
| 1315 |
+
case 'vendor':
|
| 1316 |
+
case 'pwd':
|
| 1317 |
+
case 'sandbox_flag':
|
| 1318 |
+
case 'use_proxy':
|
| 1319 |
+
case 'proxy_host':
|
| 1320 |
+
case 'proxy_port':
|
| 1321 |
+
return $pathPrefix . '/' . $fieldName;
|
| 1322 |
+
default:
|
| 1323 |
+
return null;
|
| 1324 |
+
}
|
| 1325 |
+
}
|
| 1326 |
+
|
| 1327 |
+
/**
|
| 1328 |
+
* Map PayPal common style config fields
|
| 1329 |
+
*
|
| 1330 |
+
* @param string $fieldName
|
| 1331 |
+
* @return string|null
|
| 1332 |
+
*/
|
| 1333 |
+
protected function _mapGenericStyleFieldset($fieldName)
|
| 1334 |
+
{
|
| 1335 |
+
switch ($fieldName) {
|
| 1336 |
+
case 'logo':
|
| 1337 |
+
case 'page_style':
|
| 1338 |
+
case 'paypal_hdrimg':
|
| 1339 |
+
case 'paypal_hdrbackcolor':
|
| 1340 |
+
case 'paypal_hdrbordercolor':
|
| 1341 |
+
case 'paypal_payflowcolor':
|
| 1342 |
+
return "paypal/style/{$fieldName}";
|
| 1343 |
+
default:
|
| 1344 |
+
return null;
|
| 1345 |
+
}
|
| 1346 |
+
}
|
| 1347 |
+
|
| 1348 |
+
/**
|
| 1349 |
+
* Map PayPal General Settings
|
| 1350 |
+
*
|
| 1351 |
+
* @param string $fieldName
|
| 1352 |
+
* @return string|null
|
| 1353 |
+
*/
|
| 1354 |
+
protected function _mapGeneralFieldset($fieldName)
|
| 1355 |
+
{
|
| 1356 |
+
switch ($fieldName)
|
| 1357 |
+
{
|
| 1358 |
+
case 'business_account':
|
| 1359 |
+
case 'merchant_country':
|
| 1360 |
+
return "paypal/general/{$fieldName}";
|
| 1361 |
+
default:
|
| 1362 |
+
return null;
|
| 1363 |
+
}
|
| 1364 |
+
}
|
| 1365 |
+
|
| 1366 |
+
/**
|
| 1367 |
+
* Map PayPal General Settings
|
| 1368 |
+
*
|
| 1369 |
+
* @param string $fieldName
|
| 1370 |
+
* @return string|null
|
| 1371 |
+
*/
|
| 1372 |
+
protected function _mapMethodFieldset($fieldName)
|
| 1373 |
+
{
|
| 1374 |
+
if (!$this->_methodCode) {
|
| 1375 |
+
return null;
|
| 1376 |
+
}
|
| 1377 |
+
switch ($fieldName)
|
| 1378 |
+
{
|
| 1379 |
+
case 'active':
|
| 1380 |
+
case 'title':
|
| 1381 |
+
case 'payment_action':
|
| 1382 |
+
case 'allowspecific':
|
| 1383 |
+
case 'specificcountry':
|
| 1384 |
+
case 'line_items_enabled':
|
| 1385 |
+
case 'cctypes':
|
| 1386 |
+
case 'sort_order':
|
| 1387 |
+
case 'debug':
|
| 1388 |
+
case 'verify_peer':
|
| 1389 |
+
return "payment/{$this->_methodCode}/{$fieldName}";
|
| 1390 |
+
default:
|
| 1391 |
+
return null;
|
| 1392 |
+
}
|
| 1393 |
+
}
|
| 1394 |
+
|
| 1395 |
+
/**
|
| 1396 |
+
* Payment API authentication methods source getter
|
| 1397 |
+
*
|
| 1398 |
+
* @return array
|
| 1399 |
+
*/
|
| 1400 |
+
public function getApiAuthenticationMethods()
|
| 1401 |
+
{
|
| 1402 |
+
return array(
|
| 1403 |
+
'0' => Mage::helper('paypal')->__('API Signature'),
|
| 1404 |
+
'1' => Mage::helper('paypal')->__('API Certificate')
|
| 1405 |
+
);
|
| 1406 |
+
}
|
| 1407 |
+
|
| 1408 |
+
/**
|
| 1409 |
+
* Api certificate getter
|
| 1410 |
+
*
|
| 1411 |
+
* @return string
|
| 1412 |
+
*/
|
| 1413 |
+
public function getApiCertificate()
|
| 1414 |
+
{
|
| 1415 |
+
$websiteId = Mage::app()->getStore($this->_storeId)->getWebsiteId();
|
| 1416 |
+
return Mage::getModel('paypal/cert')->loadByWebsite($websiteId, false)->getCertPath();
|
| 1417 |
+
}
|
| 1418 |
+
}
|
| 1419 |
+
|
app/code/local/Ced/LayBuy/Model/Express.php
ADDED
|
@@ -0,0 +1,771 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
*
|
| 29 |
+
* PayPal Express Module
|
| 30 |
+
*/
|
| 31 |
+
class Ced_LayBuy_Model_Express extends Mage_Payment_Model_Method_Abstract
|
| 32 |
+
implements Mage_Payment_Model_Recurring_Profile_MethodInterface
|
| 33 |
+
{
|
| 34 |
+
protected $_code = "laybuy_express";
|
| 35 |
+
//protected $_formBlockType = 'laybuy/express_form';
|
| 36 |
+
// protected $_infoBlockType = 'laybuy/payment_info';
|
| 37 |
+
protected $_formBlockType = 'laybuy/form_laybuy';
|
| 38 |
+
protected $_infoBlockType = 'laybuy/info_laybuy';
|
| 39 |
+
/**
|
| 40 |
+
* Website Payments Pro instance type
|
| 41 |
+
*
|
| 42 |
+
* @var $_proType string
|
| 43 |
+
*/
|
| 44 |
+
protected $_proType = 'laybuy/pro';
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Availability options
|
| 48 |
+
*/
|
| 49 |
+
protected $_isGateway = false;
|
| 50 |
+
protected $_canOrder = true;
|
| 51 |
+
protected $_canAuthorize = true;
|
| 52 |
+
protected $_canCapture = true;
|
| 53 |
+
protected $_canCapturePartial = true;
|
| 54 |
+
protected $_canRefund = true;
|
| 55 |
+
protected $_canRefundInvoicePartial = true;
|
| 56 |
+
protected $_canVoid = true;
|
| 57 |
+
protected $_canUseInternal = false;
|
| 58 |
+
protected $_canUseCheckout = true;
|
| 59 |
+
protected $_canUseForMultishipping = false;
|
| 60 |
+
protected $_canFetchTransactionInfo = true;
|
| 61 |
+
protected $_canCreateBillingAgreement = true;
|
| 62 |
+
protected $_canReviewPayment = true;
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* Website Payments Pro instance
|
| 66 |
+
*
|
| 67 |
+
* @var Mage_Paypal_Model_Pro
|
| 68 |
+
*/
|
| 69 |
+
protected $_pro = null;
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Payment additional information key for payment action
|
| 73 |
+
* @var string
|
| 74 |
+
*/
|
| 75 |
+
protected $_isOrderPaymentActionKey = 'is_order_action';
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* Payment additional information key for number of used authorizations
|
| 79 |
+
* @var string
|
| 80 |
+
*/
|
| 81 |
+
protected $_authorizationCountKey = 'authorization_count';
|
| 82 |
+
|
| 83 |
+
public function __construct($params = array())
|
| 84 |
+
{
|
| 85 |
+
$proInstance = array_shift($params);
|
| 86 |
+
if ($proInstance && ($proInstance instanceof Ced_LayBuy_Model_Pro)) {
|
| 87 |
+
$this->_pro = $proInstance;
|
| 88 |
+
} else {
|
| 89 |
+
$this->_pro = Mage::getModel($this->_proType);
|
| 90 |
+
}
|
| 91 |
+
$this->_pro->setMethod($this->_code);
|
| 92 |
+
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* Store setter
|
| 97 |
+
* Also updates store ID in config object
|
| 98 |
+
*
|
| 99 |
+
* @param Mage_Core_Model_Store|int $store
|
| 100 |
+
*/
|
| 101 |
+
public function setStore($store)
|
| 102 |
+
{
|
| 103 |
+
$this->setData('store', $store);
|
| 104 |
+
if (null === $store) {
|
| 105 |
+
$store = Mage::app()->getStore()->getId();
|
| 106 |
+
}
|
| 107 |
+
$this->_pro->getConfig()->setStoreId(is_object($store) ? $store->getId() : $store);
|
| 108 |
+
return $this;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
/**
|
| 112 |
+
* Can be used in regular checkout
|
| 113 |
+
*
|
| 114 |
+
* @return bool
|
| 115 |
+
*/
|
| 116 |
+
public function canUseCheckout()
|
| 117 |
+
{
|
| 118 |
+
if (Mage::getStoreConfigFlag('payment/hosted_pro/active')
|
| 119 |
+
&& !Mage::getStoreConfigFlag('payment/hosted_pro/display_ec')
|
| 120 |
+
) {
|
| 121 |
+
return false;
|
| 122 |
+
}
|
| 123 |
+
return parent::canUseCheckout();
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
/**
|
| 127 |
+
* Whether method is available for specified currency
|
| 128 |
+
*
|
| 129 |
+
* @param string $currencyCode
|
| 130 |
+
* @return bool
|
| 131 |
+
*/
|
| 132 |
+
public function canUseForCurrency($currencyCode)
|
| 133 |
+
{
|
| 134 |
+
return $this->_pro->getConfig()->isCurrencyCodeSupported($currencyCode);
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/**
|
| 138 |
+
* Payment action getter compatible with payment model
|
| 139 |
+
*
|
| 140 |
+
* @see Mage_Sales_Model_Payment::place()
|
| 141 |
+
* @return string
|
| 142 |
+
*/
|
| 143 |
+
public function getConfigPaymentAction()
|
| 144 |
+
{
|
| 145 |
+
/* echo get_class($this->_pro);
|
| 146 |
+
var_dump($this->_pro->getConfig()->getPaymentAction());die("herrooo"); */
|
| 147 |
+
return 'authorize';
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
/**
|
| 151 |
+
* Check whether payment method can be used
|
| 152 |
+
* @param Mage_Sales_Model_Quote
|
| 153 |
+
* @return bool
|
| 154 |
+
*/
|
| 155 |
+
/* public function isAvailable($quote = null)
|
| 156 |
+
{
|
| 157 |
+
if (parent::isAvailable($quote) && $this->_pro->getConfig()->isMethodAvailable()) {
|
| 158 |
+
return true;
|
| 159 |
+
}
|
| 160 |
+
return false;
|
| 161 |
+
} */
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
* Custom getter for payment configuration
|
| 165 |
+
*
|
| 166 |
+
* @param string $field
|
| 167 |
+
* @param int $storeId
|
| 168 |
+
* @return mixed
|
| 169 |
+
*/
|
| 170 |
+
public function getConfigData($field, $storeId = null)
|
| 171 |
+
{
|
| 172 |
+
return $this->_pro->getConfig()->$field;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
/**
|
| 176 |
+
* Order payment
|
| 177 |
+
*
|
| 178 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 179 |
+
* @param float $amount
|
| 180 |
+
* @return Mage_Paypal_Model_Express
|
| 181 |
+
*/
|
| 182 |
+
public function order(Varien_Object $payment, $amount)
|
| 183 |
+
{
|
| 184 |
+
$this->_placeOrder($payment, $amount);
|
| 185 |
+
|
| 186 |
+
$payment->setAdditionalInformation($this->_isOrderPaymentActionKey, true);
|
| 187 |
+
|
| 188 |
+
if ($payment->getIsFraudDetected()) {
|
| 189 |
+
return $this;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
$order = $payment->getOrder();
|
| 193 |
+
$orderTransactionId = $payment->getTransactionId();
|
| 194 |
+
|
| 195 |
+
$api = $this->_callDoAuthorize($amount, $payment, $payment->getTransactionId());
|
| 196 |
+
|
| 197 |
+
$state = Mage_Sales_Model_Order::STATE_PROCESSING;
|
| 198 |
+
$status = true;
|
| 199 |
+
|
| 200 |
+
$formatedPrice = $order->getBaseCurrency()->formatTxt($amount);
|
| 201 |
+
if ($payment->getIsTransactionPending()) {
|
| 202 |
+
$message = Mage::helper('laybuy')->__('Ordering amount of %s is pending approval on gateway.', $formatedPrice);
|
| 203 |
+
$state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
|
| 204 |
+
} else {
|
| 205 |
+
$message = Mage::helper('laybuy')->__('Ordered amount of %s.', $formatedPrice);
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
$payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, null, false, $message);
|
| 209 |
+
|
| 210 |
+
$this->_pro->importPaymentInfo($api, $payment);
|
| 211 |
+
|
| 212 |
+
if ($payment->getIsTransactionPending()) {
|
| 213 |
+
$message = Mage::helper('laybuy')->__('Authorizing amount of %s is pending approval on gateway.', $formatedPrice);
|
| 214 |
+
$state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
|
| 215 |
+
if ($payment->getIsFraudDetected()) {
|
| 216 |
+
$status = Mage_Sales_Model_Order::STATUS_FRAUD;
|
| 217 |
+
}
|
| 218 |
+
} else {
|
| 219 |
+
$message = Mage::helper('laybuy')->__('Authorized amount of %s.', $formatedPrice);
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
$payment->resetTransactionAdditionalInfo();
|
| 223 |
+
|
| 224 |
+
$payment->setTransactionId($api->getTransactionId());
|
| 225 |
+
$payment->setParentTransactionId($orderTransactionId);
|
| 226 |
+
|
| 227 |
+
$transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null, false,
|
| 228 |
+
$message
|
| 229 |
+
);
|
| 230 |
+
|
| 231 |
+
$order->setState($state, $status);
|
| 232 |
+
|
| 233 |
+
$payment->setSkipOrderProcessing(true);
|
| 234 |
+
return $this;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
/**
|
| 238 |
+
* Authorize payment
|
| 239 |
+
*
|
| 240 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 241 |
+
* @param float $amount
|
| 242 |
+
* @return Mage_Paypal_Model_Express
|
| 243 |
+
*/
|
| 244 |
+
public function authorize(Varien_Object $payment, $amount)
|
| 245 |
+
{
|
| 246 |
+
return $this->_placeOrder($payment, $amount);
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
/**
|
| 250 |
+
* Void payment
|
| 251 |
+
*
|
| 252 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 253 |
+
* @return Mage_Paypal_Model_Express
|
| 254 |
+
*/
|
| 255 |
+
public function void(Varien_Object $payment)
|
| 256 |
+
{
|
| 257 |
+
//Switching to order transaction if needed
|
| 258 |
+
if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)
|
| 259 |
+
&& !$payment->getVoidOnlyAuthorization()
|
| 260 |
+
) {
|
| 261 |
+
$orderTransaction = $payment->lookupTransaction(
|
| 262 |
+
false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 263 |
+
);
|
| 264 |
+
if ($orderTransaction) {
|
| 265 |
+
$payment->setParentTransactionId($orderTransaction->getTxnId());
|
| 266 |
+
$payment->setTransactionId($orderTransaction->getTxnId() . '-void');
|
| 267 |
+
}
|
| 268 |
+
}
|
| 269 |
+
$this->_pro->void($payment);
|
| 270 |
+
return $this;
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
/**
|
| 276 |
+
* Refund capture
|
| 277 |
+
*
|
| 278 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 279 |
+
* @param float $amount
|
| 280 |
+
* @return Mage_Paypal_Model_Express
|
| 281 |
+
*/
|
| 282 |
+
public function refund(Varien_Object $payment, $amount)
|
| 283 |
+
{
|
| 284 |
+
$this->_pro->refund($payment, $amount);
|
| 285 |
+
return $this;
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
/**
|
| 291 |
+
* Whether payment can be reviewed
|
| 292 |
+
*
|
| 293 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 294 |
+
* @return bool
|
| 295 |
+
*/
|
| 296 |
+
public function canReviewPayment(Mage_Payment_Model_Info $payment)
|
| 297 |
+
{
|
| 298 |
+
return parent::canReviewPayment($payment) && $this->_pro->canReviewPayment($payment);
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
/**
|
| 302 |
+
* Attempt to accept a pending payment
|
| 303 |
+
*
|
| 304 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 305 |
+
* @return bool
|
| 306 |
+
*/
|
| 307 |
+
public function acceptPayment(Mage_Payment_Model_Info $payment)
|
| 308 |
+
{
|
| 309 |
+
parent::acceptPayment($payment);
|
| 310 |
+
return $this->_pro->reviewPayment($payment, Mage_Paypal_Model_Pro::PAYMENT_REVIEW_ACCEPT);
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
/**
|
| 314 |
+
* Attempt to deny a pending payment
|
| 315 |
+
*
|
| 316 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 317 |
+
* @return bool
|
| 318 |
+
*/
|
| 319 |
+
public function denyPayment(Mage_Payment_Model_Info $payment)
|
| 320 |
+
{
|
| 321 |
+
parent::denyPayment($payment);
|
| 322 |
+
return $this->_pro->reviewPayment($payment, Mage_Paypal_Model_Pro::PAYMENT_REVIEW_DENY);
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
/**
|
| 326 |
+
* Checkout redirect URL getter for onepage checkout (hardcode)
|
| 327 |
+
*
|
| 328 |
+
* @see Mage_Checkout_OnepageController::savePaymentAction()
|
| 329 |
+
* @see Mage_Sales_Model_Quote_Payment::getCheckoutRedirectUrl()
|
| 330 |
+
* @return string
|
| 331 |
+
*/
|
| 332 |
+
public function getCheckoutRedirectUrl()
|
| 333 |
+
{
|
| 334 |
+
return Mage::getUrl('laybuy/express/start');
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
/**
|
| 338 |
+
* Fetch transaction details info
|
| 339 |
+
*
|
| 340 |
+
* @param Mage_Payment_Model_Info $payment
|
| 341 |
+
* @param string $transactionId
|
| 342 |
+
* @return array
|
| 343 |
+
*/
|
| 344 |
+
public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
|
| 345 |
+
{
|
| 346 |
+
return $this->_pro->fetchTransactionInfo($payment, $transactionId);
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
/**
|
| 350 |
+
* Validate RP data
|
| 351 |
+
*
|
| 352 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 353 |
+
*/
|
| 354 |
+
public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
| 355 |
+
{
|
| 356 |
+
return $this->_pro->validateRecurringProfile($profile);
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
/**
|
| 360 |
+
* Submit RP to the gateway
|
| 361 |
+
*
|
| 362 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 363 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
| 364 |
+
*/
|
| 365 |
+
public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile,
|
| 366 |
+
Mage_Payment_Model_Info $paymentInfo
|
| 367 |
+
) {
|
| 368 |
+
$token = $paymentInfo->
|
| 369 |
+
getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
|
| 370 |
+
$profile->setToken($token);
|
| 371 |
+
$this->_pro->submitRecurringProfile($profile, $paymentInfo);
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
/**
|
| 375 |
+
* Fetch RP details
|
| 376 |
+
*
|
| 377 |
+
* @param string $referenceId
|
| 378 |
+
* @param Varien_Object $result
|
| 379 |
+
*/
|
| 380 |
+
public function getRecurringProfileDetails($referenceId, Varien_Object $result)
|
| 381 |
+
{
|
| 382 |
+
return $this->_pro->getRecurringProfileDetails($referenceId, $result);
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
/**
|
| 386 |
+
* Whether can get recurring profile details
|
| 387 |
+
*/
|
| 388 |
+
public function canGetRecurringProfileDetails()
|
| 389 |
+
{
|
| 390 |
+
return true;
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
/**
|
| 394 |
+
* Update RP data
|
| 395 |
+
*
|
| 396 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 397 |
+
*/
|
| 398 |
+
public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
| 399 |
+
{
|
| 400 |
+
return $this->_pro->updateRecurringProfile($profile);
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
/**
|
| 404 |
+
* Manage status
|
| 405 |
+
*
|
| 406 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 407 |
+
*/
|
| 408 |
+
public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
|
| 409 |
+
{
|
| 410 |
+
return $this->_pro->updateRecurringProfileStatus($profile);
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
/**
|
| 414 |
+
* Assign data to info model instance
|
| 415 |
+
*
|
| 416 |
+
* @param mixed $data
|
| 417 |
+
* @return Mage_Payment_Model_Info
|
| 418 |
+
*/
|
| 419 |
+
public function assignData($data)
|
| 420 |
+
{
|
| 421 |
+
$result = parent::assignData($data);
|
| 422 |
+
$key = Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT;
|
| 423 |
+
if (is_array($data)) {
|
| 424 |
+
$this->getInfoInstance()->setAdditionalInformation($key, isset($data[$key]) ? $data[$key] : null);
|
| 425 |
+
}
|
| 426 |
+
elseif ($data instanceof Varien_Object) {
|
| 427 |
+
$this->getInfoInstance()->setAdditionalInformation($key, $data->getData($key));
|
| 428 |
+
}
|
| 429 |
+
return $result;
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
/**
|
| 433 |
+
* Place an order with authorization or capture action
|
| 434 |
+
*
|
| 435 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 436 |
+
* @param float $amount
|
| 437 |
+
* @return Mage_Paypal_Model_Express
|
| 438 |
+
*/
|
| 439 |
+
protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
|
| 440 |
+
{
|
| 441 |
+
$order = $payment->getOrder();
|
| 442 |
+
|
| 443 |
+
// prepare api call
|
| 444 |
+
$token = $payment->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
|
| 445 |
+
$api = $this->_pro->getApi();
|
| 446 |
+
$api->setToken($token);
|
| 447 |
+
$api->setPayerId($payment->
|
| 448 |
+
getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID));
|
| 449 |
+
$api->setAmount($amount);
|
| 450 |
+
$api->setPaymentAction($this->_pro->getConfig()->paymentAction);
|
| 451 |
+
$api->setNotifyUrl(Mage::getUrl('paypal/ipn/'));
|
| 452 |
+
$api->setInvNum($order->getIncrementId());
|
| 453 |
+
$api->setCurrencyCode($order->getBaseCurrencyCode());
|
| 454 |
+
//$api->setPaypalCart(Mage::getModel('paypal/cart', array($order)));
|
| 455 |
+
$api->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled);
|
| 456 |
+
|
| 457 |
+
if ($order->getIsVirtual()) {
|
| 458 |
+
$api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
|
| 459 |
+
} else {
|
| 460 |
+
$api->setAddress($order->getShippingAddress());
|
| 461 |
+
$api->setBillingAddress($order->getBillingAddress());
|
| 462 |
+
}
|
| 463 |
+
// call api and get details from it
|
| 464 |
+
$api->callDoExpressCheckoutPayment();
|
| 465 |
+
$this->_importToPayment($api, $payment);//$api
|
| 466 |
+
|
| 467 |
+
return $this;
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
/**
|
| 471 |
+
* Import payment info to payment
|
| 472 |
+
*
|
| 473 |
+
* @param Mage_Paypal_Model_Api_Nvp
|
| 474 |
+
* @param Mage_Sales_Model_Order_Payment
|
| 475 |
+
*/
|
| 476 |
+
protected function _importToPayment($api, $payment)
|
| 477 |
+
{
|
| 478 |
+
$payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0)
|
| 479 |
+
->setAdditionalInformation('laybuy_express_checkout_redirect_required',
|
| 480 |
+
$api->getRedirectRequired()
|
| 481 |
+
);
|
| 482 |
+
$model_obj=$api->getModelObject();
|
| 483 |
+
if ($model_obj->getBillingAgreementId()) {
|
| 484 |
+
$payment->setBillingAgreementData(array(
|
| 485 |
+
'billing_agreement_id' => $model_obj->getBillingAgreementId(),
|
| 486 |
+
'method_code' => 'laybuy_billing_agreement'
|
| 487 |
+
));
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
$this->_pro->importPaymentInfo($model_obj, $payment);
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
+
/**
|
| 494 |
+
* Check void availability
|
| 495 |
+
*
|
| 496 |
+
* @param Varien_Object $payment
|
| 497 |
+
* @return bool
|
| 498 |
+
*/
|
| 499 |
+
public function canVoid(Varien_Object $payment)
|
| 500 |
+
{
|
| 501 |
+
if ($payment instanceof Mage_Sales_Model_Order_Invoice
|
| 502 |
+
|| $payment instanceof Mage_Sales_Model_Order_Creditmemo
|
| 503 |
+
) {
|
| 504 |
+
return false;
|
| 505 |
+
}
|
| 506 |
+
$info = $this->getInfoInstance();
|
| 507 |
+
if ($info->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
|
| 508 |
+
$orderTransaction = $info->lookupTransaction(
|
| 509 |
+
false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 510 |
+
);
|
| 511 |
+
if ($orderTransaction) {
|
| 512 |
+
$info->setParentTransactionId($orderTransaction->getTxnId());
|
| 513 |
+
}
|
| 514 |
+
}
|
| 515 |
+
|
| 516 |
+
return $this->_canVoid;
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
/**
|
| 520 |
+
* Check capture availability
|
| 521 |
+
*
|
| 522 |
+
* @return bool
|
| 523 |
+
*/
|
| 524 |
+
public function canCapture()
|
| 525 |
+
{
|
| 526 |
+
$payment = $this->getInfoInstance();
|
| 527 |
+
$this->_pro->getConfig()->setStoreId($payment->getOrder()->getStore()->getId());
|
| 528 |
+
|
| 529 |
+
if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
|
| 530 |
+
$orderTransaction = $payment->lookupTransaction(false,
|
| 531 |
+
Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
|
| 532 |
+
);
|
| 533 |
+
if ($orderTransaction->getIsClosed()) {
|
| 534 |
+
return false;
|
| 535 |
+
}
|
| 536 |
+
|
| 537 |
+
$orderValidPeriod = abs(intval($this->getConfigData('order_valid_period')));
|
| 538 |
+
|
| 539 |
+
$dateCompass = new DateTime($orderTransaction->getCreatedAt());
|
| 540 |
+
$dateCompass->modify('+' . $orderValidPeriod . ' days');
|
| 541 |
+
$currentDate = new DateTime();
|
| 542 |
+
|
| 543 |
+
if ($currentDate > $dateCompass || $orderValidPeriod == 0) {
|
| 544 |
+
return false;
|
| 545 |
+
}
|
| 546 |
+
}
|
| 547 |
+
return $this->_canCapture;
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
/**
|
| 551 |
+
* Call DoAuthorize
|
| 552 |
+
*
|
| 553 |
+
* @param int $amount
|
| 554 |
+
* @param Varien_Object $payment
|
| 555 |
+
* @param string $parentTransactionId
|
| 556 |
+
* @return Mage_Paypal_Model_Api_Abstract
|
| 557 |
+
*/
|
| 558 |
+
protected function _callDoAuthorize($amount, $payment, $parentTransactionId)
|
| 559 |
+
{
|
| 560 |
+
$api = $this->_pro->resetApi()->getApi()
|
| 561 |
+
->setAmount($amount)
|
| 562 |
+
->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode())
|
| 563 |
+
->setTransactionId($parentTransactionId)
|
| 564 |
+
->callDoAuthorization();
|
| 565 |
+
|
| 566 |
+
$payment->setAdditionalInformation($this->_authorizationCountKey,
|
| 567 |
+
$payment->getAdditionalInformation($this->_authorizationCountKey) + 1
|
| 568 |
+
);
|
| 569 |
+
|
| 570 |
+
return $api;
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
/**
|
| 574 |
+
* Check transaction for expiration in PST
|
| 575 |
+
*
|
| 576 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction
|
| 577 |
+
* @param int $period
|
| 578 |
+
* @return boolean
|
| 579 |
+
*/
|
| 580 |
+
protected function _isTransactionExpired(Mage_Sales_Model_Order_Payment_Transaction $transaction, $period)
|
| 581 |
+
{
|
| 582 |
+
$period = intval($period);
|
| 583 |
+
if (0 == $period) {
|
| 584 |
+
return true;
|
| 585 |
+
}
|
| 586 |
+
|
| 587 |
+
$transactionClosingDate = new DateTime($transaction->getCreatedAt(), new DateTimeZone('GMT'));
|
| 588 |
+
$transactionClosingDate->setTimezone(new DateTimeZone('US/Pacific'));
|
| 589 |
+
/**
|
| 590 |
+
* 11:49:00 PayPal transactions closing time
|
| 591 |
+
*/
|
| 592 |
+
$transactionClosingDate->setTime(11, 49, 00);
|
| 593 |
+
$transactionClosingDate->modify('+' . $period . ' days');
|
| 594 |
+
|
| 595 |
+
$currentTime = new DateTime(null, new DateTimeZone('US/Pacific'));
|
| 596 |
+
|
| 597 |
+
if ($currentTime > $transactionClosingDate) {
|
| 598 |
+
return true;
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
return false;
|
| 602 |
+
}
|
| 603 |
+
|
| 604 |
+
/***************************new code********************************/
|
| 605 |
+
/**
|
| 606 |
+
* Check whether payment method can be used
|
| 607 |
+
* @param Mage_Sales_Model_Quote
|
| 608 |
+
* @return bool
|
| 609 |
+
*/
|
| 610 |
+
public function isAvailable($quote = null)
|
| 611 |
+
{
|
| 612 |
+
if ($status = parent::isAvailable($quote)) {
|
| 613 |
+
|
| 614 |
+
$storeId = $quote ? $quote->getStoreId() : null;
|
| 615 |
+
|
| 616 |
+
/* Condition for minimum checkout amount for method availability */
|
| 617 |
+
$configTotal = Mage::getStoreConfig('laybuy/conditional_criteria/total',$storeId);
|
| 618 |
+
$total = $quote ? $quote->getData('grand_total') : 0;
|
| 619 |
+
if($total && $status && $configTotal){
|
| 620 |
+
if($configTotal<$total){
|
| 621 |
+
$status = true;
|
| 622 |
+
}else{
|
| 623 |
+
$status = false;
|
| 624 |
+
}
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
/* Condition for customer groups for method availability */
|
| 628 |
+
if($status){
|
| 629 |
+
if(Mage::getStoreConfig('laybuy/conditional_criteria/allowspecificgroup',$storeId)) {
|
| 630 |
+
$configCustomerGroupId = explode(',',Mage::getStoreConfig('laybuy/conditional_criteria/customergroup',$storeId ));
|
| 631 |
+
$customerGroupId = $quote ? $quote->getData('customer_group_id'):-5;
|
| 632 |
+
if($customerGroupId != -5){
|
| 633 |
+
if($configCustomerGroupId && in_array($customerGroupId,$configCustomerGroupId)){
|
| 634 |
+
$status = true;
|
| 635 |
+
}else{
|
| 636 |
+
$status = false;
|
| 637 |
+
}
|
| 638 |
+
}
|
| 639 |
+
}
|
| 640 |
+
}
|
| 641 |
+
|
| 642 |
+
return $status;
|
| 643 |
+
}
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
/**
|
| 647 |
+
* Validate payment method information object
|
| 648 |
+
*
|
| 649 |
+
* @return Mage_Payment_Model_Abstract
|
| 650 |
+
*/
|
| 651 |
+
public function validate()
|
| 652 |
+
{
|
| 653 |
+
/**
|
| 654 |
+
* to validate payment method is allowed for billing country or not
|
| 655 |
+
*/
|
| 656 |
+
parent::validate();
|
| 657 |
+
|
| 658 |
+
$paymentInfo = $this->getInfoInstance();
|
| 659 |
+
if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
|
| 660 |
+
$cartItems = $paymentInfo->getOrder()->getAllItems();
|
| 661 |
+
$storeId = $paymentInfo->getOrder()->getStoreId();
|
| 662 |
+
} else {
|
| 663 |
+
$cartItems = $paymentInfo->getQuote()->getAllItems();
|
| 664 |
+
$storeId = $paymentInfo->getQuote()->getStoreId();
|
| 665 |
+
}
|
| 666 |
+
$flagArr = $this->canUseForCategories($cartItems, $storeId);
|
| 667 |
+
if (!$flagArr[0]) {
|
| 668 |
+
Mage::throwException(Mage::helper('laybuy')->__('Selected payment type is not allowed for '.$flagArr[1].' products.'));
|
| 669 |
+
}
|
| 670 |
+
return $this;
|
| 671 |
+
}
|
| 672 |
+
public function returnRestrictedProductNames($product_id="",$storeId=0){
|
| 673 |
+
$status = true;
|
| 674 |
+
$productName = '';
|
| 675 |
+
$configCategories = explode(',',Mage::getStoreConfig('laybuy/conditional_criteria/categories',$storeId ));
|
| 676 |
+
$xproducts = explode(',',Mage::getStoreConfig('laybuy/conditional_criteria/xproducts',$storeId));
|
| 677 |
+
$cartItems=Mage::getModel('checkout/cart')->getQuote()->getAllItems();
|
| 678 |
+
foreach($cartItems as $_product){
|
| 679 |
+
$_product = Mage::getModel('catalog/product')->load($_product->getProductId());
|
| 680 |
+
if($xproducts && in_array($_product->getId(),$xproducts)){
|
| 681 |
+
$status = false;
|
| 682 |
+
$productName .= $_product->getName().',';
|
| 683 |
+
} elseif(!Mage::getStoreConfig('laybuy/conditional_criteria/allowspecificcategory',$storeId)) {
|
| 684 |
+
$status = true;
|
| 685 |
+
} elseif ($configCategories && count(array_diff($_product->getCategoryIds(),$configCategories))>0){
|
| 686 |
+
$status = false;
|
| 687 |
+
$productName .= $_product->getName().',';
|
| 688 |
+
}
|
| 689 |
+
}
|
| 690 |
+
$productName = rtrim($productName,',');
|
| 691 |
+
|
| 692 |
+
return $productName;
|
| 693 |
+
}
|
| 694 |
+
public function checkForCategoriesAndProducts($product_id="",$storeId=0){
|
| 695 |
+
$status = true;
|
| 696 |
+
$productName = '';
|
| 697 |
+
$cartItems="";
|
| 698 |
+
$configCategories = explode(',',Mage::getStoreConfig('laybuy/conditional_criteria/categories',$storeId ));
|
| 699 |
+
$xproducts = explode(',',Mage::getStoreConfig('laybuy/conditional_criteria/xproducts',$storeId));
|
| 700 |
+
$controller_name=Mage::app()->getRequest()->getControllerName();
|
| 701 |
+
$action_name=Mage::app()->getRequest()->getActionName();
|
| 702 |
+
$module_name=Mage::app()->getRequest()->getModuleName();
|
| 703 |
+
if($controller_name=="product" && $module_name="catalog" && $action_name=="view" && $product_id !=""){
|
| 704 |
+
$_product = Mage::getModel('catalog/product')->load($product_id);
|
| 705 |
+
if($xproducts && in_array($_product->getId(),$xproducts)){
|
| 706 |
+
$status = false;
|
| 707 |
+
$productName .= $_product->getName().',';
|
| 708 |
+
} elseif(!Mage::getStoreConfig('laybuy/conditional_criteria/allowspecificcategory',$storeId)) {
|
| 709 |
+
$status = true;
|
| 710 |
+
} elseif ($configCategories && count(array_diff($_product->getCategoryIds(),$configCategories))>0){
|
| 711 |
+
$status = false;
|
| 712 |
+
$productName .= $_product->getName().',';
|
| 713 |
+
}
|
| 714 |
+
|
| 715 |
+
}else{
|
| 716 |
+
$cartItems=Mage::getModel('checkout/cart')->getQuote()->getAllItems();
|
| 717 |
+
foreach($cartItems as $_product){
|
| 718 |
+
$_product = Mage::getModel('catalog/product')->load($_product->getProductId());
|
| 719 |
+
if($xproducts && in_array($_product->getId(),$xproducts)){
|
| 720 |
+
$status = false;
|
| 721 |
+
$productName .= $_product->getName().',';
|
| 722 |
+
} elseif(!Mage::getStoreConfig('laybuy/conditional_criteria/allowspecificcategory',$storeId)) {
|
| 723 |
+
$status = true;
|
| 724 |
+
} elseif ($configCategories && count(array_diff($_product->getCategoryIds(),$configCategories))>0){
|
| 725 |
+
$status = false;
|
| 726 |
+
$productName .= $_product->getName().',';
|
| 727 |
+
}
|
| 728 |
+
if($status==false){
|
| 729 |
+
break;
|
| 730 |
+
}
|
| 731 |
+
}
|
| 732 |
+
|
| 733 |
+
}
|
| 734 |
+
return $status;
|
| 735 |
+
|
| 736 |
+
}
|
| 737 |
+
|
| 738 |
+
/**
|
| 739 |
+
* To check billing country is allowed for the payment method
|
| 740 |
+
*
|
| 741 |
+
* @return bool
|
| 742 |
+
*/
|
| 743 |
+
public function canUseForCategories($cartItems = array(), $storeId=0)
|
| 744 |
+
{
|
| 745 |
+
/*
|
| 746 |
+
for specific categories, the flag will set up as 1
|
| 747 |
+
*/
|
| 748 |
+
$status = true;
|
| 749 |
+
$productName = '';
|
| 750 |
+
$configCategories = explode(',',Mage::getStoreConfig('laybuy/conditional_criteria/categories',$storeId ));
|
| 751 |
+
$xproducts = explode(',',Mage::getStoreConfig('laybuy/conditional_criteria/xproducts',$storeId));
|
| 752 |
+
|
| 753 |
+
foreach($cartItems as $_product){
|
| 754 |
+
$_product = Mage::getModel('catalog/product')->load($_product->getProductId());
|
| 755 |
+
if($xproducts && in_array($_product->getId(),$xproducts)){
|
| 756 |
+
$status = false;
|
| 757 |
+
$productName .= $_product->getName().',';
|
| 758 |
+
} elseif(!Mage::getStoreConfig('laybuy/conditional_criteria/allowspecificcategory',$storeId)) {
|
| 759 |
+
$status = true;
|
| 760 |
+
} elseif ($configCategories && count(array_diff($_product->getCategoryIds(),$configCategories))>0){
|
| 761 |
+
$status = false;
|
| 762 |
+
$productName .= $_product->getName().',';
|
| 763 |
+
}
|
| 764 |
+
}
|
| 765 |
+
$productName = rtrim($productName,',');
|
| 766 |
+
|
| 767 |
+
return array($status,$productName);
|
| 768 |
+
}
|
| 769 |
+
|
| 770 |
+
/***************************ends************************************/
|
| 771 |
+
}
|
app/code/local/Ced/LayBuy/Model/Laybuyresp.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ced_LayBuy_Model_Laybuyresp extends Mage_Core_Model_Abstract
|
| 3 |
+
{
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* Initialize resource model
|
| 7 |
+
*/
|
| 8 |
+
protected function _construct()
|
| 9 |
+
{
|
| 10 |
+
$this->_init('laybuy/laybuyresp');
|
| 11 |
+
}
|
| 12 |
+
}
|
app/code/local/Ced/LayBuy/Model/Mysql4/Laybuyresp.php
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ced_LayBuy_Model_Mysql4_Laybuyresp extends Mage_Core_Model_Mysql4_Abstract{
|
| 3 |
+
|
| 4 |
+
protected function _construct()
|
| 5 |
+
|
| 6 |
+
{
|
| 7 |
+
|
| 8 |
+
$this->_init('laybuy/laybuyresp', 'resp_id');
|
| 9 |
+
|
| 10 |
+
}
|
| 11 |
+
}
|
app/code/local/Ced/LayBuy/Model/Mysql4/Laybuyresp/Collection.php
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Lay-Buys
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Ced
|
| 22 |
+
* @package Ced_LayBuy
|
| 23 |
+
* @author Asheesh Singh<asheeshsingh@cedcoss.com>
|
| 24 |
+
* @copyright Copyright LAY-BUYS (2011). (http://lay-buys.com/)
|
| 25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* LayBuy Report Collection model
|
| 30 |
+
*/
|
| 31 |
+
|
| 32 |
+
class Ced_LayBuy_Model_Mysql4_Laybuyresp_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
| 33 |
+
protected function _construct()
|
| 34 |
+
{
|
| 35 |
+
$this->_init('laybuy/laybuyresp');
|
| 36 |
+
}
|
| 37 |
+
}
|
app/code/local/Ced/LayBuy/Model/Mysql4/Region/Collection.php
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Directory
|
| 23 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Country collection
|
| 29 |
+
*
|
| 30 |
+
* @category Mage
|
| 31 |
+
* @package Mage_Directory
|
| 32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 33 |
+
*/
|
| 34 |
+
class Ced_Laybuy_Model_Mysql4_Region_Collection extends Mage_Directory_Model_Mysql4_Region_Collection
|
| 35 |
+
{
|
| 36 |
+
/**
|
| 37 |
+
* Filter region by its code or name
|
| 38 |
+
*
|
| 39 |
+
* @param string|array $region
|
| 40 |
+
* @return Mage_Directory_Model_Resource_Region_Collection
|
| 41 |
+
*/
|
| 42 |
+
public function addRegionCodeOrNameFilter($region)
|
| 43 |
+
{
|
| 44 |
+
if (!empty($region)) {
|
| 45 |
+
$condition = is_array($region) ? array('in' => $region) : $region;
|
| 46 |
+
$this->addFieldToFilter(array('region.code', 'region.default_name'), array($condition, $condition));
|
| 47 |
+
}
|
| 48 |
+
return $this;
|
| 49 |
+
}
|
| 50 |
+
}
|
app/code/local/Ced/LayBuy/Model/Pro.php
ADDED
|
@@ -0,0 +1,484 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Paypal
|
| 23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* PayPal Website Payments Pro implementation for payment method instaces
|
| 29 |
+
* This model was created because right now PayPal Direct and PayPal Express payment methods cannot have same abstract
|
| 30 |
+
*/
|
| 31 |
+
class Ced_LayBuy_Model_Pro
|
| 32 |
+
{
|
| 33 |
+
/**
|
| 34 |
+
* Possible payment review actions (for FMF only)
|
| 35 |
+
*
|
| 36 |
+
* @var string
|
| 37 |
+
*/
|
| 38 |
+
const PAYMENT_REVIEW_ACCEPT = 'accept';
|
| 39 |
+
const PAYMENT_REVIEW_DENY = 'deny';
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Config instance
|
| 43 |
+
*
|
| 44 |
+
* @var Mage_Paypal_Model_Config
|
| 45 |
+
*/
|
| 46 |
+
protected $_config = null;
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* API instance
|
| 50 |
+
*
|
| 51 |
+
* @var Mage_Paypal_Model_Api_Nvp
|
| 52 |
+
*/
|
| 53 |
+
protected $_api = null;
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* PayPal info object
|
| 57 |
+
*
|
| 58 |
+
* @var Mage_Paypal_Model_Info
|
| 59 |
+
*/
|
| 60 |
+
protected $_infoInstance = null;
|
| 61 |
+
|
| 62 |
+
/**
|
| 63 |
+
* API model type
|
| 64 |
+
*
|
| 65 |
+
* @var string
|
| 66 |
+
*/
|
| 67 |
+
protected $_apiType = 'laybuy/api_nvp';
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* Config model type
|
| 71 |
+
*
|
| 72 |
+
* @var string
|
| 73 |
+
*/
|
| 74 |
+
protected $_configType = 'laybuy/config';
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* Payment method code setter. Also instantiates/updates config
|
| 78 |
+
*
|
| 79 |
+
* @param string $code
|
| 80 |
+
* @param int|null $storeId
|
| 81 |
+
*/
|
| 82 |
+
public function setMethod($code, $storeId = null)
|
| 83 |
+
{
|
| 84 |
+
if (null === $this->_config) {
|
| 85 |
+
$params = array($code);
|
| 86 |
+
if (null !== $storeId) {
|
| 87 |
+
$params[] = $storeId;
|
| 88 |
+
}
|
| 89 |
+
$this->_config = Mage::getModel($this->_configType, $params);
|
| 90 |
+
|
| 91 |
+
} else {
|
| 92 |
+
$this->_config->setMethod($code);
|
| 93 |
+
if (null !== $storeId) {
|
| 94 |
+
$this->_config->setStoreId($storeId);
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
return $this;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/**
|
| 101 |
+
* Config instance setter
|
| 102 |
+
*
|
| 103 |
+
* @param Mage_Paypal_Model_Config $instace
|
| 104 |
+
* @param int $storeId
|
| 105 |
+
*/
|
| 106 |
+
public function setConfig(Mage_Paypal_Model_Config $instace, $storeId = null)
|
| 107 |
+
{
|
| 108 |
+
$this->_config = $instace;
|
| 109 |
+
if (null !== $storeId) {
|
| 110 |
+
$this->_config->setStoreId($storeId);
|
| 111 |
+
}
|
| 112 |
+
return $this;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* Config instance getter
|
| 117 |
+
*
|
| 118 |
+
* @return Mage_Paypal_Model_Config
|
| 119 |
+
*/
|
| 120 |
+
public function getConfig()
|
| 121 |
+
{
|
| 122 |
+
return $this->_config;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
/**
|
| 126 |
+
* API instance getter
|
| 127 |
+
* Sets current store id to current config instance and passes it to API
|
| 128 |
+
*
|
| 129 |
+
* @return Mage_Paypal_Model_Api_Nvp
|
| 130 |
+
*/
|
| 131 |
+
public function getApi()
|
| 132 |
+
{
|
| 133 |
+
if (null === $this->_api) {
|
| 134 |
+
//$this->_api = Mage::getModel($this->_apiType);
|
| 135 |
+
$this->_api=new Ced_LayBuy_ExpressController();
|
| 136 |
+
}
|
| 137 |
+
$this->_api->setConfigObject($this->_config);
|
| 138 |
+
return $this->_api;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
/**
|
| 142 |
+
* Destroy existing NVP Api object
|
| 143 |
+
*
|
| 144 |
+
* @return Mage_Paypal_Model_Pro
|
| 145 |
+
*/
|
| 146 |
+
public function resetApi()
|
| 147 |
+
{
|
| 148 |
+
$this->_api = null;
|
| 149 |
+
|
| 150 |
+
return $this;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
/**
|
| 154 |
+
* Instantiate and return info model
|
| 155 |
+
*
|
| 156 |
+
* @return Mage_Paypal_Model_Info
|
| 157 |
+
*/
|
| 158 |
+
public function getInfo()
|
| 159 |
+
{
|
| 160 |
+
if (null === $this->_infoInstance) {
|
| 161 |
+
$this->_infoInstance = new Ced_LayBuy_ExpressController();//Mage::getModel('paypal/info');
|
| 162 |
+
}
|
| 163 |
+
return $this->_infoInstance;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
/**
|
| 167 |
+
* Transfer transaction/payment information from API instance to order payment
|
| 168 |
+
*
|
| 169 |
+
* @param Mage_Paypal_Model_Api_Abstract $from
|
| 170 |
+
* @param Mage_Payment_Model_Info $to
|
| 171 |
+
* @return Mage_Paypal_Model_Pro
|
| 172 |
+
*/
|
| 173 |
+
public function importPaymentInfo(Varien_Object $from, Mage_Payment_Model_Info $to)
|
| 174 |
+
{
|
| 175 |
+
// update PayPal-specific payment information in the payment object
|
| 176 |
+
$this->getInfo()->importToPayment($from, $to);
|
| 177 |
+
|
| 178 |
+
/**
|
| 179 |
+
* Detect payment review and/or frauds
|
| 180 |
+
* PayPal pro API returns fraud results only in the payment call response
|
| 181 |
+
*/
|
| 182 |
+
try{
|
| 183 |
+
//
|
| 184 |
+
//echo get_class($this->getInfo());die("kkkiran..");
|
| 185 |
+
if ($from->getDataUsingMethod(Ced_LayBuy_ExpressController::IS_FRAUD)) {//Mage_Paypal_Model_Info
|
| 186 |
+
$to->setIsTransactionPending(true);
|
| 187 |
+
$to->setIsFraudDetected(true);
|
| 188 |
+
} elseif ($this->getInfo()->isPaymentReviewRequired($to)) {//->getModelObject()
|
| 189 |
+
$to->setIsTransactionPending(true);
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
// give generic info about transaction state
|
| 193 |
+
if ($this->getInfo()->isPaymentSuccessful($to)) {
|
| 194 |
+
$to->setIsTransactionApproved(true);
|
| 195 |
+
} elseif ($this->getInfo()->isPaymentFailed($to)) {
|
| 196 |
+
$to->setIsTransactionDenied(true);
|
| 197 |
+
}
|
| 198 |
+
}catch(Exception $e){
|
| 199 |
+
echo $e->getMessage();die("hasan..");
|
| 200 |
+
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
return $this;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
/**
|
| 207 |
+
* Void transaction
|
| 208 |
+
*
|
| 209 |
+
* @param Varien_Object $payment
|
| 210 |
+
*/
|
| 211 |
+
public function void(Varien_Object $payment)
|
| 212 |
+
{
|
| 213 |
+
if ($authTransactionId = $this->_getParentTransactionId($payment)) {
|
| 214 |
+
$api = $this->getApi();
|
| 215 |
+
$api->setPayment($payment)->setAuthorizationId($authTransactionId)->callDoVoid();
|
| 216 |
+
$this->importPaymentInfo($api, $payment);
|
| 217 |
+
} else {
|
| 218 |
+
Mage::throwException(Mage::helper('laybuy')->__('Authorization transaction is required to void.'));
|
| 219 |
+
}
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
/**
|
| 223 |
+
* Attempt to capture payment
|
| 224 |
+
* Will return false if the payment is not supposed to be captured
|
| 225 |
+
*
|
| 226 |
+
* @param Varien_Object $payment
|
| 227 |
+
* @param float $amount
|
| 228 |
+
* @return false|null
|
| 229 |
+
*/
|
| 230 |
+
public function capture(Varien_Object $payment, $amount)
|
| 231 |
+
{
|
| 232 |
+
$authTransactionId = $this->_getParentTransactionId($payment);
|
| 233 |
+
if (!$authTransactionId) {
|
| 234 |
+
return false;
|
| 235 |
+
}
|
| 236 |
+
$api = $this->getApi()
|
| 237 |
+
->setAuthorizationId($authTransactionId)
|
| 238 |
+
->setIsCaptureComplete($payment->getShouldCloseParentTransaction())
|
| 239 |
+
->setAmount($amount)
|
| 240 |
+
->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode())
|
| 241 |
+
->setInvNum($payment->getOrder()->getIncrementId())
|
| 242 |
+
// TODO: pass 'NOTE' to API
|
| 243 |
+
;
|
| 244 |
+
|
| 245 |
+
$api->callDoCapture();
|
| 246 |
+
$this->_importCaptureResultToPayment($api, $payment);
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
/**
|
| 250 |
+
* Refund a capture transaction
|
| 251 |
+
*
|
| 252 |
+
* @param Varien_Object $payment
|
| 253 |
+
* @param float $amount
|
| 254 |
+
*/
|
| 255 |
+
public function refund(Varien_Object $payment, $amount)
|
| 256 |
+
{
|
| 257 |
+
$captureTxnId = $this->_getParentTransactionId($payment);
|
| 258 |
+
if ($captureTxnId) {
|
| 259 |
+
$api = $this->getApi();
|
| 260 |
+
$order = $payment->getOrder();
|
| 261 |
+
$api->setPayment($payment)
|
| 262 |
+
->setTransactionId($captureTxnId)
|
| 263 |
+
->setAmount($amount)
|
| 264 |
+
->setCurrencyCode($order->getBaseCurrencyCode())
|
| 265 |
+
;
|
| 266 |
+
$canRefundMore = $payment->getCreditmemo()->getInvoice()->canRefund();
|
| 267 |
+
$isFullRefund = !$canRefundMore
|
| 268 |
+
&& (0 == ((float)$order->getBaseTotalOnlineRefunded() + (float)$order->getBaseTotalOfflineRefunded()));
|
| 269 |
+
$api->setRefundType($isFullRefund ? Mage_Paypal_Model_Config::REFUND_TYPE_FULL
|
| 270 |
+
: Mage_Paypal_Model_Config::REFUND_TYPE_PARTIAL
|
| 271 |
+
);
|
| 272 |
+
$api->callRefundTransaction();
|
| 273 |
+
$this->_importRefundResultToPayment($api, $payment, $canRefundMore);
|
| 274 |
+
} else {
|
| 275 |
+
Mage::throwException(Mage::helper('laybuy')->__('Impossible to issue a refund transaction because the capture transaction does not exist.'));
|
| 276 |
+
}
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
/**
|
| 280 |
+
* Cancel payment
|
| 281 |
+
*
|
| 282 |
+
* @param Varien_Object $payment
|
| 283 |
+
*/
|
| 284 |
+
public function cancel(Varien_Object $payment)
|
| 285 |
+
{
|
| 286 |
+
if (!$payment->getOrder()->getInvoiceCollection()->count()) {
|
| 287 |
+
$this->void($payment);
|
| 288 |
+
}
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
/**
|
| 292 |
+
*
|
| 293 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
| 294 |
+
* @return bool
|
| 295 |
+
*/
|
| 296 |
+
public function canReviewPayment(Mage_Payment_Model_Info $payment)
|
| 297 |
+
{
|
| 298 |
+
return Mage_Paypal_Model_Info::isPaymentReviewRequired($payment);
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
/**
|
| 302 |
+
* Perform the payment review
|
| 303 |
+
*
|
| 304 |
+
* @param Mage_Payment_Model_Info $payment
|
| 305 |
+
* @param string $action
|
| 306 |
+
* @return bool
|
| 307 |
+
*/
|
| 308 |
+
public function reviewPayment(Mage_Payment_Model_Info $payment, $action)
|
| 309 |
+
{
|
| 310 |
+
$api = $this->getApi()->setTransactionId($payment->getLastTransId());
|
| 311 |
+
|
| 312 |
+
// check whether the review is still needed
|
| 313 |
+
$api->callGetTransactionDetails();
|
| 314 |
+
$this->importPaymentInfo($api, $payment);
|
| 315 |
+
if (!$this->getInfo()->isPaymentReviewRequired($payment)) {
|
| 316 |
+
return false;
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
// perform the review action
|
| 320 |
+
$api->setAction($action)->callManagePendingTransactionStatus();
|
| 321 |
+
$api->callGetTransactionDetails();
|
| 322 |
+
$this->importPaymentInfo($api, $payment);
|
| 323 |
+
return true;
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
/**
|
| 327 |
+
* Fetch transaction details info
|
| 328 |
+
*
|
| 329 |
+
* @param Mage_Payment_Model_Info $payment
|
| 330 |
+
* @param string $transactionId
|
| 331 |
+
* @return array
|
| 332 |
+
*/
|
| 333 |
+
public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
|
| 334 |
+
{
|
| 335 |
+
$api = $this->getApi()
|
| 336 |
+
->setTransactionId($transactionId)
|
| 337 |
+
->setRawResponseNeeded(true);
|
| 338 |
+
$api->callGetTransactionDetails();
|
| 339 |
+
$this->importPaymentInfo($api, $payment);
|
| 340 |
+
$data = $api->getRawSuccessResponseData();
|
| 341 |
+
return ($data) ? $data : array();
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
/**
|
| 345 |
+
* Validate RP data
|
| 346 |
+
*
|
| 347 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 348 |
+
* @throws Mage_Core_Exception
|
| 349 |
+
*/
|
| 350 |
+
public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
| 351 |
+
{
|
| 352 |
+
$errors = array();
|
| 353 |
+
if (strlen($profile->getSubscriberName()) > 32) { // up to 32 single-byte chars
|
| 354 |
+
$errors[] = Mage::helper('laybuy')->__('Subscriber name is too long.');
|
| 355 |
+
}
|
| 356 |
+
$refId = $profile->getInternalReferenceId(); // up to 127 single-byte alphanumeric
|
| 357 |
+
if (strlen($refId) > 127) { // || !preg_match('/^[a-z\d\s]+$/i', $refId)
|
| 358 |
+
$errors[] = Mage::helper('laybuy')->__('Merchant reference ID format is not supported.');
|
| 359 |
+
}
|
| 360 |
+
$scheduleDescr = $profile->getScheduleDescription(); // up to 127 single-byte alphanumeric
|
| 361 |
+
if (strlen($refId) > 127) { // || !preg_match('/^[a-z\d\s]+$/i', $scheduleDescr)
|
| 362 |
+
$errors[] = Mage::helper('laybuy')->__('Schedule description is too long.');
|
| 363 |
+
}
|
| 364 |
+
if ($errors) {
|
| 365 |
+
Mage::throwException(implode(' ', $errors));
|
| 366 |
+
}
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
/**
|
| 370 |
+
* Submit RP to the gateway
|
| 371 |
+
*
|
| 372 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 373 |
+
* @param Mage_Payment_Model_Info $paymentInfo
|
| 374 |
+
* @throws Mage_Core_Exception
|
| 375 |
+
*/
|
| 376 |
+
public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile,
|
| 377 |
+
Mage_Payment_Model_Info $paymentInfo
|
| 378 |
+
) {
|
| 379 |
+
$api = $this->getApi();
|
| 380 |
+
Varien_Object_Mapper::accumulateByMap($profile, $api, array(
|
| 381 |
+
'token', // EC fields
|
| 382 |
+
// TODO: DP fields
|
| 383 |
+
// profile fields
|
| 384 |
+
'subscriber_name', 'start_datetime', 'internal_reference_id', 'schedule_description',
|
| 385 |
+
'suspension_threshold', 'bill_failed_later', 'period_unit', 'period_frequency', 'period_max_cycles',
|
| 386 |
+
'billing_amount' => 'amount', 'trial_period_unit', 'trial_period_frequency', 'trial_period_max_cycles',
|
| 387 |
+
'trial_billing_amount', 'currency_code', 'shipping_amount', 'tax_amount', 'init_amount', 'init_may_fail',
|
| 388 |
+
));
|
| 389 |
+
$api->callCreateRecurringPaymentsProfile();
|
| 390 |
+
$profile->setReferenceId($api->getRecurringProfileId());
|
| 391 |
+
if ($api->getIsProfileActive()) {
|
| 392 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
|
| 393 |
+
} elseif ($api->getIsProfilePending()) {
|
| 394 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_PENDING);
|
| 395 |
+
}
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
/**
|
| 399 |
+
* Fetch RP details
|
| 400 |
+
*
|
| 401 |
+
* @param string $referenceId
|
| 402 |
+
* @param Varien_Object $result
|
| 403 |
+
*/
|
| 404 |
+
public function getRecurringProfileDetails($referenceId, Varien_Object $result)
|
| 405 |
+
{
|
| 406 |
+
$api = $this->getApi();
|
| 407 |
+
$api->setRecurringProfileId($referenceId)
|
| 408 |
+
->callGetRecurringPaymentsProfileDetails($result)
|
| 409 |
+
;
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
/**
|
| 413 |
+
* Update RP data
|
| 414 |
+
*
|
| 415 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 416 |
+
*/
|
| 417 |
+
public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
|
| 418 |
+
{
|
| 419 |
+
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
/**
|
| 423 |
+
* Manage status
|
| 424 |
+
*
|
| 425 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
| 426 |
+
*/
|
| 427 |
+
public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
|
| 428 |
+
{
|
| 429 |
+
$api = $this->getApi();
|
| 430 |
+
$action = null;
|
| 431 |
+
switch ($profile->getNewState()) {
|
| 432 |
+
case Mage_Sales_Model_Recurring_Profile::STATE_CANCELED: $action = 'cancel'; break;
|
| 433 |
+
case Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED: $action = 'suspend'; break;
|
| 434 |
+
case Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE: $action = 'activate'; break;
|
| 435 |
+
}
|
| 436 |
+
$state = $profile->getState();
|
| 437 |
+
$api->setRecurringProfileId($profile->getReferenceId())
|
| 438 |
+
->setIsAlreadyCanceled($state == Mage_Sales_Model_Recurring_Profile::STATE_CANCELED)
|
| 439 |
+
->setIsAlreadySuspended($state == Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED)
|
| 440 |
+
->setIsAlreadyActive($state == Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE)
|
| 441 |
+
->setAction($action)
|
| 442 |
+
->callManageRecurringPaymentsProfileStatus()
|
| 443 |
+
;
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
/**
|
| 447 |
+
* Import capture results to payment
|
| 448 |
+
*
|
| 449 |
+
* @param Mage_Paypal_Model_Api_Nvp
|
| 450 |
+
* @param Mage_Sales_Model_Order_Payment
|
| 451 |
+
*/
|
| 452 |
+
protected function _importCaptureResultToPayment($api, $payment)
|
| 453 |
+
{
|
| 454 |
+
$payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(false);
|
| 455 |
+
$this->importPaymentInfo($api, $payment);
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
/**
|
| 459 |
+
* Import refund results to payment
|
| 460 |
+
*
|
| 461 |
+
* @param Mage_Paypal_Model_Api_Nvp
|
| 462 |
+
* @param Mage_Sales_Model_Order_Payment
|
| 463 |
+
* @param bool $canRefundMore
|
| 464 |
+
*/
|
| 465 |
+
protected function _importRefundResultToPayment($api, $payment, $canRefundMore)
|
| 466 |
+
{
|
| 467 |
+
$payment->setTransactionId($api->getRefundTransactionId())
|
| 468 |
+
->setIsTransactionClosed(1) // refund initiated by merchant
|
| 469 |
+
->setShouldCloseParentTransaction(!$canRefundMore)
|
| 470 |
+
;
|
| 471 |
+
$this->importPaymentInfo($api, $payment);
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
/**
|
| 475 |
+
* Parent transaction id getter
|
| 476 |
+
*
|
| 477 |
+
* @param Varien_Object $payment
|
| 478 |
+
* @return string
|
| 479 |
+
*/
|
| 480 |
+
protected function _getParentTransactionId(Varien_Object $payment)
|
| 481 |
+
{
|
| 482 |
+
return $payment->getParentTransactionId() ? $payment->getParentTransactionId() : $payment->getLastTransId();
|
| 483 |
+
}
|
| 484 |
+
}
|
app/code/local/Ced/LayBuy/controllers/ExpressController.php
ADDED
|
@@ -0,0 +1,1841 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Ced_LayBuy_ExpressController extends Mage_Core_Controller_Front_Action
|
| 3 |
+
{
|
| 4 |
+
const PAYER_ID = 'payer_id';
|
| 5 |
+
const PAYER_EMAIL = 'email';
|
| 6 |
+
const PAYER_STATUS = 'payer_status';
|
| 7 |
+
const ADDRESS_ID = 'address_id';
|
| 8 |
+
const ADDRESS_STATUS = 'address_status';
|
| 9 |
+
const PROTECTION_EL = 'protection_eligibility';
|
| 10 |
+
const FRAUD_FILTERS = 'collected_fraud_filters';
|
| 11 |
+
const CORRELATION_ID = 'correlation_id';
|
| 12 |
+
const AVS_CODE = 'avs_result';
|
| 13 |
+
const CVV2_MATCH = 'cvv2_check_result';
|
| 14 |
+
const CENTINEL_VPAS = 'centinel_vpas_result';
|
| 15 |
+
const CENTINEL_ECI = 'centinel_eci_result';
|
| 16 |
+
|
| 17 |
+
// Next two fields are required for Brazil
|
| 18 |
+
const BUYER_TAX_ID = 'buyer_tax_id';
|
| 19 |
+
const BUYER_TAX_ID_TYPE = 'buyer_tax_id_type';
|
| 20 |
+
|
| 21 |
+
const PAYMENT_STATUS = 'payment_status';
|
| 22 |
+
const PENDING_REASON = 'pending_reason';
|
| 23 |
+
const IS_FRAUD = 'is_fraud_detected';
|
| 24 |
+
const PAYMENT_STATUS_GLOBAL = 'paypal_payment_status';
|
| 25 |
+
const PENDING_REASON_GLOBAL = 'paypal_pending_reason';
|
| 26 |
+
const IS_FRAUD_GLOBAL = 'paypal_is_fraud_detected';
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Possible buyer's tax id types (Brazil only)
|
| 30 |
+
*/
|
| 31 |
+
const BUYER_TAX_ID_TYPE_CPF = 'BR_CPF';
|
| 32 |
+
const BUYER_TAX_ID_TYPE_CNPJ = 'BR_CNPJ';
|
| 33 |
+
|
| 34 |
+
const PAYMENTSTATUS_NONE = 'none';
|
| 35 |
+
const PAYMENTSTATUS_COMPLETED = 'completed';
|
| 36 |
+
const PAYMENTSTATUS_DENIED = 'denied';
|
| 37 |
+
const PAYMENTSTATUS_EXPIRED = 'expired';
|
| 38 |
+
const PAYMENTSTATUS_FAILED = 'failed';
|
| 39 |
+
const PAYMENTSTATUS_INPROGRESS = 'in_progress';
|
| 40 |
+
const PAYMENTSTATUS_PENDING = 'pending';
|
| 41 |
+
const PAYMENTSTATUS_REFUNDED = 'refunded';
|
| 42 |
+
const PAYMENTSTATUS_REFUNDEDPART = 'partially_refunded';
|
| 43 |
+
const PAYMENTSTATUS_REVERSED = 'reversed';
|
| 44 |
+
const PAYMENTSTATUS_UNREVERSED = 'canceled_reversal';
|
| 45 |
+
const PAYMENTSTATUS_PROCESSED = 'processed';
|
| 46 |
+
const PAYMENTSTATUS_VOIDED = 'voided';
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* PayPal payment transaction type
|
| 50 |
+
*/
|
| 51 |
+
const TXN_TYPE_ADJUSTMENT = 'adjustment';
|
| 52 |
+
const TXN_TYPE_NEW_CASE = 'new_case';
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Order
|
| 57 |
+
*
|
| 58 |
+
* @var Mage_Sales_Model_QuoteMage_Sales_Model_Quote
|
| 59 |
+
*/
|
| 60 |
+
protected $_order = null;
|
| 61 |
+
protected $_amount=null;
|
| 62 |
+
/**
|
| 63 |
+
* State helper variables
|
| 64 |
+
* @var string
|
| 65 |
+
*/
|
| 66 |
+
protected $_redirectUrl = '';
|
| 67 |
+
/**
|
| 68 |
+
* Billing agreement that might be created during order placing
|
| 69 |
+
*
|
| 70 |
+
* @var Mage_Sales_Model_Billing_Agreement
|
| 71 |
+
*/
|
| 72 |
+
protected $_billingAgreement = null;
|
| 73 |
+
/**
|
| 74 |
+
* Recurring payment profiles
|
| 75 |
+
*
|
| 76 |
+
* @var array
|
| 77 |
+
*/
|
| 78 |
+
protected $_recurringPaymentProfiles = array();
|
| 79 |
+
protected $_init=null;
|
| 80 |
+
protected $_months=null;
|
| 81 |
+
/**
|
| 82 |
+
* Map for shipping address import/export (extends billing address mapper)
|
| 83 |
+
* @var array
|
| 84 |
+
*/
|
| 85 |
+
|
| 86 |
+
protected $_shippingAddressMap = array(
|
| 87 |
+
'SHIPTOCOUNTRYCODE' => 'country_id',
|
| 88 |
+
'SHIPTOSTATE' => 'region',
|
| 89 |
+
'SHIPTOCITY' => 'city',
|
| 90 |
+
'SHIPTOSTREET' => 'street',
|
| 91 |
+
'SHIPTOSTREET2' => 'street2',
|
| 92 |
+
'SHIPTOZIP' => 'postcode',
|
| 93 |
+
'SHIPTOPHONENUM' => 'telephone',
|
| 94 |
+
// 'SHIPTONAME' will be treated manually in address import/export methods
|
| 95 |
+
);
|
| 96 |
+
/**
|
| 97 |
+
* All payment information map
|
| 98 |
+
*
|
| 99 |
+
* @var array
|
| 100 |
+
*/
|
| 101 |
+
protected $_paymentMap = array(
|
| 102 |
+
self::PAYER_ID => 'paypal_payer_id',
|
| 103 |
+
self::PAYER_EMAIL => 'paypal_payer_email',
|
| 104 |
+
self::PAYER_STATUS => 'paypal_payer_status',
|
| 105 |
+
self::ADDRESS_ID => 'paypal_address_id',
|
| 106 |
+
self::ADDRESS_STATUS => 'paypal_address_status',
|
| 107 |
+
self::PROTECTION_EL => 'paypal_protection_eligibility',
|
| 108 |
+
self::FRAUD_FILTERS => 'paypal_fraud_filters',
|
| 109 |
+
self::CORRELATION_ID => 'paypal_correlation_id',
|
| 110 |
+
self::AVS_CODE => 'paypal_avs_code',
|
| 111 |
+
self::CVV2_MATCH => 'paypal_cvv2_match',
|
| 112 |
+
self::CENTINEL_VPAS => self::CENTINEL_VPAS,
|
| 113 |
+
self::CENTINEL_ECI => self::CENTINEL_ECI,
|
| 114 |
+
self::BUYER_TAX_ID => self::BUYER_TAX_ID,
|
| 115 |
+
self::BUYER_TAX_ID_TYPE => self::BUYER_TAX_ID_TYPE,
|
| 116 |
+
);
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
* System information map
|
| 120 |
+
*
|
| 121 |
+
* @var array
|
| 122 |
+
*/
|
| 123 |
+
protected $_systemMap = array(
|
| 124 |
+
self::PAYMENT_STATUS => self::PAYMENT_STATUS_GLOBAL,
|
| 125 |
+
self::PENDING_REASON => self::PENDING_REASON_GLOBAL,
|
| 126 |
+
self::IS_FRAUD => self::IS_FRAUD_GLOBAL,
|
| 127 |
+
);
|
| 128 |
+
|
| 129 |
+
protected $_importFromRequestFilters = array(
|
| 130 |
+
'REDIRECTREQUIRED' => '_filterToBool',
|
| 131 |
+
'SUCCESSPAGEREDIRECTREQUESTED' => '_filterToBool',
|
| 132 |
+
'PAYMENTSTATUS' => '_filterPaymentStatusFromNvpToInfo',
|
| 133 |
+
);
|
| 134 |
+
public $_laybuyresponse=null;
|
| 135 |
+
/**
|
| 136 |
+
* Global public interface map
|
| 137 |
+
* @var array
|
| 138 |
+
*/
|
| 139 |
+
protected $_globalMap = array(
|
| 140 |
+
// each call
|
| 141 |
+
'VERSION' => 'version',
|
| 142 |
+
'USER' => 'api_username',
|
| 143 |
+
'PWD' => 'api_password',
|
| 144 |
+
'SIGNATURE' => 'api_signature',
|
| 145 |
+
'BUTTONSOURCE' => 'build_notation_code',
|
| 146 |
+
|
| 147 |
+
// for Unilateral payments
|
| 148 |
+
'SUBJECT' => 'business_account',
|
| 149 |
+
|
| 150 |
+
// commands
|
| 151 |
+
'PAYMENTACTION' => 'payment_action',
|
| 152 |
+
'RETURNURL' => 'return_url',
|
| 153 |
+
'CANCELURL' => 'cancel_url',
|
| 154 |
+
'INVNUM' => 'inv_num',
|
| 155 |
+
'TOKEN' => 'token',
|
| 156 |
+
'CORRELATIONID' => 'correlation_id',
|
| 157 |
+
'SOLUTIONTYPE' => 'solution_type',
|
| 158 |
+
'GIROPAYCANCELURL' => 'giropay_cancel_url',
|
| 159 |
+
'GIROPAYSUCCESSURL' => 'giropay_success_url',
|
| 160 |
+
'BANKTXNPENDINGURL' => 'giropay_bank_txn_pending_url',
|
| 161 |
+
'IPADDRESS' => 'ip_address',
|
| 162 |
+
'NOTIFYURL' => 'notify_url',
|
| 163 |
+
'RETURNFMFDETAILS' => 'fraud_management_filters_enabled',
|
| 164 |
+
'NOTE' => 'note',
|
| 165 |
+
'REFUNDTYPE' => 'refund_type',
|
| 166 |
+
'ACTION' => 'action',
|
| 167 |
+
'REDIRECTREQUIRED' => 'redirect_required',
|
| 168 |
+
'SUCCESSPAGEREDIRECTREQUESTED' => 'redirect_requested',
|
| 169 |
+
'REQBILLINGADDRESS' => 'require_billing_address',
|
| 170 |
+
// style settings
|
| 171 |
+
'PAGESTYLE' => 'page_style',
|
| 172 |
+
'HDRIMG' => 'hdrimg',
|
| 173 |
+
'HDRBORDERCOLOR' => 'hdrbordercolor',
|
| 174 |
+
'HDRBACKCOLOR' => 'hdrbackcolor',
|
| 175 |
+
'PAYFLOWCOLOR' => 'payflowcolor',
|
| 176 |
+
'LOCALECODE' => 'locale_code',
|
| 177 |
+
'PAL' => 'pal',
|
| 178 |
+
|
| 179 |
+
// transaction info
|
| 180 |
+
'TRANSACTIONID' => 'transaction_id',
|
| 181 |
+
'AUTHORIZATIONID' => 'authorization_id',
|
| 182 |
+
'REFUNDTRANSACTIONID' => 'refund_transaction_id',
|
| 183 |
+
'COMPLETETYPE' => 'complete_type',
|
| 184 |
+
'AMT' => 'amount',
|
| 185 |
+
'ITEMAMT' => 'subtotal_amount',
|
| 186 |
+
'GROSSREFUNDAMT' => 'refunded_amount', // possible mistake, check with API reference
|
| 187 |
+
|
| 188 |
+
// payment/billing info
|
| 189 |
+
'CURRENCYCODE' => 'currency_code',
|
| 190 |
+
'PAYMENTSTATUS' => 'payment_status',
|
| 191 |
+
'PENDINGREASON' => 'pending_reason',
|
| 192 |
+
'PROTECTIONELIGIBILITY' => 'protection_eligibility',
|
| 193 |
+
'PAYERID' => 'payer_id',
|
| 194 |
+
'PAYERSTATUS' => 'payer_status',
|
| 195 |
+
'ADDRESSID' => 'address_id',
|
| 196 |
+
'ADDRESSSTATUS' => 'address_status',
|
| 197 |
+
'EMAIL' => 'email',
|
| 198 |
+
// backwards compatibility
|
| 199 |
+
'FIRSTNAME' => 'firstname',
|
| 200 |
+
'LASTNAME' => 'lastname',
|
| 201 |
+
|
| 202 |
+
// shipping rate
|
| 203 |
+
'SHIPPINGOPTIONNAME' => 'shipping_rate_code',
|
| 204 |
+
'NOSHIPPING' => 'suppress_shipping',
|
| 205 |
+
|
| 206 |
+
// paypal direct credit card information
|
| 207 |
+
'CREDITCARDTYPE' => 'credit_card_type',
|
| 208 |
+
'ACCT' => 'credit_card_number',
|
| 209 |
+
'EXPDATE' => 'credit_card_expiration_date',
|
| 210 |
+
'CVV2' => 'credit_card_cvv2',
|
| 211 |
+
'STARTDATE' => 'maestro_solo_issue_date', // MMYYYY, always six chars, including leading zero
|
| 212 |
+
'ISSUENUMBER' => 'maestro_solo_issue_number',
|
| 213 |
+
'CVV2MATCH' => 'cvv2_check_result',
|
| 214 |
+
'AVSCODE' => 'avs_result',
|
| 215 |
+
// cardinal centinel
|
| 216 |
+
'AUTHSTATUS3DS' => 'centinel_authstatus',
|
| 217 |
+
'MPIVENDOR3DS' => 'centinel_mpivendor',
|
| 218 |
+
'CAVV' => 'centinel_cavv',
|
| 219 |
+
'ECI3DS' => 'centinel_eci',
|
| 220 |
+
'XID' => 'centinel_xid',
|
| 221 |
+
'VPAS' => 'centinel_vpas_result',
|
| 222 |
+
'ECISUBMITTED3DS' => 'centinel_eci_result',
|
| 223 |
+
|
| 224 |
+
// recurring payment profiles
|
| 225 |
+
//'TOKEN' => 'token',
|
| 226 |
+
'SUBSCRIBERNAME' =>'subscriber_name',
|
| 227 |
+
'PROFILESTARTDATE' => 'start_datetime',
|
| 228 |
+
'PROFILEREFERENCE' => 'internal_reference_id',
|
| 229 |
+
'DESC' => 'schedule_description',
|
| 230 |
+
'MAXFAILEDPAYMENTS' => 'suspension_threshold',
|
| 231 |
+
'AUTOBILLAMT' => 'bill_failed_later',
|
| 232 |
+
'BILLINGPERIOD' => 'period_unit',
|
| 233 |
+
'BILLINGFREQUENCY' => 'period_frequency',
|
| 234 |
+
'TOTALBILLINGCYCLES' => 'period_max_cycles',
|
| 235 |
+
//'AMT' => 'billing_amount', // have to use 'amount', see above
|
| 236 |
+
'TRIALBILLINGPERIOD' => 'trial_period_unit',
|
| 237 |
+
'TRIALBILLINGFREQUENCY' => 'trial_period_frequency',
|
| 238 |
+
'TRIALTOTALBILLINGCYCLES' => 'trial_period_max_cycles',
|
| 239 |
+
'TRIALAMT' => 'trial_billing_amount',
|
| 240 |
+
// 'CURRENCYCODE' => 'currency_code',
|
| 241 |
+
'SHIPPINGAMT' => 'shipping_amount',
|
| 242 |
+
'TAXAMT' => 'tax_amount',
|
| 243 |
+
'INITAMT' => 'init_amount',
|
| 244 |
+
'FAILEDINITAMTACTION' => 'init_may_fail',
|
| 245 |
+
'PROFILEID' => 'recurring_profile_id',
|
| 246 |
+
'PROFILESTATUS' => 'recurring_profile_status',
|
| 247 |
+
'STATUS' => 'status',
|
| 248 |
+
|
| 249 |
+
//Next two fields are used for Brazil only
|
| 250 |
+
'TAXID' => 'buyer_tax_id',
|
| 251 |
+
'TAXIDTYPE' => 'buyer_tax_id_type',
|
| 252 |
+
|
| 253 |
+
'BILLINGAGREEMENTID' => 'billing_agreement_id',
|
| 254 |
+
'REFERENCEID' => 'reference_id',
|
| 255 |
+
'BILLINGAGREEMENTSTATUS' => 'billing_agreement_status',
|
| 256 |
+
'BILLINGTYPE' => 'billing_type',
|
| 257 |
+
'SREET' => 'street',
|
| 258 |
+
'CITY' => 'city',
|
| 259 |
+
'STATE' => 'state',
|
| 260 |
+
'COUNTRYCODE' => 'countrycode',
|
| 261 |
+
'ZIP' => 'zip',
|
| 262 |
+
'PAYERBUSINESS' => 'payer_business',
|
| 263 |
+
);
|
| 264 |
+
/**
|
| 265 |
+
* Payment information response specifically to be collected after some requests
|
| 266 |
+
* @var array
|
| 267 |
+
*/
|
| 268 |
+
protected $_paymentInformationResponse = array(
|
| 269 |
+
'PAYERID', 'PAYERSTATUS', 'CORRELATIONID', 'ADDRESSID', 'ADDRESSSTATUS',
|
| 270 |
+
'PAYMENTSTATUS', 'PENDINGREASON', 'PROTECTIONELIGIBILITY', 'EMAIL', 'SHIPPINGOPTIONNAME', 'TAXID', 'TAXIDTYPE'
|
| 271 |
+
);
|
| 272 |
+
protected $_doExpressCheckoutPaymentResponse = array(
|
| 273 |
+
'TRANSACTIONID', 'AMT', 'PAYMENTSTATUS', 'PENDINGREASON', 'REDIRECTREQUIRED'
|
| 274 |
+
);
|
| 275 |
+
|
| 276 |
+
protected $_billingaddress;
|
| 277 |
+
protected $_shippingaddress;
|
| 278 |
+
/**
|
| 279 |
+
* Map for billing address import/export
|
| 280 |
+
* @var array
|
| 281 |
+
*/
|
| 282 |
+
protected $_token;
|
| 283 |
+
protected $_billingAddressMap = array (
|
| 284 |
+
'BUSINESS' => 'company',
|
| 285 |
+
'NOTETEXT' => 'customer_notes',
|
| 286 |
+
'EMAIL' => 'email',
|
| 287 |
+
'FIRSTNAME' => 'firstname',
|
| 288 |
+
'LASTNAME' => 'lastname',
|
| 289 |
+
'MIDDLENAME' => 'middlename',
|
| 290 |
+
'SALUTATION' => 'prefix',
|
| 291 |
+
'SUFFIX' => 'suffix',
|
| 292 |
+
|
| 293 |
+
'COUNTRYCODE' => 'country_id', // iso-3166 two-character code
|
| 294 |
+
'STATE' => 'region',
|
| 295 |
+
'CITY' => 'city',
|
| 296 |
+
'STREET' => 'street',
|
| 297 |
+
'STREET2' => 'street2',
|
| 298 |
+
'ZIP' => 'postcode',
|
| 299 |
+
'PHONENUM' => 'telephone',
|
| 300 |
+
);
|
| 301 |
+
public $_model_obj=null;
|
| 302 |
+
protected $_checkout = null;
|
| 303 |
+
protected $_payer_id=null;
|
| 304 |
+
/**
|
| 305 |
+
* DoExpressCheckoutPayment request/response map
|
| 306 |
+
* @var array
|
| 307 |
+
*/
|
| 308 |
+
protected $_doExpressCheckoutPaymentRequest = array(
|
| 309 |
+
'TOKEN', 'PAYERID', 'PAYMENTACTION', 'AMT', 'CURRENCYCODE', 'IPADDRESS', 'BUTTONSOURCE', 'NOTIFYURL',
|
| 310 |
+
'RETURNFMFDETAILS', 'SUBJECT', 'ITEMAMT', 'SHIPPINGAMT', 'TAXAMT',
|
| 311 |
+
);
|
| 312 |
+
protected $_createBillingAgreementResponse = array('BILLINGAGREEMENTID');
|
| 313 |
+
/**
|
| 314 |
+
* @var Mage_Paypal_Model_Config
|
| 315 |
+
*/
|
| 316 |
+
protected $_config = null;
|
| 317 |
+
protected $_notify_url=null;
|
| 318 |
+
protected $_payment_action=null;
|
| 319 |
+
protected $_increment_id=null;
|
| 320 |
+
protected $_currency_code=null;
|
| 321 |
+
protected $_line_item_enabled=null;
|
| 322 |
+
protected $_address=null;
|
| 323 |
+
protected $_transaction_id=null;
|
| 324 |
+
protected $_redirect_req=null;
|
| 325 |
+
/**
|
| 326 |
+
* @var Mage_Sales_Model_Quote
|
| 327 |
+
*/
|
| 328 |
+
protected $_quote = false;
|
| 329 |
+
public function setToken($token){
|
| 330 |
+
$this->_token=$token;
|
| 331 |
+
}
|
| 332 |
+
public function setTransactionId($trans_id=null){
|
| 333 |
+
$this->_transaction_id=$trans_id;
|
| 334 |
+
}
|
| 335 |
+
public function getTransactionId(){
|
| 336 |
+
return $this->_transaction_id;
|
| 337 |
+
}
|
| 338 |
+
public function getModelObject(){
|
| 339 |
+
return $this->_model_obj;
|
| 340 |
+
}
|
| 341 |
+
public function getRedirectRequired(){
|
| 342 |
+
return $this->_redirect_req;
|
| 343 |
+
}
|
| 344 |
+
public function getToken($token){
|
| 345 |
+
return $this->_token;
|
| 346 |
+
}
|
| 347 |
+
public function setPayerId($id=""){
|
| 348 |
+
$this->_payer_id=$id;
|
| 349 |
+
}
|
| 350 |
+
public function getPayerId(){
|
| 351 |
+
return $this->_payer_id;
|
| 352 |
+
}
|
| 353 |
+
public function setAmount($amount=""){
|
| 354 |
+
$this->_amount=$amount;
|
| 355 |
+
}
|
| 356 |
+
public function getAmount(){
|
| 357 |
+
return $this->_amount;
|
| 358 |
+
}
|
| 359 |
+
public function setPaymentAction($action=""){
|
| 360 |
+
$this->_payment_action=$action;
|
| 361 |
+
}
|
| 362 |
+
public function getPaymentAction(){
|
| 363 |
+
return $this->_payment_action;
|
| 364 |
+
}
|
| 365 |
+
public function setNotifyUrl($notify=""){
|
| 366 |
+
$this->_notify_url=$notify;
|
| 367 |
+
}
|
| 368 |
+
public function getNotifyUrl(){
|
| 369 |
+
return $this->_notify_url;
|
| 370 |
+
}
|
| 371 |
+
public function setInvNum($increment_id=""){
|
| 372 |
+
$this->_increment_id=$increment_id;
|
| 373 |
+
}
|
| 374 |
+
public function getInvNum(){
|
| 375 |
+
return $this->_increment_id;
|
| 376 |
+
}
|
| 377 |
+
public function setCurrencyCode($currency_code=""){
|
| 378 |
+
$this->_currency_code=$currency_code;
|
| 379 |
+
}
|
| 380 |
+
public function getCurrencyCode(){
|
| 381 |
+
return $this->_currency_code;
|
| 382 |
+
}
|
| 383 |
+
public function setIsLineItemsEnabled($line=""){
|
| 384 |
+
$this->_line_item_enabled=$line;
|
| 385 |
+
}
|
| 386 |
+
public function getIsLineItemsEnabled(){
|
| 387 |
+
return $this->_line_item_enabled;
|
| 388 |
+
}
|
| 389 |
+
public function setAddress($address=""){
|
| 390 |
+
$this->_address=$address;
|
| 391 |
+
}
|
| 392 |
+
public function getAddress(){
|
| 393 |
+
return $this->_address;
|
| 394 |
+
}
|
| 395 |
+
public function setBillingAddress($billing=""){
|
| 396 |
+
$this->_billing_address=$billing;
|
| 397 |
+
}
|
| 398 |
+
public function getBillingAddress(){
|
| 399 |
+
return $this->_billing_address;
|
| 400 |
+
}
|
| 401 |
+
/**
|
| 402 |
+
* Return checkout session object
|
| 403 |
+
*
|
| 404 |
+
* @return Mage_Checkout_Model_Session
|
| 405 |
+
*/
|
| 406 |
+
private function _getCheckoutSession()
|
| 407 |
+
{
|
| 408 |
+
return Mage::getSingleton('checkout/session');
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
/**
|
| 412 |
+
* Return checkout quote object
|
| 413 |
+
*
|
| 414 |
+
* @return Mage_Sale_Model_Quote
|
| 415 |
+
*/
|
| 416 |
+
private function _getQuote()
|
| 417 |
+
{
|
| 418 |
+
if (!$this->_quote) {
|
| 419 |
+
$this->_quote = $this->_getCheckoutSession()->getQuote();
|
| 420 |
+
}
|
| 421 |
+
return $this->_quote;
|
| 422 |
+
}
|
| 423 |
+
public function setConfigObject($obj){
|
| 424 |
+
$this->_config=$obj;
|
| 425 |
+
}
|
| 426 |
+
public function getConfigObject(){
|
| 427 |
+
return $this->_config;
|
| 428 |
+
}
|
| 429 |
+
/**
|
| 430 |
+
* Instantiate quote and checkout
|
| 431 |
+
* @throws Mage_Core_Exception
|
| 432 |
+
*/
|
| 433 |
+
/* private function _initCheckout()
|
| 434 |
+
{
|
| 435 |
+
$quote = $this->_getQuote();
|
| 436 |
+
if (!$quote->hasItems() || $quote->getHasError()) {
|
| 437 |
+
$this->getResponse()->setHeader('HTTP/1.1','403 Forbidden');
|
| 438 |
+
Mage::throwException(Mage::helper('paypal')->__('Unable to initialize Express Checkout.'));
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
} */
|
| 442 |
+
|
| 443 |
+
public function indexAction(){
|
| 444 |
+
|
| 445 |
+
$quote = $this->_getQuote();
|
| 446 |
+
if (!$quote->hasItems() || $quote->getHasError()) {
|
| 447 |
+
$this->getResponse()->setHeader('HTTP/1.1','403 Forbidden');
|
| 448 |
+
Mage::throwException(Mage::helper('laybuy')->__('Unable to initialize Laybuy Express Checkout.'));
|
| 449 |
+
}
|
| 450 |
+
$model=Mage::getModel("laybuy/express");
|
| 451 |
+
$product_id="";
|
| 452 |
+
$store_id="";
|
| 453 |
+
if(!$model->isAvailable($quote) || !$model->checkForCategoriesAndProducts($product_id,$store_id)){
|
| 454 |
+
if(!$model->isAvailable($quote)){
|
| 455 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('laybuy')->__('Laybuy Express is not Available.'));
|
| 456 |
+
$this->_redirect('checkout/cart/index');
|
| 457 |
+
}
|
| 458 |
+
if(!$model->checkForCategoriesAndProducts($product_id,$store_id)){
|
| 459 |
+
$product_names="";
|
| 460 |
+
$product_names=$model->returnRestrictedProductNames($product_id,$store_id);
|
| 461 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('laybuy')->__('Your cart contains restricted products that are not allowed to pay using Lay-Buy.Please first remove these products - '.$product_names.'.'));
|
| 462 |
+
|
| 463 |
+
}
|
| 464 |
+
$this->_redirect('checkout/cart/index');
|
| 465 |
+
}
|
| 466 |
+
else{
|
| 467 |
+
$this->loadLayout();
|
| 468 |
+
$this->renderLayout();
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
}
|
| 472 |
+
public function formAction(){
|
| 473 |
+
$quote = $this->_getQuote();
|
| 474 |
+
$model=Mage::getModel("laybuy/express");
|
| 475 |
+
$product_id="";
|
| 476 |
+
$store_id="";
|
| 477 |
+
if(!$model->isAvailable($quote) || !$model->checkForCategoriesAndProducts($product_id,$store_id)){
|
| 478 |
+
if(!$model->checkForCategoriesAndProducts($product_id,$store_id)){
|
| 479 |
+
$product_names="";
|
| 480 |
+
$product_names=$model->returnRestrictedProductNames($product_id,$store_id);
|
| 481 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('laybuy')->__('Your cart contains restricted products that are not allowed to pay using Lay-Buy.Please first remove these products - '.$product_names.'.'));
|
| 482 |
+
|
| 483 |
+
}
|
| 484 |
+
$this->_redirect('checkout/cart/index');
|
| 485 |
+
}
|
| 486 |
+
if($this->getRequest()->getParams()){
|
| 487 |
+
$quote=Mage::getSingleton('checkout/session')->getQuote();
|
| 488 |
+
$email = $quote->getBillingAddress()->getEmail();
|
| 489 |
+
if (!$email) $email = $quote->getCustomerEmail();
|
| 490 |
+
|
| 491 |
+
$request=array();
|
| 492 |
+
$amt="";
|
| 493 |
+
$storeId="";
|
| 494 |
+
$storeId=Mage::app()->getStore()->getId();
|
| 495 |
+
if($checkout = Mage::getSingleton('checkout/session')){
|
| 496 |
+
$totals = $checkout->getQuote()->getTotals();
|
| 497 |
+
$amt = $totals["grand_total"]->getValue();
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
$currency_code ="";
|
| 501 |
+
$currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
|
| 502 |
+
$request["AMOUNT"]=$amt;
|
| 503 |
+
$request["MEMBER"]=Mage::getStoreConfig('payment/laybuy/membership_number',$storeId);
|
| 504 |
+
$request["CURRENCY"]=$currency_code;
|
| 505 |
+
$request["RETURNURL"]=Mage::getUrl("laybuy/express/return");
|
| 506 |
+
$request["CANCELURL"]=Mage::getUrl("laybuy/express/cancel");
|
| 507 |
+
$request["GETEXPRESSRETURNURL"]=Mage::getUrl("laybuy/express/returnfromgetexpress");
|
| 508 |
+
/* $request["RETURNURL"]="http://192.168.1.44/magento18/magento/index.php/laybuy/express/return/";
|
| 509 |
+
$request["CANCELURL"]="http://192.168.1.44/magento18/magento/index.php/laybuy/express/cancel/";
|
| 510 |
+
$request["GETEXPRESSRETURNURL"]="http://192.168.1.44/magento18/magento/index.php/laybuy/express/returnfromgetexpress";
|
| 511 |
+
*/
|
| 512 |
+
$cartItems = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
|
| 513 |
+
$description="";
|
| 514 |
+
foreach ($cartItems as $item) {
|
| 515 |
+
$_product = Mage::getModel('catalog/product')->load($item->getProduct()->getId());
|
| 516 |
+
if($description){
|
| 517 |
+
$description .= ' <br/> ';
|
| 518 |
+
}
|
| 519 |
+
$description .= strip_tags($_product->getShortDescription()).'(Qty '.(int)$item->getQty().')';
|
| 520 |
+
}
|
| 521 |
+
$request["DESC"]=$description;
|
| 522 |
+
$reserved_order_id="";
|
| 523 |
+
Mage::getSingleton('checkout/session')->getQuote()->reserveOrderId()->save();
|
| 524 |
+
$reserved_order_id=Mage::getSingleton('checkout/session')->getQuote()->getReservedOrderId();
|
| 525 |
+
$request["CUSTOM"]=$reserved_order_id;
|
| 526 |
+
$request["EMAIL"]=$email;
|
| 527 |
+
$request["BYPASSLAYBUY"]=Mage::getStoreConfig('payment/laybuy/bypasslaybuy');
|
| 528 |
+
$request["VERSION"]='0.2';
|
| 529 |
+
$params="";
|
| 530 |
+
$params=$this->getRequest()->getParam("payment");
|
| 531 |
+
$mnth="";
|
| 532 |
+
$init="";
|
| 533 |
+
|
| 534 |
+
$mnth= $params["laybuy_months"];
|
| 535 |
+
$init=$params["laybuy_init"];
|
| 536 |
+
$request["INIT"]=0;
|
| 537 |
+
$MAXD = Mage::getStoreConfig('payment/laybuy/maxd',$storeId);
|
| 538 |
+
$MIND = Mage::getStoreConfig('payment/laybuy/mind',$storeId);
|
| 539 |
+
$IMAGE = Mage::getStoreConfig('payment/laybuy/image',$storeId);
|
| 540 |
+
if(isset($mnth) && $mnth){
|
| 541 |
+
$MONTHS =$mnth;
|
| 542 |
+
}else{
|
| 543 |
+
$MONTHS = Mage::getStoreConfig('payment/laybuy/months',$storeId);
|
| 544 |
+
}
|
| 545 |
+
if(isset($init) && $init){
|
| 546 |
+
$INIT = $init;
|
| 547 |
+
}else{
|
| 548 |
+
$INIT = 0;
|
| 549 |
+
}
|
| 550 |
+
/* Restrict maxiumum possible downpayment percentage to less then or equal 50% */
|
| 551 |
+
if(!$MIND || $MIND<20 || $MIND>50){
|
| 552 |
+
$MIND = 20;
|
| 553 |
+
}
|
| 554 |
+
if(!$MAXD || $MAXD<20 || $MAXD>50){
|
| 555 |
+
$MAXD = 50;
|
| 556 |
+
}
|
| 557 |
+
if($IMAGE){
|
| 558 |
+
$IMAGE = Mage::getBaseUrl('media')."laybuy/".$IMAGE;
|
| 559 |
+
}else{
|
| 560 |
+
$IMAGE = 'http://lay-buys.com/lb2.jpg';
|
| 561 |
+
}
|
| 562 |
+
if(!$MONTHS || $MONTHS<0){
|
| 563 |
+
$MONTHS = 3;
|
| 564 |
+
}
|
| 565 |
+
if($INIT){
|
| 566 |
+
|
| 567 |
+
$request["INIT"]=$INIT;
|
| 568 |
+
}
|
| 569 |
+
$this->_init=$request["INIT"];
|
| 570 |
+
|
| 571 |
+
$request["MIND"]=$MIND ;
|
| 572 |
+
$request["MAXD"]=$MAXD;
|
| 573 |
+
$request["IMAGE"]=$IMAGE;
|
| 574 |
+
$request["MONTHS"]=$MONTHS;
|
| 575 |
+
Mage::getSingleton('core/session')->setPaymentMonths($request["MONTHS"]);
|
| 576 |
+
Mage::getSingleton('core/session')->setPaymentInit($request["INIT"]);
|
| 577 |
+
$this->_months=$request["MONTHS"];
|
| 578 |
+
$helper=Mage::helper('laybuy');
|
| 579 |
+
$redirectURL="http://lay-buys.com/expressgateway/";
|
| 580 |
+
$token="";
|
| 581 |
+
if($token = $helper->postToLaybuy($redirectURL,$request)){
|
| 582 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('Ced_LayBuy_Block_Express_Redirect')->setData('token',$token)->toHtml());
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
|
| 586 |
+
}
|
| 587 |
+
}
|
| 588 |
+
/**
|
| 589 |
+
* DoExpressCheckout call
|
| 590 |
+
* @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoExpressCheckoutPayment
|
| 591 |
+
*/
|
| 592 |
+
public function callDoExpressCheckoutPayment()
|
| 593 |
+
{
|
| 594 |
+
|
| 595 |
+
$payer_id="";
|
| 596 |
+
if(Mage::getSingleton('core/session')->getPaymentPayerId()){
|
| 597 |
+
$payer_id=Mage::getSingleton('core/session')->getPaymentPayerId();
|
| 598 |
+
}
|
| 599 |
+
$token="";
|
| 600 |
+
if(Mage::getSingleton('core/session')->getLaybuyExpressToken()){
|
| 601 |
+
$token=Mage::getSingleton('core/session')->getLaybuyExpressToken();
|
| 602 |
+
}
|
| 603 |
+
$sandbox="";
|
| 604 |
+
if(Mage::getSingleton('core/session')->getSandbox()){
|
| 605 |
+
$sandbox=Mage::getSingleton('core/session')->getSandbox();
|
| 606 |
+
}
|
| 607 |
+
$vpayment="";
|
| 608 |
+
if(Mage::getSingleton('core/session')->getVpaymentId()){
|
| 609 |
+
$vpayment=Mage::getSingleton('core/session')->getVpaymentId();
|
| 610 |
+
}
|
| 611 |
+
$quote="";
|
| 612 |
+
$email ="";
|
| 613 |
+
$city="";
|
| 614 |
+
$firstname="";
|
| 615 |
+
$lastname="";
|
| 616 |
+
$company="";
|
| 617 |
+
$street="";
|
| 618 |
+
$region_id="";
|
| 619 |
+
$region ="";
|
| 620 |
+
$state="";
|
| 621 |
+
$postcode="";
|
| 622 |
+
$country_id="";
|
| 623 |
+
$telephone="";
|
| 624 |
+
$country_name="";
|
| 625 |
+
$quote=Mage::getSingleton('checkout/session')->getQuote();
|
| 626 |
+
$email = $quote->getBillingAddress()->getEmail();
|
| 627 |
+
$city=$quote->getBillingAddress()->getCity();
|
| 628 |
+
$firstname=$quote->getBillingAddress()->getFirstname();
|
| 629 |
+
$lastname=$quote->getBillingAddress()->getLastname();
|
| 630 |
+
$company=$quote->getBillingAddress()->getCompany();
|
| 631 |
+
$street=$quote->getBillingAddress()->getStreet();
|
| 632 |
+
$region_id=$quote->getBillingAddress()->getRegionId();
|
| 633 |
+
$region = Mage::getModel('directory/region')->load($region_id);
|
| 634 |
+
$state=$region->getName();
|
| 635 |
+
$postcode=$quote->getBillingAddress()->getPostcode();
|
| 636 |
+
$country_id=$quote->getBillingAddress()->getCountryId();
|
| 637 |
+
$country = Mage::getModel('directory/country')->loadByCode($country_id);
|
| 638 |
+
$country_name=$country->getName();
|
| 639 |
+
$telephone=$quote->getBillingAddress()->getTelephone();
|
| 640 |
+
|
| 641 |
+
$request=array();
|
| 642 |
+
$cartItems = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
|
| 643 |
+
$description="";
|
| 644 |
+
foreach ($cartItems as $item) {
|
| 645 |
+
$_product = Mage::getModel('catalog/product')->load($item->getProduct()->getId());
|
| 646 |
+
if($description){
|
| 647 |
+
$description .= ' <br/> ';
|
| 648 |
+
}
|
| 649 |
+
$description .= strip_tags($_product->getShortDescription()).'(Qty '.(int)$item->getQty().')';
|
| 650 |
+
}
|
| 651 |
+
$request["DESC"]=$description;
|
| 652 |
+
$request["TOKEN"]=$token;
|
| 653 |
+
$request["PAYERID"]=$payer_id;
|
| 654 |
+
$request["COUNTRY_NAME"]=$country_name;
|
| 655 |
+
$request["CITY"]=$city;
|
| 656 |
+
$request["FIRSTNAME"]=$firstname;
|
| 657 |
+
$request["LASTNAME"]=$lastname;
|
| 658 |
+
$request["COMPANY"]=$company;
|
| 659 |
+
$street2="";
|
| 660 |
+
$street1="";
|
| 661 |
+
if(is_array($street)){
|
| 662 |
+
$street1=$street[0];
|
| 663 |
+
if(isset($street[1])){
|
| 664 |
+
$street2=$street[1];
|
| 665 |
+
}
|
| 666 |
+
|
| 667 |
+
}
|
| 668 |
+
$request["STREET1"]=$street1;
|
| 669 |
+
$request["STREET2"]=$street2;
|
| 670 |
+
$request["STATE"]=$state;
|
| 671 |
+
$request["POSTCODE"]=$postcode;
|
| 672 |
+
$request["COUNTRYID"]=$country_id;
|
| 673 |
+
$request["TELEPHONE"]=$telephone;
|
| 674 |
+
$amt="";
|
| 675 |
+
$storeId="";
|
| 676 |
+
$storeId=Mage::app()->getStore()->getId();
|
| 677 |
+
if($checkout = Mage::getSingleton('checkout/session')){
|
| 678 |
+
$totals = $checkout->getQuote()->getTotals();
|
| 679 |
+
$amt = $totals["grand_total"]->getValue();
|
| 680 |
+
}
|
| 681 |
+
$currency_code ="";
|
| 682 |
+
$currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
|
| 683 |
+
$request["AMOUNT"]=$amt;
|
| 684 |
+
|
| 685 |
+
$request["MEMBER"]=Mage::getStoreConfig('payment/laybuy/membership_number',$storeId);
|
| 686 |
+
|
| 687 |
+
$request["CURRENCY"]=$currency_code;
|
| 688 |
+
$cartItems = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
|
| 689 |
+
$description="";
|
| 690 |
+
foreach ($cartItems as $item) {
|
| 691 |
+
$_product = Mage::getModel('catalog/product')->load($item->getProduct()->getId());
|
| 692 |
+
if($description){
|
| 693 |
+
$description .= ' <br/> ';
|
| 694 |
+
}
|
| 695 |
+
$description .= strip_tags($_product->getShortDescription()).'(Qty '.(int)$item->getQty().')';
|
| 696 |
+
}
|
| 697 |
+
$request["DESC"]=$description;
|
| 698 |
+
$reserved_order_id="";
|
| 699 |
+
$reserved_order_id=Mage::getSingleton('checkout/session')->getQuote()->getReservedOrderId();
|
| 700 |
+
$request["CUSTOM"]=$reserved_order_id;
|
| 701 |
+
$request["EMAIL"]=$email;
|
| 702 |
+
$request["BYPASSLAYBUY"]=Mage::getStoreConfig('payment/laybuy/bypasslaybuy');
|
| 703 |
+
$request["VERSION"]='0.2';
|
| 704 |
+
if( Mage::getSingleton('core/session')->getPaymentMonths()){
|
| 705 |
+
$mnth= Mage::getSingleton('core/session')->getPaymentMonths();
|
| 706 |
+
}
|
| 707 |
+
if(Mage::getSingleton('core/session')->getPaymentInit()){
|
| 708 |
+
$init=Mage::getSingleton('core/session')->getPaymentInit();
|
| 709 |
+
}
|
| 710 |
+
$request["INIT"]=0;
|
| 711 |
+
$MAXD = Mage::getStoreConfig('payment/laybuy/maxd',$storeId);
|
| 712 |
+
$MIND = Mage::getStoreConfig('payment/laybuy/mind',$storeId);
|
| 713 |
+
$IMAGE = Mage::getStoreConfig('payment/laybuy/image',$storeId);
|
| 714 |
+
if(isset($mnth) && $mnth){
|
| 715 |
+
$MONTHS =$mnth;
|
| 716 |
+
}else{
|
| 717 |
+
$MONTHS = Mage::getStoreConfig('payment/laybuy/months',$storeId);
|
| 718 |
+
}
|
| 719 |
+
if(isset($init) && $init){
|
| 720 |
+
$INIT = $init;
|
| 721 |
+
}else{
|
| 722 |
+
$INIT = 0;
|
| 723 |
+
}
|
| 724 |
+
/* Restrict maxiumum possible downpayment percentage to less then or equal 50% */
|
| 725 |
+
if(!$MIND || $MIND<20 || $MIND>50){
|
| 726 |
+
$MIND = 20;
|
| 727 |
+
}
|
| 728 |
+
if(!$MAXD || $MAXD<20 || $MAXD>50){
|
| 729 |
+
$MAXD = 50;
|
| 730 |
+
}
|
| 731 |
+
if($IMAGE){
|
| 732 |
+
$IMAGE = Mage::getBaseUrl('media')."laybuy/".$IMAGE;
|
| 733 |
+
}else{
|
| 734 |
+
$IMAGE = 'http://lay-buys.com/lb2.jpg';
|
| 735 |
+
}
|
| 736 |
+
if(!$MONTHS || $MONTHS<0){
|
| 737 |
+
$MONTHS = 3;
|
| 738 |
+
}
|
| 739 |
+
if($INIT){
|
| 740 |
+
|
| 741 |
+
$request["INIT"]=$INIT;
|
| 742 |
+
}
|
| 743 |
+
$request["MIND"]=$MIND ;
|
| 744 |
+
$request["MAXD"]=$MAXD;
|
| 745 |
+
$request["IMAGE"]=$IMAGE;
|
| 746 |
+
$request["MONTHS"]=$MONTHS;
|
| 747 |
+
$request["DO_EXPRESS"]="1";
|
| 748 |
+
$request['SANDBOX']=$sandbox;
|
| 749 |
+
$request['VPAYMENTID']=$vpayment;
|
| 750 |
+
|
| 751 |
+
$helper=Mage::helper('laybuy');
|
| 752 |
+
$redirectURL="https://lay-buys.com/expressgateway/doexpress/";
|
| 753 |
+
|
| 754 |
+
$postdata ='';
|
| 755 |
+
|
| 756 |
+
foreach($request as $lname=>$lvalue){
|
| 757 |
+
/* if($lname == 'MEMBER') continue; */
|
| 758 |
+
$postdata .= $lname."=".urlencode($lvalue)."&";
|
| 759 |
+
}
|
| 760 |
+
$postdata = rtrim($postdata,'&');
|
| 761 |
+
|
| 762 |
+
$ch = curl_init();
|
| 763 |
+
curl_setopt($ch, CURLOPT_URL,$redirectURL);
|
| 764 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
| 765 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
|
| 766 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
| 767 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
|
| 768 |
+
$result = curl_exec($ch);
|
| 769 |
+
curl_close ($ch);
|
| 770 |
+
$result = json_decode($result,true);
|
| 771 |
+
if($result['ACK']=="FAILURE"){
|
| 772 |
+
print_r($result);die();
|
| 773 |
+
}
|
| 774 |
+
$doexpressresponse="";
|
| 775 |
+
$laybuyresponse="";
|
| 776 |
+
if(isset($result['doexpressresponse'])){
|
| 777 |
+
$doexpressresponse=$result['doexpressresponse'];
|
| 778 |
+
}
|
| 779 |
+
if(isset($result['laybuyresponse'])){
|
| 780 |
+
$laybuyresponse=$result['laybuyresponse'];
|
| 781 |
+
$this->_laybuyresponse=$result['laybuyresponse'];
|
| 782 |
+
$jsonresponse=json_encode($result['laybuyresponse']);
|
| 783 |
+
$respmodel=Mage::getModel("laybuy/laybuyresp");
|
| 784 |
+
$respmodel->setData("order_id",$result['laybuyresponse']["CUSTOM"]);
|
| 785 |
+
$respmodel->setData("response",$jsonresponse);
|
| 786 |
+
$respmodel->save();
|
| 787 |
+
}
|
| 788 |
+
if($laybuyresponse){
|
| 789 |
+
$this->_transaction_id=$laybuyresponse['DP_PAYPAL_TXN_ID'];
|
| 790 |
+
}
|
| 791 |
+
if($doexpressresponse){
|
| 792 |
+
$this->_redirect_req=$doexpressresponse['SUCCESSPAGEREDIRECTREQUESTED'];
|
| 793 |
+
}
|
| 794 |
+
/* $this->_prepareExpressCheckoutCallRequest($this->_doExpressCheckoutPaymentRequest);
|
| 795 |
+
$request = $this->_exportToRequest($this->_doExpressCheckoutPaymentRequest);
|
| 796 |
+
$this->_exportLineItems($request);
|
| 797 |
+
|
| 798 |
+
if ($this->getAddress()) {
|
| 799 |
+
$request = $this->_importAddresses($request);
|
| 800 |
+
$request['ADDROVERRIDE'] = 1;
|
| 801 |
+
}*/
|
| 802 |
+
$response = $doexpressresponse;
|
| 803 |
+
$this->_model_obj=new Ced_LayBuy_Model_Abstract();
|
| 804 |
+
$this->_model_obj->_importFromResponse($this->_paymentInformationResponse, $response);//$this
|
| 805 |
+
$this->_model_obj->_importFromResponse($this->_doExpressCheckoutPaymentResponse, $response);
|
| 806 |
+
$this->_model_obj->_importFromResponse($this->_createBillingAgreementResponse, $response);
|
| 807 |
+
|
| 808 |
+
|
| 809 |
+
}
|
| 810 |
+
|
| 811 |
+
public function returnfromgetexpressAction(){
|
| 812 |
+
if($this->getRequest()->getParams()){
|
| 813 |
+
$data=$this->getRequest()->getParams();
|
| 814 |
+
//var_dump($data);die("hellooooohiii");
|
| 815 |
+
Mage::getSingleton('core/session')->setSandbox($data['sand']);
|
| 816 |
+
Mage::getSingleton('core/session')->setVpaymentId($data['vpay']);
|
| 817 |
+
$token=$data['TOKEN'];
|
| 818 |
+
$this->_token=$data['TOKEN'];
|
| 819 |
+
$payer_id=$data['PAYERID'];
|
| 820 |
+
$this->_payer_id=$data['PAYERID'];
|
| 821 |
+
Mage::getSingleton('core/session')->setPaymentPayerId($payer_id);
|
| 822 |
+
Mage::getSingleton('core/session')->setLaybuyExpressToken($token);
|
| 823 |
+
$this->_importFromResponse($this->_paymentInformationResponse, $data);
|
| 824 |
+
$this->_exportAddressses($data);
|
| 825 |
+
$this->_initCheckout();
|
| 826 |
+
$quote = $this->_quote;
|
| 827 |
+
$this->_ignoreAddressValidation();
|
| 828 |
+
$billingAddress = $quote->getBillingAddress();
|
| 829 |
+
$exportedBillingAddress = $this->getExportedBillingAddress();
|
| 830 |
+
$quote->setCustomerEmail($billingAddress->getEmail());
|
| 831 |
+
$quote->setCustomerPrefix($billingAddress->getPrefix());
|
| 832 |
+
$quote->setCustomerFirstname($billingAddress->getFirstname());
|
| 833 |
+
$quote->setCustomerMiddlename($billingAddress->getMiddlename());
|
| 834 |
+
$quote->setCustomerLastname($billingAddress->getLastname());
|
| 835 |
+
$quote->setCustomerSuffix($billingAddress->getSuffix());
|
| 836 |
+
$quote->setCustomerNote($exportedBillingAddress->getData('note'));
|
| 837 |
+
$this->_setExportedAddressData($billingAddress, $exportedBillingAddress);
|
| 838 |
+
// import shipping address
|
| 839 |
+
$exportedShippingAddress = $this->getExportedShippingAddress();
|
| 840 |
+
if (!$quote->getIsVirtual()) {
|
| 841 |
+
$shippingAddress = $quote->getShippingAddress();
|
| 842 |
+
if ($shippingAddress) {
|
| 843 |
+
if ($exportedShippingAddress) {
|
| 844 |
+
$this->_setExportedAddressData($shippingAddress, $exportedShippingAddress);
|
| 845 |
+
$shippingAddress->setCollectShippingRates(true);
|
| 846 |
+
$shippingAddress->setSameAsBilling(0);
|
| 847 |
+
|
| 848 |
+
}
|
| 849 |
+
|
| 850 |
+
// import shipping method
|
| 851 |
+
/* $code = '';
|
| 852 |
+
|
| 853 |
+
if ($this->_api->getShippingRateCode()) {
|
| 854 |
+
if ($code = $this->_matchShippingMethodCode($shippingAddress, $this->_api->getShippingRateCode())) {
|
| 855 |
+
// possible bug of double collecting rates :-/
|
| 856 |
+
$shippingAddress->setShippingMethod($code)->setCollectShippingRates(true);
|
| 857 |
+
}
|
| 858 |
+
}
|
| 859 |
+
$quote->getPayment()->setAdditionalInformation(
|
| 860 |
+
self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD,
|
| 861 |
+
$code
|
| 862 |
+
);*/
|
| 863 |
+
}
|
| 864 |
+
}
|
| 865 |
+
$payment = $quote->getPayment();
|
| 866 |
+
|
| 867 |
+
$payment->setMethod("laybuy_express");
|
| 868 |
+
$this->importToPayment($this, $payment);
|
| 869 |
+
$payment->setAdditionalInformation('laybuy_express_checkout_payer_id', $payer_id)
|
| 870 |
+
->setAdditionalInformation('laybuy_express_checkout_token', $token);
|
| 871 |
+
$quote->collectTotals()->save();
|
| 872 |
+
$this->_redirect('*/*/review');
|
| 873 |
+
return;
|
| 874 |
+
}
|
| 875 |
+
|
| 876 |
+
}
|
| 877 |
+
/**
|
| 878 |
+
* Check whether the payment was processed successfully
|
| 879 |
+
*
|
| 880 |
+
* @param Mage_Payment_Model_Info $payment
|
| 881 |
+
* @return bool
|
| 882 |
+
*/
|
| 883 |
+
public static function isPaymentSuccessful(Mage_Payment_Model_Info $payment)
|
| 884 |
+
{
|
| 885 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 886 |
+
if (in_array($paymentStatus, array(
|
| 887 |
+
self::PAYMENTSTATUS_COMPLETED, self::PAYMENTSTATUS_INPROGRESS, self::PAYMENTSTATUS_REFUNDED,
|
| 888 |
+
self::PAYMENTSTATUS_REFUNDEDPART, self::PAYMENTSTATUS_UNREVERSED, self::PAYMENTSTATUS_PROCESSED,
|
| 889 |
+
))) {
|
| 890 |
+
return true;
|
| 891 |
+
}
|
| 892 |
+
$pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL);
|
| 893 |
+
return self::PAYMENTSTATUS_PENDING === $paymentStatus
|
| 894 |
+
&& in_array($pendingReason, array('authorization', 'order'));
|
| 895 |
+
}
|
| 896 |
+
/**
|
| 897 |
+
* Check whether the payment was processed unsuccessfully or failed
|
| 898 |
+
*
|
| 899 |
+
* @param Mage_Payment_Model_Info $payment
|
| 900 |
+
* @return bool
|
| 901 |
+
*/
|
| 902 |
+
public static function isPaymentFailed(Mage_Payment_Model_Info $payment)
|
| 903 |
+
{
|
| 904 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 905 |
+
return in_array($paymentStatus, array(
|
| 906 |
+
self::PAYMENTSTATUS_DENIED, self::PAYMENTSTATUS_EXPIRED, self::PAYMENTSTATUS_FAILED,
|
| 907 |
+
self::PAYMENTSTATUS_REVERSED, self::PAYMENTSTATUS_VOIDED,
|
| 908 |
+
));
|
| 909 |
+
}
|
| 910 |
+
/**
|
| 911 |
+
* Check whether the payment is in review state
|
| 912 |
+
*
|
| 913 |
+
* @param Mage_Payment_Model_Info $payment
|
| 914 |
+
* @return bool
|
| 915 |
+
*/
|
| 916 |
+
public static function isPaymentReviewRequired(Mage_Payment_Model_Info $payment)
|
| 917 |
+
{
|
| 918 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 919 |
+
if (self::PAYMENTSTATUS_PENDING === $paymentStatus) {
|
| 920 |
+
$pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL);
|
| 921 |
+
return !in_array($pendingReason, array('authorization', 'order'));
|
| 922 |
+
}
|
| 923 |
+
return false;
|
| 924 |
+
}
|
| 925 |
+
/**
|
| 926 |
+
* Grab data from source and map it into payment
|
| 927 |
+
*
|
| 928 |
+
* @param array|Varien_Object|callback $from
|
| 929 |
+
* @param Mage_Payment_Model_Info $payment
|
| 930 |
+
*/
|
| 931 |
+
public function importToPayment($from, Mage_Payment_Model_Info $payment)
|
| 932 |
+
{
|
| 933 |
+
$fullMap = array_merge($this->_paymentMap, $this->_systemMap);
|
| 934 |
+
|
| 935 |
+
if (is_object($from)) {
|
| 936 |
+
$from = array($from, 'getDataUsingMethod');
|
| 937 |
+
}
|
| 938 |
+
|
| 939 |
+
Varien_Object_Mapper::accumulateByMap($from, array($payment, 'setAdditionalInformation'), $fullMap);
|
| 940 |
+
|
| 941 |
+
}
|
| 942 |
+
|
| 943 |
+
/**
|
| 944 |
+
* Import $this public data from a private response array
|
| 945 |
+
*
|
| 946 |
+
* @param array $privateResponseMap
|
| 947 |
+
* @param array $response
|
| 948 |
+
*/
|
| 949 |
+
protected function _importFromResponse(array $privateResponseMap, array $response)
|
| 950 |
+
{
|
| 951 |
+
$map = array();
|
| 952 |
+
foreach ($privateResponseMap as $key) {
|
| 953 |
+
if (isset($this->_globalMap[$key])) {
|
| 954 |
+
$map[$key] = $this->_globalMap[$key];
|
| 955 |
+
}
|
| 956 |
+
if (isset($response[$key]) && isset($this->_importFromRequestFilters[$key])) {
|
| 957 |
+
$callback = $this->_importFromRequestFilters[$key];
|
| 958 |
+
$response[$key] = call_user_func(array($this, $callback), $response[$key], $key, $map[$key]);
|
| 959 |
+
}
|
| 960 |
+
}
|
| 961 |
+
Varien_Object_Mapper::accumulateByMap($response, array($this, 'setDataUsingMethod'), $map);
|
| 962 |
+
}
|
| 963 |
+
|
| 964 |
+
/**
|
| 965 |
+
* Sets address data from exported address
|
| 966 |
+
*
|
| 967 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
| 968 |
+
* @param array $exportedAddress
|
| 969 |
+
*/
|
| 970 |
+
protected function _setExportedAddressData($address, $exportedAddress)
|
| 971 |
+
{
|
| 972 |
+
foreach ($exportedAddress->getExportedKeys() as $key) {
|
| 973 |
+
$oldData = $address->getDataUsingMethod($key);
|
| 974 |
+
$isEmpty = null;
|
| 975 |
+
if (is_array($oldData)) {
|
| 976 |
+
foreach($oldData as $val) {
|
| 977 |
+
if(!empty($val)) {
|
| 978 |
+
$isEmpty = false;
|
| 979 |
+
break;
|
| 980 |
+
}
|
| 981 |
+
$isEmpty = true;
|
| 982 |
+
}
|
| 983 |
+
}
|
| 984 |
+
if (empty($oldData) || $isEmpty === true) {
|
| 985 |
+
$address->setDataUsingMethod($key, $exportedAddress->getData($key));
|
| 986 |
+
}
|
| 987 |
+
}
|
| 988 |
+
}
|
| 989 |
+
protected function setExportedBillingAddress($address=""){
|
| 990 |
+
$this->_billingaddress=$address;
|
| 991 |
+
}
|
| 992 |
+
protected function getExportedBillingAddress($address=""){
|
| 993 |
+
return $this->_billingaddress;
|
| 994 |
+
}
|
| 995 |
+
protected function setExportedShippingAddress($address=""){
|
| 996 |
+
$this->_shippingaddress=$address;
|
| 997 |
+
}
|
| 998 |
+
protected function getExportedShippingAddress($address=""){
|
| 999 |
+
return $this->_shippingaddress;
|
| 1000 |
+
}
|
| 1001 |
+
/**
|
| 1002 |
+
* Create billing and shipping addresses basing on response data
|
| 1003 |
+
* @param array $data
|
| 1004 |
+
*/
|
| 1005 |
+
protected function _exportAddressses($data)
|
| 1006 |
+
{
|
| 1007 |
+
$address = new Varien_Object();
|
| 1008 |
+
Varien_Object_Mapper::accumulateByMap($data, $address, $this->_billingAddressMap);
|
| 1009 |
+
$address->setExportedKeys(array_values($this->_billingAddressMap));
|
| 1010 |
+
$this->_applyStreetAndRegionWorkarounds($address);
|
| 1011 |
+
$this->setExportedBillingAddress($address);
|
| 1012 |
+
// assume there is shipping address if there is at least one field specific to shipping
|
| 1013 |
+
if (isset($data['SHIPTONAME'])) {
|
| 1014 |
+
$shippingAddress = clone $address;
|
| 1015 |
+
Varien_Object_Mapper::accumulateByMap($data, $shippingAddress, $this->_shippingAddressMap);
|
| 1016 |
+
$this->_applyStreetAndRegionWorkarounds($shippingAddress);
|
| 1017 |
+
// PayPal doesn't provide detailed shipping name fields, so the name will be overwritten
|
| 1018 |
+
$firstName = $data['SHIPTONAME'];
|
| 1019 |
+
$lastName = null;
|
| 1020 |
+
if (isset($data['FIRSTNAME']) && $data['LASTNAME']) {
|
| 1021 |
+
$firstName = $data['FIRSTNAME'];
|
| 1022 |
+
$lastName = $data['LASTNAME'];
|
| 1023 |
+
}
|
| 1024 |
+
$shippingAddress->addData(array(
|
| 1025 |
+
'prefix' => null,
|
| 1026 |
+
'firstname' => $firstName,
|
| 1027 |
+
'middlename' => null,
|
| 1028 |
+
'lastname' => $lastName,
|
| 1029 |
+
'suffix' => null,
|
| 1030 |
+
));
|
| 1031 |
+
$this->setExportedShippingAddress($shippingAddress);
|
| 1032 |
+
|
| 1033 |
+
}
|
| 1034 |
+
}
|
| 1035 |
+
/**
|
| 1036 |
+
* Adopt specified address object to be compatible with Magento
|
| 1037 |
+
*
|
| 1038 |
+
* @param Varien_Object $address
|
| 1039 |
+
*/
|
| 1040 |
+
protected function _applyStreetAndRegionWorkarounds(Varien_Object $address)
|
| 1041 |
+
{
|
| 1042 |
+
// merge street addresses into 1
|
| 1043 |
+
if ($address->hasStreet2()) {
|
| 1044 |
+
$address->setStreet(implode("\n", array($address->getStreet(), $address->getStreet2())));
|
| 1045 |
+
$address->unsStreet2();
|
| 1046 |
+
}
|
| 1047 |
+
// attempt to fetch region_id from directory
|
| 1048 |
+
if ($address->getCountryId() && $address->getRegion()) {
|
| 1049 |
+
$regions = Mage::getModel('directory/country')->loadByCode($address->getCountryId())->getRegionCollection()
|
| 1050 |
+
//->addRegionCodeOrNameFilter($address->getRegion())
|
| 1051 |
+
->setPageSize(1);
|
| 1052 |
+
/**********************new added code*************************/
|
| 1053 |
+
$region1="";
|
| 1054 |
+
$condition="";
|
| 1055 |
+
$region1=$address->getRegion();
|
| 1056 |
+
|
| 1057 |
+
if (!empty($region1)) {
|
| 1058 |
+
$condition = is_array($region1) ? array('in' => $region1) : $region1;
|
| 1059 |
+
$regions->addFieldToFilter(array('main_table.code', 'main_table.default_name'), array($condition, $condition));
|
| 1060 |
+
|
| 1061 |
+
}
|
| 1062 |
+
/**********************new added code ends*************************/
|
| 1063 |
+
foreach ($regions as $region) {
|
| 1064 |
+
$address->setRegionId($region->getId());
|
| 1065 |
+
$address->setExportedKeys(array_merge($address->getExportedKeys(), array('region_id')));
|
| 1066 |
+
break;
|
| 1067 |
+
}
|
| 1068 |
+
}
|
| 1069 |
+
}
|
| 1070 |
+
/**
|
| 1071 |
+
* Make sure addresses will be saved without validation errors
|
| 1072 |
+
*/
|
| 1073 |
+
private function _ignoreAddressValidation()
|
| 1074 |
+
{
|
| 1075 |
+
$this->_quote->getBillingAddress()->setShouldIgnoreValidation(true);
|
| 1076 |
+
if (!$this->_quote->getIsVirtual()) {
|
| 1077 |
+
$this->_quote->getShippingAddress()->setShouldIgnoreValidation(true);
|
| 1078 |
+
if ( !$this->_quote->getBillingAddress()->getEmail()) {//!$this->_config->requireBillingAddress &&
|
| 1079 |
+
$this->_quote->getBillingAddress()->setSameAsBilling(1);
|
| 1080 |
+
}
|
| 1081 |
+
}
|
| 1082 |
+
}
|
| 1083 |
+
public function continueAction(){
|
| 1084 |
+
$quote = $this->_getQuote();
|
| 1085 |
+
if (!$quote->hasItems() || $quote->getHasError()) {
|
| 1086 |
+
$this->getResponse()->setHeader('HTTP/1.1','403 Forbidden');
|
| 1087 |
+
Mage::throwException(Mage::helper('laybuy')->__('Unable to initialize Express Checkout.'));
|
| 1088 |
+
}
|
| 1089 |
+
$this->_checkout = Mage::getSingleton("laybuy/express_checkout", array(
|
| 1090 |
+
'quote' => $quote,
|
| 1091 |
+
));
|
| 1092 |
+
if ($this->_getQuote()->getIsMultiShipping()) {
|
| 1093 |
+
$this->_getQuote()->setIsMultiShipping(false);
|
| 1094 |
+
$this->_getQuote()->removeAllAddresses();
|
| 1095 |
+
}
|
| 1096 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
| 1097 |
+
if ($customer && $customer->getId()) {
|
| 1098 |
+
$this->_checkout->setCustomerWithAddressChange(
|
| 1099 |
+
$customer, $this->_getQuote()->getBillingAddress(), $this->_getQuote()->getShippingAddress()
|
| 1100 |
+
);
|
| 1101 |
+
}
|
| 1102 |
+
$this->_checkout->prepareGiropayUrls(
|
| 1103 |
+
Mage::getUrl('checkout/onepage/success'),
|
| 1104 |
+
Mage::getUrl('laybuy/express/cancel'),
|
| 1105 |
+
Mage::getUrl('checkout/onepage/success')
|
| 1106 |
+
);
|
| 1107 |
+
$token = $this->_checkout->start(Mage::getUrl('*/*/return'), Mage::getUrl('*/*/cancel'));
|
| 1108 |
+
|
| 1109 |
+
}
|
| 1110 |
+
/**
|
| 1111 |
+
* when laybuy returns
|
| 1112 |
+
* The order information at this point is in POST
|
| 1113 |
+
*/
|
| 1114 |
+
public function success($order_id)
|
| 1115 |
+
{
|
| 1116 |
+
//var_dump($order_id);echo "<br>";
|
| 1117 |
+
$respmodel=Mage::getModel("laybuy/laybuyresp")->getCollection();
|
| 1118 |
+
$laybuyresponse="";
|
| 1119 |
+
foreach($respmodel as $model)
|
| 1120 |
+
{
|
| 1121 |
+
if($order_id==$model->getData("order_id")){
|
| 1122 |
+
$resp="";
|
| 1123 |
+
$resp=$model->getData("response");
|
| 1124 |
+
$laybuyresponse=json_decode($resp,true);
|
| 1125 |
+
break;
|
| 1126 |
+
}
|
| 1127 |
+
}
|
| 1128 |
+
//var_dump($laybuyresponse);echo "<br>";
|
| 1129 |
+
$format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
|
| 1130 |
+
$status = array_change_key_case($laybuyresponse,CASE_LOWER);
|
| 1131 |
+
//var_dump($status);echo "<br>";
|
| 1132 |
+
if(isset($status['result']) && $status['result']=='FAILURE'){
|
| 1133 |
+
$this->_forward('cancel');
|
| 1134 |
+
}
|
| 1135 |
+
$session = Mage::getSingleton('checkout/session');
|
| 1136 |
+
try{
|
| 1137 |
+
$status['_secure'] = true;
|
| 1138 |
+
$str = print_r($status, true);
|
| 1139 |
+
/* $status['first_payment_due'] = '13/12/13';
|
| 1140 |
+
$status['last_payment_due'] = '13/01/14'; */
|
| 1141 |
+
$status['first_payment_due'] = date('Y-m-d h:i:s', strtotime(str_replace('/','-',$status['first_payment_due'])));
|
| 1142 |
+
$status['last_payment_due'] = date('Y-m-d h:i:s', strtotime(str_replace('/','-',$status['last_payment_due'])));
|
| 1143 |
+
//$session->setQuoteId($session->getLayBuyStandardQuoteId(true));
|
| 1144 |
+
//Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
| 1145 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($status['custom']);
|
| 1146 |
+
$payment_info = array();
|
| 1147 |
+
if($order && $order->getId()){
|
| 1148 |
+
$order->sendNewOrderEmail();
|
| 1149 |
+
$order->setEmailSent(true);
|
| 1150 |
+
$payment_info = $order->getPayment()->getData('additional_information');
|
| 1151 |
+
$payment_info['transactions'][$status['paypal_profile_id']][] = array(
|
| 1152 |
+
'txnID' => $status['dp_paypal_txn_id'],
|
| 1153 |
+
'type' => 'd',
|
| 1154 |
+
'paymentStatus' => 'Completed',
|
| 1155 |
+
'paymentDate' => $order->getCreatedAt(),
|
| 1156 |
+
'amount' => $status['downpayment_amount']
|
| 1157 |
+
);
|
| 1158 |
+
$order->getPayment()->setData('additional_information',$payment_info);
|
| 1159 |
+
$order->setData('state', "new");
|
| 1160 |
+
$order->setStatus("pending");
|
| 1161 |
+
//$order->addStatusToHistory("pending", 'Put your comment here', true);
|
| 1162 |
+
/* $history = Mage::getModel('sales/order_status_history')
|
| 1163 |
+
->setStatus("pending")
|
| 1164 |
+
->setComment('My Comment!')
|
| 1165 |
+
->setEntityName(Mage_Sales_Model_Order::HISTORY_ENTITY_NAME)
|
| 1166 |
+
->setIsCustomerNotified(false)
|
| 1167 |
+
->setCreatedAt(date('Y-m-d H:i:s', time() - 60*60*24));
|
| 1168 |
+
|
| 1169 |
+
$order->addStatusHistory($history); */
|
| 1170 |
+
$comments = $order->getStatusHistoryCollection(true);
|
| 1171 |
+
$com="Authorized amount of ".Mage::app()->getLocale()->currency($status['currency'])->toCurrency($status['downpayment_amount']).". Transaction ID: \"".$status['dp_paypal_txn_id']."\".";
|
| 1172 |
+
foreach ($comments as $c) {
|
| 1173 |
+
|
| 1174 |
+
$c->setStatus("complete");
|
| 1175 |
+
$c->setComment($com)->save();
|
| 1176 |
+
|
| 1177 |
+
}
|
| 1178 |
+
$order->save();
|
| 1179 |
+
$createdAt = Mage::helper('core')->formatDate($order->getCreatedAt(), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
|
| 1180 |
+
$newStr = '<div class="grid"><div class="hor-scroll"><table cellspacing=0 class="data"><thead><tr class="headings"><th colspan=2 class=" no-link" style="text-align: center;"><span class="nobr">Installment</span></th><th class=" no-link" style="text-align: center;"><span class="nobr">Date</span></th><th class=" no-link" style="text-align: center;"><span class="nobr">PayPal Transaction ID</span></th><th class=" no-link" style="text-align: center;"><span class="nobr">Status</span></th></tr></thead>';
|
| 1181 |
+
$newStr .= '<colgroup>
|
| 1182 |
+
<col width="100">
|
| 1183 |
+
<col width="75">
|
| 1184 |
+
<col width="183">
|
| 1185 |
+
<col width="183">
|
| 1186 |
+
<col width="98">
|
| 1187 |
+
</colgroup>';
|
| 1188 |
+
$months = (int)$status['months'];
|
| 1189 |
+
$newStr .= '<tbody><tr class="even" ><td style="text-align: center;"> DP: </td><td style="text-align: center;"> '.Mage::app()->getLocale()
|
| 1190 |
+
->currency($status['currency'])
|
| 1191 |
+
->toCurrency($status['downpayment_amount']).' </td>'.
|
| 1192 |
+
'<td style="text-align: center;"> '.$createdAt.' </td>'.
|
| 1193 |
+
'<td style="text-align: center;">'.$status['dp_paypal_txn_id'].'</td>'.
|
| 1194 |
+
'<td style="text-align: center;"> Completed </td></tr>';
|
| 1195 |
+
for($month=1;$month<=$months;$month++){
|
| 1196 |
+
$newStr .= '<tr ';
|
| 1197 |
+
if($month%2==0)
|
| 1198 |
+
$newStr .= 'class="even"';
|
| 1199 |
+
$newStr .= '>';
|
| 1200 |
+
$newStr .= '<td style="text-align: center;"> Month '.$month.': </td><td style="text-align: center;"> '.Mage::app()->getLocale()
|
| 1201 |
+
->currency($status['currency'])
|
| 1202 |
+
->toCurrency($status['payment_amounts']).' </td>';
|
| 1203 |
+
$date = date("Y-m-d h:i:s", strtotime($status['first_payment_due'] . " +".($month-1)." month"));
|
| 1204 |
+
$date = Mage::helper('core')->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
|
| 1205 |
+
$newStr .= '<td style="text-align: center;"> '.$date.' </td>';
|
| 1206 |
+
$newStr .= '<td style="text-align: center;"> </td>';
|
| 1207 |
+
$newStr .= '<td style="text-align: center;"> Pending </td></tr>';
|
| 1208 |
+
}
|
| 1209 |
+
$newStr .= '</tbody></table></div></div>';
|
| 1210 |
+
$model = Mage::getModel('laybuy/report')->setData($status)
|
| 1211 |
+
->setOrderId($status['custom'])
|
| 1212 |
+
->setStoreId($order->getStoreId())
|
| 1213 |
+
->setCreatedAt($order->getCreatedAt())
|
| 1214 |
+
->setStatus(0)
|
| 1215 |
+
->setReport($newStr)
|
| 1216 |
+
/* ->setTransaction(0) */
|
| 1217 |
+
->save();
|
| 1218 |
+
Mage::log('Response Array From LayBuy {{'.$str."}}", null, 'laybuy_success.log');
|
| 1219 |
+
}
|
| 1220 |
+
$session->addSuccess($this->__('Payment was recieved successfully.'));
|
| 1221 |
+
}catch(Exception $e){
|
| 1222 |
+
$status = array_change_key_case($this->getRequest()->getParams(),CASE_LOWER);
|
| 1223 |
+
if($status){
|
| 1224 |
+
$str = print_r($status, true);
|
| 1225 |
+
$session->addError($this->__('Payment Recieved.But transaction not saved please contact us.'));
|
| 1226 |
+
Mage::log('Exception Order of LayBuy {{'."Order_id=".$status['custom']."|".$status['errormessage']."|".'Response Array From LayBuy {{'.$status."}}"."}}", null, 'laybuy_failure.log');
|
| 1227 |
+
}else{
|
| 1228 |
+
$session->addError($this->__('Try Again Later.'));
|
| 1229 |
+
}
|
| 1230 |
+
}
|
| 1231 |
+
//$this->_redirect('checkout/onepage/success',array('_secure' => true));
|
| 1232 |
+
}
|
| 1233 |
+
public function returnAction()
|
| 1234 |
+
{
|
| 1235 |
+
try {
|
| 1236 |
+
$this->_initCheckout();
|
| 1237 |
+
$this->_checkout->returnFromPaypal($this->_initToken());
|
| 1238 |
+
$this->_redirect('*/*/review');
|
| 1239 |
+
return;
|
| 1240 |
+
}
|
| 1241 |
+
catch (Mage_Core_Exception $e) {
|
| 1242 |
+
Mage::getSingleton('checkout/session')->addError($e->getMessage());
|
| 1243 |
+
}
|
| 1244 |
+
catch (Exception $e) {
|
| 1245 |
+
Mage::getSingleton('checkout/session')->addError($this->__('Unable to process Express Checkout approval.'));
|
| 1246 |
+
Mage::logException($e);
|
| 1247 |
+
}
|
| 1248 |
+
$this->_redirect('checkout/cart');
|
| 1249 |
+
}
|
| 1250 |
+
public function _initToken(){
|
| 1251 |
+
return $this->_token;
|
| 1252 |
+
}
|
| 1253 |
+
/**
|
| 1254 |
+
* Get checkout method
|
| 1255 |
+
*
|
| 1256 |
+
* @return string
|
| 1257 |
+
*/
|
| 1258 |
+
public function getCheckoutMethod()
|
| 1259 |
+
{
|
| 1260 |
+
if ($this->getCustomerSession()->isLoggedIn()) {
|
| 1261 |
+
return Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER;
|
| 1262 |
+
}
|
| 1263 |
+
|
| 1264 |
+
if (!$this->_quote->getCheckoutMethod()) {
|
| 1265 |
+
if (Mage::helper('checkout')->isAllowedGuestCheckout($this->_quote)) {
|
| 1266 |
+
$this->_quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST);
|
| 1267 |
+
} else {
|
| 1268 |
+
$this->_quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER);
|
| 1269 |
+
}
|
| 1270 |
+
}
|
| 1271 |
+
return $this->_quote->getCheckoutMethod();
|
| 1272 |
+
}
|
| 1273 |
+
|
| 1274 |
+
/**
|
| 1275 |
+
* Set shipping method to quote, if needed
|
| 1276 |
+
* @param string $methodCode
|
| 1277 |
+
*/
|
| 1278 |
+
public function updateShippingMethod($methodCode)
|
| 1279 |
+
{
|
| 1280 |
+
if (!$this->_quote->getIsVirtual() && $shippingAddress = $this->_quote->getShippingAddress()) {
|
| 1281 |
+
if ($methodCode != $shippingAddress->getShippingMethod()) {
|
| 1282 |
+
$this->_ignoreAddressValidation();
|
| 1283 |
+
$shippingAddress->setShippingMethod($methodCode)->setCollectShippingRates(true);
|
| 1284 |
+
$this->_quote->collectTotals();
|
| 1285 |
+
}
|
| 1286 |
+
}
|
| 1287 |
+
}
|
| 1288 |
+
/**
|
| 1289 |
+
* Prepare quote for guest checkout order submit
|
| 1290 |
+
*
|
| 1291 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 1292 |
+
*/
|
| 1293 |
+
protected function _prepareGuestQuote()
|
| 1294 |
+
{
|
| 1295 |
+
$quote = $this->_quote;
|
| 1296 |
+
$quote->setCustomerId(null)
|
| 1297 |
+
->setCustomerEmail($quote->getBillingAddress()->getEmail())
|
| 1298 |
+
->setCustomerIsGuest(true)
|
| 1299 |
+
->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
| 1300 |
+
return $this;
|
| 1301 |
+
}
|
| 1302 |
+
/**
|
| 1303 |
+
* Checks if customer with email coming from Express checkout exists
|
| 1304 |
+
*
|
| 1305 |
+
* @return int
|
| 1306 |
+
*/
|
| 1307 |
+
protected function _lookupCustomerId()
|
| 1308 |
+
{
|
| 1309 |
+
return Mage::getModel('customer/customer')
|
| 1310 |
+
->setWebsiteId(Mage::app()->getWebsite()->getId())
|
| 1311 |
+
->loadByEmail($this->_quote->getCustomerEmail())
|
| 1312 |
+
->getId();
|
| 1313 |
+
}
|
| 1314 |
+
/**
|
| 1315 |
+
* Get customer session object
|
| 1316 |
+
*
|
| 1317 |
+
* @return Mage_Customer_Model_Session
|
| 1318 |
+
*/
|
| 1319 |
+
public function getCustomerSession()
|
| 1320 |
+
{
|
| 1321 |
+
return Mage::getSingleton('customer/session');
|
| 1322 |
+
}
|
| 1323 |
+
/**
|
| 1324 |
+
* Prepare quote for customer order submit
|
| 1325 |
+
*
|
| 1326 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 1327 |
+
*/
|
| 1328 |
+
protected function _prepareCustomerQuote()
|
| 1329 |
+
{
|
| 1330 |
+
$quote = $this->_quote;
|
| 1331 |
+
$billing = $quote->getBillingAddress();
|
| 1332 |
+
$shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
|
| 1333 |
+
|
| 1334 |
+
$customer = $this->getCustomerSession()->getCustomer();
|
| 1335 |
+
if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
|
| 1336 |
+
$customerBilling = $billing->exportCustomerAddress();
|
| 1337 |
+
$customer->addAddress($customerBilling);
|
| 1338 |
+
$billing->setCustomerAddress($customerBilling);
|
| 1339 |
+
}
|
| 1340 |
+
if ($shipping && ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling())
|
| 1341 |
+
|| (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook()))) {
|
| 1342 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
| 1343 |
+
$customer->addAddress($customerShipping);
|
| 1344 |
+
$shipping->setCustomerAddress($customerShipping);
|
| 1345 |
+
}
|
| 1346 |
+
|
| 1347 |
+
if (isset($customerBilling) && !$customer->getDefaultBilling()) {
|
| 1348 |
+
$customerBilling->setIsDefaultBilling(true);
|
| 1349 |
+
}
|
| 1350 |
+
if ($shipping && isset($customerBilling) && !$customer->getDefaultShipping() && $shipping->getSameAsBilling()) {
|
| 1351 |
+
$customerBilling->setIsDefaultShipping(true);
|
| 1352 |
+
} elseif ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) {
|
| 1353 |
+
$customerShipping->setIsDefaultShipping(true);
|
| 1354 |
+
}
|
| 1355 |
+
$quote->setCustomer($customer);
|
| 1356 |
+
|
| 1357 |
+
return $this;
|
| 1358 |
+
}
|
| 1359 |
+
|
| 1360 |
+
/**
|
| 1361 |
+
* Prepare quote for customer registration and customer order submit
|
| 1362 |
+
* and restore magento customer data from quote
|
| 1363 |
+
*
|
| 1364 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 1365 |
+
*/
|
| 1366 |
+
protected function _prepareNewCustomerQuote()
|
| 1367 |
+
{
|
| 1368 |
+
$quote = $this->_quote;
|
| 1369 |
+
$billing = $quote->getBillingAddress();
|
| 1370 |
+
$shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
|
| 1371 |
+
|
| 1372 |
+
$customerId = $this->_lookupCustomerId();
|
| 1373 |
+
if ($customerId) {
|
| 1374 |
+
$this->getCustomerSession()->loginById($customerId);
|
| 1375 |
+
return $this->_prepareCustomerQuote();
|
| 1376 |
+
}
|
| 1377 |
+
|
| 1378 |
+
$customer = $quote->getCustomer();
|
| 1379 |
+
/** @var $customer Mage_Customer_Model_Customer */
|
| 1380 |
+
$customerBilling = $billing->exportCustomerAddress();
|
| 1381 |
+
$customer->addAddress($customerBilling);
|
| 1382 |
+
$billing->setCustomerAddress($customerBilling);
|
| 1383 |
+
$customerBilling->setIsDefaultBilling(true);
|
| 1384 |
+
if ($shipping && !$shipping->getSameAsBilling()) {
|
| 1385 |
+
$customerShipping = $shipping->exportCustomerAddress();
|
| 1386 |
+
$customer->addAddress($customerShipping);
|
| 1387 |
+
$shipping->setCustomerAddress($customerShipping);
|
| 1388 |
+
$customerShipping->setIsDefaultShipping(true);
|
| 1389 |
+
} elseif ($shipping) {
|
| 1390 |
+
$customerBilling->setIsDefaultShipping(true);
|
| 1391 |
+
}
|
| 1392 |
+
/**
|
| 1393 |
+
* @todo integration with dynamica attributes customer_dob, customer_taxvat, customer_gender
|
| 1394 |
+
*/
|
| 1395 |
+
if ($quote->getCustomerDob() && !$billing->getCustomerDob()) {
|
| 1396 |
+
$billing->setCustomerDob($quote->getCustomerDob());
|
| 1397 |
+
}
|
| 1398 |
+
|
| 1399 |
+
if ($quote->getCustomerTaxvat() && !$billing->getCustomerTaxvat()) {
|
| 1400 |
+
$billing->setCustomerTaxvat($quote->getCustomerTaxvat());
|
| 1401 |
+
}
|
| 1402 |
+
|
| 1403 |
+
if ($quote->getCustomerGender() && !$billing->getCustomerGender()) {
|
| 1404 |
+
$billing->setCustomerGender($quote->getCustomerGender());
|
| 1405 |
+
}
|
| 1406 |
+
|
| 1407 |
+
Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer);
|
| 1408 |
+
$customer->setEmail($quote->getCustomerEmail());
|
| 1409 |
+
$customer->setPrefix($quote->getCustomerPrefix());
|
| 1410 |
+
$customer->setFirstname($quote->getCustomerFirstname());
|
| 1411 |
+
$customer->setMiddlename($quote->getCustomerMiddlename());
|
| 1412 |
+
$customer->setLastname($quote->getCustomerLastname());
|
| 1413 |
+
$customer->setSuffix($quote->getCustomerSuffix());
|
| 1414 |
+
$customer->setPassword($customer->decryptPassword($quote->getPasswordHash()));
|
| 1415 |
+
$customer->setPasswordHash($customer->hashPassword($customer->getPassword()));
|
| 1416 |
+
$customer->save();
|
| 1417 |
+
$quote->setCustomer($customer);
|
| 1418 |
+
|
| 1419 |
+
return $this;
|
| 1420 |
+
}
|
| 1421 |
+
/**
|
| 1422 |
+
* Involve new customer to system
|
| 1423 |
+
*
|
| 1424 |
+
* @return Mage_Paypal_Model_Express_Checkout
|
| 1425 |
+
*/
|
| 1426 |
+
protected function _involveNewCustomer()
|
| 1427 |
+
{
|
| 1428 |
+
$customer = $this->_quote->getCustomer();
|
| 1429 |
+
if ($customer->isConfirmationRequired()) {
|
| 1430 |
+
$customer->sendNewAccountEmail('confirmation');
|
| 1431 |
+
$url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
|
| 1432 |
+
$this->getCustomerSession()->addSuccess(
|
| 1433 |
+
Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.', $url)
|
| 1434 |
+
);
|
| 1435 |
+
} else {
|
| 1436 |
+
$customer->sendNewAccountEmail();
|
| 1437 |
+
$this->getCustomerSession()->loginById($customer->getId());
|
| 1438 |
+
}
|
| 1439 |
+
return $this;
|
| 1440 |
+
}
|
| 1441 |
+
|
| 1442 |
+
/**
|
| 1443 |
+
* Place the order and recurring payment profiles when customer returned from paypal
|
| 1444 |
+
* Until this moment all quote data must be valid
|
| 1445 |
+
*
|
| 1446 |
+
* @param string $token
|
| 1447 |
+
* @param string $shippingMethodCode
|
| 1448 |
+
*/
|
| 1449 |
+
public function place($token, $shippingMethodCode = null)
|
| 1450 |
+
{
|
| 1451 |
+
if ($shippingMethodCode) {
|
| 1452 |
+
$this->updateShippingMethod($shippingMethodCode);
|
| 1453 |
+
}
|
| 1454 |
+
|
| 1455 |
+
$isNewCustomer = false;
|
| 1456 |
+
switch ($this->getCheckoutMethod()) {
|
| 1457 |
+
case Mage_Checkout_Model_Type_Onepage::METHOD_GUEST:
|
| 1458 |
+
$this->_prepareGuestQuote();
|
| 1459 |
+
break;
|
| 1460 |
+
case Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER:
|
| 1461 |
+
$this->_prepareNewCustomerQuote();
|
| 1462 |
+
$isNewCustomer = true;
|
| 1463 |
+
break;
|
| 1464 |
+
default:
|
| 1465 |
+
$this->_prepareCustomerQuote();
|
| 1466 |
+
break;
|
| 1467 |
+
}
|
| 1468 |
+
|
| 1469 |
+
$this->_ignoreAddressValidation();
|
| 1470 |
+
$this->_quote->collectTotals();
|
| 1471 |
+
|
| 1472 |
+
$service = Mage::getModel('sales/service_quote', $this->_quote);
|
| 1473 |
+
|
| 1474 |
+
$service->submitAll();
|
| 1475 |
+
|
| 1476 |
+
|
| 1477 |
+
$this->_quote->save();
|
| 1478 |
+
|
| 1479 |
+
if ($isNewCustomer) {
|
| 1480 |
+
try {
|
| 1481 |
+
$this->_involveNewCustomer();
|
| 1482 |
+
} catch (Exception $e) {
|
| 1483 |
+
Mage::logException($e);
|
| 1484 |
+
}
|
| 1485 |
+
}
|
| 1486 |
+
|
| 1487 |
+
$this->_recurringPaymentProfiles = $service->getRecurringPaymentProfiles();
|
| 1488 |
+
// TODO: send recurring profile emails
|
| 1489 |
+
|
| 1490 |
+
$order = $service->getOrder();
|
| 1491 |
+
if (!$order) {
|
| 1492 |
+
return;
|
| 1493 |
+
}
|
| 1494 |
+
$this->_billingAgreement = $order->getPayment()->getBillingAgreement();
|
| 1495 |
+
|
| 1496 |
+
|
| 1497 |
+
// commence redirecting to finish payment, if paypal requires it
|
| 1498 |
+
|
| 1499 |
+
if ($order->getPayment()->getAdditionalInformation(
|
| 1500 |
+
'laybuy_express_checkout_redirect_required'
|
| 1501 |
+
)) {
|
| 1502 |
+
$this->_redirectUrl = $this->getExpressCheckoutCompleteUrl($token);
|
| 1503 |
+
}
|
| 1504 |
+
|
| 1505 |
+
switch ($order->getState()) {
|
| 1506 |
+
// even after placement paypal can disallow to authorize/capture, but will wait until bank transfers money
|
| 1507 |
+
case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
|
| 1508 |
+
// TODO
|
| 1509 |
+
break;
|
| 1510 |
+
// regular placement, when everything is ok
|
| 1511 |
+
case Mage_Sales_Model_Order::STATE_PROCESSING:
|
| 1512 |
+
case Mage_Sales_Model_Order::STATE_COMPLETE:
|
| 1513 |
+
case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW:
|
| 1514 |
+
$order->sendNewOrderEmail();
|
| 1515 |
+
break;
|
| 1516 |
+
}
|
| 1517 |
+
|
| 1518 |
+
$this->_order = $order;
|
| 1519 |
+
}
|
| 1520 |
+
/**
|
| 1521 |
+
* Get url for additional actions that PayPal may require customer to do after placing the order.
|
| 1522 |
+
* For instance, redirecting customer to bank for payment confirmation.
|
| 1523 |
+
*
|
| 1524 |
+
* @param string $token
|
| 1525 |
+
* @return string
|
| 1526 |
+
*/
|
| 1527 |
+
public function getExpressCheckoutCompleteUrl($token)
|
| 1528 |
+
{
|
| 1529 |
+
return $this->getLaybuyUrl(array(
|
| 1530 |
+
'cmd' => '_complete-express-checkout',
|
| 1531 |
+
'token' => $token,
|
| 1532 |
+
));
|
| 1533 |
+
}
|
| 1534 |
+
|
| 1535 |
+
/**
|
| 1536 |
+
* PayPal web URL generic getter
|
| 1537 |
+
*
|
| 1538 |
+
* @param array $params
|
| 1539 |
+
* @return string
|
| 1540 |
+
*/
|
| 1541 |
+
public function getLaybuyUrl(array $params = array())
|
| 1542 |
+
{
|
| 1543 |
+
/* return sprintf('https://www.%spaypal.com/cgi-bin/webscr%s',
|
| 1544 |
+
$this->sandboxFlag ? 'sandbox.' : '',
|
| 1545 |
+
$params ? '?' . http_build_query($params) : ''
|
| 1546 |
+
); */
|
| 1547 |
+
$url="http://lay-buys.com/expressgateway".'?' . http_build_query($params) ;
|
| 1548 |
+
return $url;
|
| 1549 |
+
}
|
| 1550 |
+
/**
|
| 1551 |
+
* Submit the order
|
| 1552 |
+
*/
|
| 1553 |
+
public function placeOrderAction()
|
| 1554 |
+
{
|
| 1555 |
+
|
| 1556 |
+
try {
|
| 1557 |
+
$requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds();
|
| 1558 |
+
if ($requiredAgreements) {
|
| 1559 |
+
$postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
|
| 1560 |
+
if (array_diff($requiredAgreements, $postedAgreements)) {
|
| 1561 |
+
Mage::throwException(Mage::helper('laybuy')->__('Please agree to all the terms and conditions before placing the order.'));
|
| 1562 |
+
}
|
| 1563 |
+
}
|
| 1564 |
+
|
| 1565 |
+
$this->_initCheckout();
|
| 1566 |
+
$this->place($this->_initToken());
|
| 1567 |
+
// prepare session to success or cancellation page
|
| 1568 |
+
$session = $this->_getCheckoutSession();
|
| 1569 |
+
$session->clearHelperData();
|
| 1570 |
+
|
| 1571 |
+
// "last successful quote"
|
| 1572 |
+
$quoteId = $this->_getQuote()->getId();
|
| 1573 |
+
$session->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId);
|
| 1574 |
+
|
| 1575 |
+
// an order may be created
|
| 1576 |
+
$order = $this->getOrder();
|
| 1577 |
+
if ($order) {
|
| 1578 |
+
$session->setLastOrderId($order->getId())
|
| 1579 |
+
->setLastRealOrderId($order->getIncrementId());
|
| 1580 |
+
// as well a billing agreement can be created
|
| 1581 |
+
$agreement = $this->getBillingAgreement();
|
| 1582 |
+
if ($agreement) {
|
| 1583 |
+
$session->setLastBillingAgreementId($agreement->getId());
|
| 1584 |
+
}
|
| 1585 |
+
}
|
| 1586 |
+
|
| 1587 |
+
// recurring profiles may be created along with the order or without it
|
| 1588 |
+
$profiles = $this->getRecurringPaymentProfiles();
|
| 1589 |
+
if ($profiles) {
|
| 1590 |
+
$ids = array();
|
| 1591 |
+
foreach($profiles as $profile) {
|
| 1592 |
+
$ids[] = $profile->getId();
|
| 1593 |
+
}
|
| 1594 |
+
$session->setLastRecurringProfileIds($ids);
|
| 1595 |
+
}
|
| 1596 |
+
|
| 1597 |
+
// redirect if PayPal specified some URL (for example, to Giropay bank)
|
| 1598 |
+
/* $url = $this->getRedirectUrl();
|
| 1599 |
+
if ($url) {
|
| 1600 |
+
$this->getResponse()->setRedirect($url);
|
| 1601 |
+
return;
|
| 1602 |
+
} */
|
| 1603 |
+
//$this->_initToken(false); // no need in token anymore
|
| 1604 |
+
$order_id=$order->getIncrementId();
|
| 1605 |
+
$this->success($order_id);
|
| 1606 |
+
$this->_redirect('checkout/onepage/success');
|
| 1607 |
+
return;
|
| 1608 |
+
}
|
| 1609 |
+
catch (Mage_Core_Exception $e) {
|
| 1610 |
+
$this->_getSession()->addError($e->getMessage());
|
| 1611 |
+
}
|
| 1612 |
+
catch (Exception $e) {
|
| 1613 |
+
$this->_getSession()->addError($this->__('Unable to place the order.'));
|
| 1614 |
+
Mage::logException($e);
|
| 1615 |
+
}
|
| 1616 |
+
$this->_redirect('*/*/review');
|
| 1617 |
+
}
|
| 1618 |
+
/**
|
| 1619 |
+
* Determine whether redirect somewhere specifically is required
|
| 1620 |
+
*
|
| 1621 |
+
* @return string
|
| 1622 |
+
*/
|
| 1623 |
+
public function getRedirectUrl()
|
| 1624 |
+
{
|
| 1625 |
+
return $this->_redirectUrl;
|
| 1626 |
+
}
|
| 1627 |
+
/**
|
| 1628 |
+
* PayPal session instance getter
|
| 1629 |
+
*
|
| 1630 |
+
* @return Mage_PayPal_Model_Session
|
| 1631 |
+
*/
|
| 1632 |
+
private function _getSession()
|
| 1633 |
+
{
|
| 1634 |
+
return Mage::getSingleton('core/session');
|
| 1635 |
+
}
|
| 1636 |
+
/**
|
| 1637 |
+
* Return recurring payment profiles
|
| 1638 |
+
*
|
| 1639 |
+
* @return array
|
| 1640 |
+
*/
|
| 1641 |
+
public function getRecurringPaymentProfiles()
|
| 1642 |
+
{
|
| 1643 |
+
return $this->_recurringPaymentProfiles;
|
| 1644 |
+
}
|
| 1645 |
+
/**
|
| 1646 |
+
* Get created billing agreement
|
| 1647 |
+
*
|
| 1648 |
+
* @return Mage_Sales_Model_Billing_Agreement|null
|
| 1649 |
+
*/
|
| 1650 |
+
public function getBillingAgreement()
|
| 1651 |
+
{
|
| 1652 |
+
return $this->_billingAgreement;
|
| 1653 |
+
}
|
| 1654 |
+
/**
|
| 1655 |
+
* Return order
|
| 1656 |
+
*
|
| 1657 |
+
* @return Mage_Sales_Model_Order
|
| 1658 |
+
*/
|
| 1659 |
+
public function getOrder()
|
| 1660 |
+
{
|
| 1661 |
+
return $this->_order;
|
| 1662 |
+
}
|
| 1663 |
+
public function reviewAction()
|
| 1664 |
+
{
|
| 1665 |
+
try {
|
| 1666 |
+
$this->_initCheckout();
|
| 1667 |
+
$this->prepareOrderReview($this->_initToken());
|
| 1668 |
+
$this->loadLayout();
|
| 1669 |
+
$this->_initLayoutMessages('paypal/session');
|
| 1670 |
+
$reviewBlock = $this->getLayout()->getBlock('laybuy.express.review');
|
| 1671 |
+
$reviewBlock->setQuote($this->_getQuote());
|
| 1672 |
+
$reviewBlock->getChild('details')->setQuote($this->_getQuote());
|
| 1673 |
+
if ($reviewBlock->getChild('shipping_method')) {
|
| 1674 |
+
$reviewBlock->getChild('shipping_method')->setQuote($this->_getQuote());
|
| 1675 |
+
}
|
| 1676 |
+
$this->renderLayout();
|
| 1677 |
+
return;
|
| 1678 |
+
}
|
| 1679 |
+
catch (Mage_Core_Exception $e) {
|
| 1680 |
+
Mage::getSingleton('checkout/session')->addError($e->getMessage());
|
| 1681 |
+
}
|
| 1682 |
+
catch (Exception $e) {
|
| 1683 |
+
Mage::getSingleton('checkout/session')->addError(
|
| 1684 |
+
$this->__('Unable to initialize Express Checkout review.')
|
| 1685 |
+
);
|
| 1686 |
+
Mage::logException($e);
|
| 1687 |
+
}
|
| 1688 |
+
$this->_redirect('checkout/cart');
|
| 1689 |
+
}
|
| 1690 |
+
/**
|
| 1691 |
+
* Update Order (combined action for ajax and regular request)
|
| 1692 |
+
*/
|
| 1693 |
+
public function updateOrderAction()
|
| 1694 |
+
{
|
| 1695 |
+
try {
|
| 1696 |
+
$isAjax = $this->getRequest()->getParam('isAjax');
|
| 1697 |
+
$this->_initCheckout();
|
| 1698 |
+
$this->updateOrders($this->getRequest()->getParams());
|
| 1699 |
+
if ($isAjax) {
|
| 1700 |
+
$this->loadLayout('laybuy_express_review_details');
|
| 1701 |
+
$this->getResponse()->setBody($this->getLayout()->getBlock('root')
|
| 1702 |
+
->setQuote($this->_getQuote())
|
| 1703 |
+
->toHtml());
|
| 1704 |
+
return;
|
| 1705 |
+
}
|
| 1706 |
+
} catch (Mage_Core_Exception $e) {
|
| 1707 |
+
$this->_getSession()->addError($e->getMessage());
|
| 1708 |
+
} catch (Exception $e) {
|
| 1709 |
+
$this->_getSession()->addError($this->__('Unable to update Order data.'));
|
| 1710 |
+
Mage::logException($e);
|
| 1711 |
+
}
|
| 1712 |
+
if ($isAjax) {
|
| 1713 |
+
$this->getResponse()->setBody('<script type="text/javascript">window.location.href = '
|
| 1714 |
+
. Mage::getUrl('*/*/review') . ';</script>');
|
| 1715 |
+
} else {
|
| 1716 |
+
$this->_redirect('*/*/review');
|
| 1717 |
+
}
|
| 1718 |
+
}
|
| 1719 |
+
/**
|
| 1720 |
+
* Update order data
|
| 1721 |
+
*
|
| 1722 |
+
* @param array $data
|
| 1723 |
+
*/
|
| 1724 |
+
public function updateOrders($data)
|
| 1725 |
+
{
|
| 1726 |
+
/** @var $checkout Mage_Checkout_Model_Type_Onepage */
|
| 1727 |
+
$checkout = Mage::getModel('checkout/type_onepage');
|
| 1728 |
+
|
| 1729 |
+
$this->_quote->setTotalsCollectedFlag(true);
|
| 1730 |
+
$checkout->setQuote($this->_quote);
|
| 1731 |
+
if (isset($data['billing'])) {
|
| 1732 |
+
if (isset($data['customer-email'])) {
|
| 1733 |
+
$data['billing']['email'] = $data['customer-email'];
|
| 1734 |
+
}
|
| 1735 |
+
$checkout->saveBilling($data['billing'], 0);
|
| 1736 |
+
}
|
| 1737 |
+
if (!$this->_quote->getIsVirtual() && isset($data['shipping'])) {
|
| 1738 |
+
$checkout->saveShipping($data['shipping'], 0);
|
| 1739 |
+
}
|
| 1740 |
+
|
| 1741 |
+
if (isset($data['shipping_method'])) {
|
| 1742 |
+
$this->updateShippingMethod($data['shipping_method']);
|
| 1743 |
+
}
|
| 1744 |
+
$this->_quote->setTotalsCollectedFlag(false);
|
| 1745 |
+
$this->_quote->collectTotals();
|
| 1746 |
+
$this->_quote->setDataChanges(true);
|
| 1747 |
+
$this->_quote->save();
|
| 1748 |
+
}
|
| 1749 |
+
|
| 1750 |
+
/**
|
| 1751 |
+
* Update Order (combined action for ajax and regular request)
|
| 1752 |
+
*/
|
| 1753 |
+
public function updateShippingMethodsAction()
|
| 1754 |
+
{
|
| 1755 |
+
try {
|
| 1756 |
+
$this->_initCheckout();
|
| 1757 |
+
$this->prepareOrderReview($this->_initToken());
|
| 1758 |
+
$this->loadLayout('laybuy_express_review');
|
| 1759 |
+
|
| 1760 |
+
$this->getResponse()->setBody($this->getLayout()->getBlock('express.review.shipping.method')
|
| 1761 |
+
->setQuote($this->_getQuote())
|
| 1762 |
+
->toHtml());
|
| 1763 |
+
return;
|
| 1764 |
+
} catch (Mage_Core_Exception $e) {
|
| 1765 |
+
$this->_getSession()->addError($e->getMessage());
|
| 1766 |
+
} catch (Exception $e) {
|
| 1767 |
+
$this->_getSession()->addError($this->__('Unable to update Order data.'));
|
| 1768 |
+
Mage::logException($e);
|
| 1769 |
+
}
|
| 1770 |
+
$this->getResponse()->setBody('<script type="text/javascript">window.location.href = '
|
| 1771 |
+
. Mage::getUrl('*/*/review') . ';</script>');
|
| 1772 |
+
}
|
| 1773 |
+
|
| 1774 |
+
/**
|
| 1775 |
+
* Check whether order review has enough data to initialize
|
| 1776 |
+
*
|
| 1777 |
+
* @param $token
|
| 1778 |
+
* @throws Mage_Core_Exception
|
| 1779 |
+
*/
|
| 1780 |
+
public function prepareOrderReview($token = null)
|
| 1781 |
+
{
|
| 1782 |
+
$payment = $this->_quote->getPayment();
|
| 1783 |
+
if (!$payment || !$payment->getAdditionalInformation("laybuy_express_checkout_payer_id")) {
|
| 1784 |
+
Mage::throwException(Mage::helper('laybuy')->__('Payer is not identified.'));
|
| 1785 |
+
}
|
| 1786 |
+
$this->_quote->setMayEditShippingAddress(
|
| 1787 |
+
1 != $this->_quote->getPayment()->getAdditionalInformation('laybuy_express_checkout_shipping_overriden')
|
| 1788 |
+
);
|
| 1789 |
+
$this->_quote->setMayEditShippingMethod(
|
| 1790 |
+
'' == $this->_quote->getPayment()->getAdditionalInformation('laybuy_express_checkout_shipping_method')
|
| 1791 |
+
);
|
| 1792 |
+
$this->_ignoreAddressValidation();
|
| 1793 |
+
$this->_quote->collectTotals()->save();
|
| 1794 |
+
}
|
| 1795 |
+
|
| 1796 |
+
private function _initCheckout()
|
| 1797 |
+
{
|
| 1798 |
+
$quote = $this->_getQuote();
|
| 1799 |
+
if (!$quote->hasItems() || $quote->getHasError()) {
|
| 1800 |
+
$this->getResponse()->setHeader('HTTP/1.1','403 Forbidden');
|
| 1801 |
+
Mage::throwException(Mage::helper('laybuy')->__('Unable to initialize Express Checkout.'));
|
| 1802 |
+
}
|
| 1803 |
+
|
| 1804 |
+
$this->_checkout = Mage::getSingleton($this->_checkoutType, array(
|
| 1805 |
+
'quote' => $quote,
|
| 1806 |
+
));
|
| 1807 |
+
}
|
| 1808 |
+
public function cancelAction()
|
| 1809 |
+
{
|
| 1810 |
+
try {
|
| 1811 |
+
//$this->_initToken(false);
|
| 1812 |
+
$this->_token=null;
|
| 1813 |
+
// TODO verify if this logic of order cancelation is deprecated
|
| 1814 |
+
// if there is an order - cancel it
|
| 1815 |
+
$orderId = $this->_getCheckoutSession()->getLastOrderId();
|
| 1816 |
+
$order = ($orderId) ? Mage::getModel('sales/order')->load($orderId) : false;
|
| 1817 |
+
if ($order && $order->getId() && $order->getQuoteId() == $this->_getCheckoutSession()->getQuoteId()) {
|
| 1818 |
+
$order->cancel()->save();
|
| 1819 |
+
$this->_getCheckoutSession()
|
| 1820 |
+
->unsLastQuoteId()
|
| 1821 |
+
->unsLastSuccessQuoteId()
|
| 1822 |
+
->unsLastOrderId()
|
| 1823 |
+
->unsLastRealOrderId()
|
| 1824 |
+
->addSuccess($this->__('Laybuy Express Checkout and Order have been canceled.'))
|
| 1825 |
+
;
|
| 1826 |
+
} else {
|
| 1827 |
+
$this->_getCheckoutSession()->addSuccess($this->__('Laybuy Express Checkout has been canceled.'));
|
| 1828 |
+
}
|
| 1829 |
+
} catch (Mage_Core_Exception $e) {
|
| 1830 |
+
$this->_getCheckoutSession()->addError($e->getMessage());
|
| 1831 |
+
} catch (Exception $e) {
|
| 1832 |
+
$this->_getCheckoutSession()->addError($this->__('Unable to cancel Laybuy Express Checkout.'));
|
| 1833 |
+
Mage::logException($e);
|
| 1834 |
+
}
|
| 1835 |
+
|
| 1836 |
+
$this->_redirect('checkout/cart');
|
| 1837 |
+
}
|
| 1838 |
+
|
| 1839 |
+
}
|
| 1840 |
+
|
| 1841 |
+
?>
|
app/code/local/Ced/LayBuy/etc/config.xml
CHANGED
|
@@ -1,189 +1,213 @@
|
|
| 1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
-
<config>
|
| 3 |
-
<modules>
|
| 4 |
-
<Ced_LayBuy>
|
| 5 |
-
<version>1.0.
|
| 6 |
-
<author>ASHEESH SINGH (asheeshsingh@cedcoss.com)</author>
|
| 7 |
-
</Ced_LayBuy>
|
| 8 |
-
</modules>
|
| 9 |
-
<admin>
|
| 10 |
-
<routers>
|
| 11 |
-
<laybuy>
|
| 12 |
-
<use>admin</use>
|
| 13 |
-
<args>
|
| 14 |
-
<module>Ced_LayBuy</module>
|
| 15 |
-
<frontName>laybuy</frontName>
|
| 16 |
-
</args>
|
| 17 |
-
</laybuy>
|
| 18 |
-
</routers>
|
| 19 |
-
</admin>
|
| 20 |
-
<adminhtml>
|
| 21 |
-
<translate>
|
| 22 |
-
<modules>
|
| 23 |
-
<Ced_LayBuy>
|
| 24 |
-
<files>
|
| 25 |
-
<default>Ced_LayBuy.csv</default>
|
| 26 |
-
</files>
|
| 27 |
-
</Ced_LayBuy>
|
| 28 |
-
</modules>
|
| 29 |
-
</translate>
|
| 30 |
-
<layout>
|
| 31 |
-
<updates>
|
| 32 |
-
<laybuy>
|
| 33 |
-
<file>laybuy.xml</file>
|
| 34 |
-
</laybuy>
|
| 35 |
-
</updates>
|
| 36 |
-
</layout>
|
| 37 |
-
</adminhtml>
|
| 38 |
-
<frontend>
|
| 39 |
-
<routers>
|
| 40 |
-
<laybuy>
|
| 41 |
-
<use>standard</use>
|
| 42 |
-
<args>
|
| 43 |
-
<module>Ced_LayBuy</module>
|
| 44 |
-
<frontName>laybuy</frontName>
|
| 45 |
-
</args>
|
| 46 |
-
</laybuy>
|
| 47 |
-
</routers>
|
| 48 |
-
<layout>
|
| 49 |
-
<updates>
|
| 50 |
-
<laybuy>
|
| 51 |
-
<file>laybuy.xml</file>
|
| 52 |
-
</laybuy>
|
| 53 |
-
</updates>
|
| 54 |
-
</layout>
|
| 55 |
-
<translate>
|
| 56 |
-
<modules>
|
| 57 |
-
<Ced_LayBuy>
|
| 58 |
-
<files>
|
| 59 |
-
<default>Ced_LayBuy.csv</default>
|
| 60 |
-
</files>
|
| 61 |
-
</Ced_LayBuy>
|
| 62 |
-
</modules>
|
| 63 |
-
</translate>
|
| 64 |
-
</frontend>
|
| 65 |
-
<global>
|
| 66 |
-
<fieldsets>
|
| 67 |
-
<sales_convert_quote_payment>
|
| 68 |
-
<laybuy_init>
|
| 69 |
-
<to_order_payment>*</to_order_payment>
|
| 70 |
-
</laybuy_init>
|
| 71 |
-
<laybuy_months>
|
| 72 |
-
<to_order_payment>*</to_order_payment>
|
| 73 |
-
</laybuy_months>
|
| 74 |
-
</sales_convert_quote_payment>
|
| 75 |
-
</fieldsets>
|
| 76 |
-
<models>
|
| 77 |
-
<
|
| 78 |
-
<
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
<
|
| 102 |
-
<
|
| 103 |
-
<
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
<
|
| 125 |
-
<
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
<
|
| 144 |
-
<
|
| 145 |
-
<
|
| 146 |
-
<
|
| 147 |
-
<
|
| 148 |
-
<
|
| 149 |
-
<
|
| 150 |
-
<
|
| 151 |
-
<
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
<
|
| 157 |
-
<
|
| 158 |
-
<
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
<
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
</
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Ced_LayBuy>
|
| 5 |
+
<version>1.0.1</version>
|
| 6 |
+
<author>ASHEESH SINGH (asheeshsingh@cedcoss.com)</author>
|
| 7 |
+
</Ced_LayBuy>
|
| 8 |
+
</modules>
|
| 9 |
+
<admin>
|
| 10 |
+
<routers>
|
| 11 |
+
<laybuy>
|
| 12 |
+
<use>admin</use>
|
| 13 |
+
<args>
|
| 14 |
+
<module>Ced_LayBuy</module>
|
| 15 |
+
<frontName>laybuy</frontName>
|
| 16 |
+
</args>
|
| 17 |
+
</laybuy>
|
| 18 |
+
</routers>
|
| 19 |
+
</admin>
|
| 20 |
+
<adminhtml>
|
| 21 |
+
<translate>
|
| 22 |
+
<modules>
|
| 23 |
+
<Ced_LayBuy>
|
| 24 |
+
<files>
|
| 25 |
+
<default>Ced_LayBuy.csv</default>
|
| 26 |
+
</files>
|
| 27 |
+
</Ced_LayBuy>
|
| 28 |
+
</modules>
|
| 29 |
+
</translate>
|
| 30 |
+
<layout>
|
| 31 |
+
<updates>
|
| 32 |
+
<laybuy>
|
| 33 |
+
<file>laybuy.xml</file>
|
| 34 |
+
</laybuy>
|
| 35 |
+
</updates>
|
| 36 |
+
</layout>
|
| 37 |
+
</adminhtml>
|
| 38 |
+
<frontend>
|
| 39 |
+
<routers>
|
| 40 |
+
<laybuy>
|
| 41 |
+
<use>standard</use>
|
| 42 |
+
<args>
|
| 43 |
+
<module>Ced_LayBuy</module>
|
| 44 |
+
<frontName>laybuy</frontName>
|
| 45 |
+
</args>
|
| 46 |
+
</laybuy>
|
| 47 |
+
</routers>
|
| 48 |
+
<layout>
|
| 49 |
+
<updates>
|
| 50 |
+
<laybuy>
|
| 51 |
+
<file>laybuy.xml</file>
|
| 52 |
+
</laybuy>
|
| 53 |
+
</updates>
|
| 54 |
+
</layout>
|
| 55 |
+
<translate>
|
| 56 |
+
<modules>
|
| 57 |
+
<Ced_LayBuy>
|
| 58 |
+
<files>
|
| 59 |
+
<default>Ced_LayBuy.csv</default>
|
| 60 |
+
</files>
|
| 61 |
+
</Ced_LayBuy>
|
| 62 |
+
</modules>
|
| 63 |
+
</translate>
|
| 64 |
+
</frontend>
|
| 65 |
+
<global>
|
| 66 |
+
<fieldsets>
|
| 67 |
+
<sales_convert_quote_payment>
|
| 68 |
+
<laybuy_init>
|
| 69 |
+
<to_order_payment>*</to_order_payment>
|
| 70 |
+
</laybuy_init>
|
| 71 |
+
<laybuy_months>
|
| 72 |
+
<to_order_payment>*</to_order_payment>
|
| 73 |
+
</laybuy_months>
|
| 74 |
+
</sales_convert_quote_payment>
|
| 75 |
+
</fieldsets>
|
| 76 |
+
<models>
|
| 77 |
+
<!-- <directory_mysql4>
|
| 78 |
+
<rewrite>
|
| 79 |
+
<region_collection>Ced_Laybuy_Model_Mysql4_Region_Collection</region_collection>
|
| 80 |
+
</rewrite>
|
| 81 |
+
</directory_mysql4>-->
|
| 82 |
+
<laybuy>
|
| 83 |
+
<class>Ced_LayBuy_Model</class>
|
| 84 |
+
<resourceModel>laybuy_mysql4</resourceModel>
|
| 85 |
+
</laybuy>
|
| 86 |
+
<laybuy_mysql4>
|
| 87 |
+
<class>Ced_LayBuy_Model_Mysql4</class>
|
| 88 |
+
<entities>
|
| 89 |
+
<report>
|
| 90 |
+
<table>laybuy_transaction_report</table>
|
| 91 |
+
</report>
|
| 92 |
+
<revise>
|
| 93 |
+
<table>laybuy_revise_request_report</table>
|
| 94 |
+
</revise>
|
| 95 |
+
<laybuyresp>
|
| 96 |
+
<table>laybuy_final_response</table>
|
| 97 |
+
</laybuyresp>
|
| 98 |
+
</entities>
|
| 99 |
+
</laybuy_mysql4>
|
| 100 |
+
</models>
|
| 101 |
+
<resources>
|
| 102 |
+
<laybuy_setup>
|
| 103 |
+
<setup>
|
| 104 |
+
<module>Ced_LayBuy</module>
|
| 105 |
+
<class>Ced_LayBuy_Model_Mysql4_Setup</class>
|
| 106 |
+
</setup>
|
| 107 |
+
</laybuy_setup>
|
| 108 |
+
</resources>
|
| 109 |
+
<helpers>
|
| 110 |
+
<laybuy>
|
| 111 |
+
<class>Ced_LayBuy_Helper</class>
|
| 112 |
+
</laybuy>
|
| 113 |
+
</helpers>
|
| 114 |
+
<blocks>
|
| 115 |
+
<laybuy>
|
| 116 |
+
<class>Ced_LayBuy_Block</class>
|
| 117 |
+
</laybuy>
|
| 118 |
+
</blocks>
|
| 119 |
+
<events>
|
| 120 |
+
<payment_info_block_prepare_specific_information>
|
| 121 |
+
<observers>
|
| 122 |
+
<laybuy_payment_info>
|
| 123 |
+
<type>model</type>
|
| 124 |
+
<class>laybuy/observer</class>
|
| 125 |
+
<method>paymentInfoBlockPrepareSpecificInformation</method>
|
| 126 |
+
</laybuy_payment_info>
|
| 127 |
+
</observers>
|
| 128 |
+
</payment_info_block_prepare_specific_information>
|
| 129 |
+
<order_cancel_after>
|
| 130 |
+
<observers>
|
| 131 |
+
<laybuy_order_cancel>
|
| 132 |
+
<type>model</type>
|
| 133 |
+
<class>laybuy/observer</class>
|
| 134 |
+
<method>orderCancelAfter</method>
|
| 135 |
+
</laybuy_order_cancel>
|
| 136 |
+
</observers>
|
| 137 |
+
</order_cancel_after>
|
| 138 |
+
</events>
|
| 139 |
+
</global>
|
| 140 |
+
<default>
|
| 141 |
+
<payment>
|
| 142 |
+
<laybuy>
|
| 143 |
+
<model>laybuy/standard</model><!-- very important thing, here you select the model for your payment method -->
|
| 144 |
+
<active>1</active>
|
| 145 |
+
<order_status>pending</order_status>
|
| 146 |
+
<title>Lay-Buy</title>
|
| 147 |
+
<payment_action>sale</payment_action>
|
| 148 |
+
<submit_url>http://lay-buys.com/gateway/</submit_url>
|
| 149 |
+
<multipledesc>1</multipledesc>
|
| 150 |
+
<desc>Description of products / services</desc>
|
| 151 |
+
<mind>20%</mind>
|
| 152 |
+
<maxd>50%</maxd>
|
| 153 |
+
<months>3</months>
|
| 154 |
+
<adminfee>0</adminfee>
|
| 155 |
+
<ftp_ip>https://lay-buys.com/report/</ftp_ip>
|
| 156 |
+
<allowspecific>0</allowspecific>
|
| 157 |
+
<sort_order>1</sort_order>
|
| 158 |
+
<bypasslaybuy>1</bypasslaybuy>
|
| 159 |
+
<cronenabled>0</cronenabled>
|
| 160 |
+
</laybuy>
|
| 161 |
+
<laybuy_express>
|
| 162 |
+
<model>laybuy/express</model>
|
| 163 |
+
<active>1</active>
|
| 164 |
+
<title>Laybuy Express Checkout</title>
|
| 165 |
+
<payment_action>Authorization</payment_action>
|
| 166 |
+
<solution_type>Mark</solution_type>
|
| 167 |
+
<line_items_enabled>1</line_items_enabled>
|
| 168 |
+
<visible_on_cart>1</visible_on_cart>
|
| 169 |
+
<visible_on_product>1</visible_on_product>
|
| 170 |
+
<allow_ba_signup>never</allow_ba_signup>
|
| 171 |
+
<group>paypal</group>
|
| 172 |
+
<authorization_honor_period>3</authorization_honor_period>
|
| 173 |
+
<order_valid_period>29</order_valid_period>
|
| 174 |
+
<child_authorization_number>1</child_authorization_number>
|
| 175 |
+
<verify_peer>1</verify_peer>
|
| 176 |
+
</laybuy_express>
|
| 177 |
+
</payment>
|
| 178 |
+
<laybuy>
|
| 179 |
+
<conditional_criteria>
|
| 180 |
+
<total>0</total>
|
| 181 |
+
<allowspecificcategory>0</allowspecificcategory>
|
| 182 |
+
<allowspecificgroup>0</allowspecificgroup>
|
| 183 |
+
</conditional_criteria>
|
| 184 |
+
<fetch_reports>
|
| 185 |
+
<schedule>1</schedule>
|
| 186 |
+
<time>00,00,00</time>
|
| 187 |
+
</fetch_reports>
|
| 188 |
+
</laybuy>
|
| 189 |
+
</default>
|
| 190 |
+
<crontab>
|
| 191 |
+
<jobs>
|
| 192 |
+
<LayBuy_Cron_Check>
|
| 193 |
+
<schedule>
|
| 194 |
+
<cron_expr>* * * * *</cron_expr>
|
| 195 |
+
</schedule>
|
| 196 |
+
<run>
|
| 197 |
+
<model>laybuy/Observer::checkCron</model>
|
| 198 |
+
|
| 199 |
+
</run>
|
| 200 |
+
</LayBuy_Cron_Check>
|
| 201 |
+
<LayBuy_Automated_Fetch_Updates>
|
| 202 |
+
<schedule>
|
| 203 |
+
|
| 204 |
+
<config_path>crontab/jobs/LayBuy_Automated_Fetch_Updates/schedule/cron_expr</config_path>
|
| 205 |
+
</schedule>
|
| 206 |
+
<run>
|
| 207 |
+
<model>laybuy/Observer::fetchUpdates</model>
|
| 208 |
+
|
| 209 |
+
</run>
|
| 210 |
+
</LayBuy_Automated_Fetch_Updates>
|
| 211 |
+
</jobs>
|
| 212 |
+
</crontab>
|
| 213 |
+
</config>
|
app/code/local/Ced/LayBuy/etc/system.xml
CHANGED
|
@@ -1,279 +1,297 @@
|
|
| 1 |
-
<?xml version="1.0"?>
|
| 2 |
-
<config>
|
| 3 |
-
<sections>
|
| 4 |
-
<payment>
|
| 5 |
-
<groups>
|
| 6 |
-
<laybuy translate="label comment" module="laybuy">
|
| 7 |
-
<label>PUT IT ON LAY-BUY (powered by PayPal)</label>
|
| 8 |
-
<frontend_type>text</frontend_type>
|
| 9 |
-
<sort_order>999</sort_order>
|
| 10 |
-
<show_in_default>1</show_in_default>
|
| 11 |
-
<show_in_website>1</show_in_website>
|
| 12 |
-
<show_in_store>1</show_in_store>
|
| 13 |
-
<fields>
|
| 14 |
-
<active translate="label comment">
|
| 15 |
-
<label>Enabled</label>
|
| 16 |
-
<frontend_type>select</frontend_type>
|
| 17 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 18 |
-
<sort_order>10</sort_order>
|
| 19 |
-
<show_in_default>1</show_in_default>
|
| 20 |
-
<show_in_website>1</show_in_website>
|
| 21 |
-
<show_in_store>0</show_in_store>
|
| 22 |
-
</active>
|
| 23 |
-
<title translate="label comment">
|
| 24 |
-
<label>Title</label>
|
| 25 |
-
<frontend_type>text</frontend_type>
|
| 26 |
-
<sort_order>20</sort_order>
|
| 27 |
-
<show_in_default>1</show_in_default>
|
| 28 |
-
<show_in_website>1</show_in_website>
|
| 29 |
-
<show_in_store>1</show_in_store>
|
| 30 |
-
</title>
|
| 31 |
-
<order_status translate="label comment">
|
| 32 |
-
<label>New Order Status</label>
|
| 33 |
-
<frontend_type>select</frontend_type>
|
| 34 |
-
<source_model>adminhtml/system_config_source_order_status</source_model>
|
| 35 |
-
<sort_order>51</sort_order>
|
| 36 |
-
<show_in_default>1</show_in_default>
|
| 37 |
-
<show_in_website>1</show_in_website>
|
| 38 |
-
<show_in_store>0</show_in_store>
|
| 39 |
-
</order_status>
|
| 40 |
-
<submit_url translate="label comment">
|
| 41 |
-
<label>Gateway URL</label>
|
| 42 |
-
<frontend_type>text</frontend_type>
|
| 43 |
-
<sort_order>58</sort_order>
|
| 44 |
-
<show_in_default>1</show_in_default>
|
| 45 |
-
<show_in_website>0</show_in_website>
|
| 46 |
-
<show_in_store>0</show_in_store>
|
| 47 |
-
</submit_url>
|
| 48 |
-
<membership_number translate="label comment">
|
| 49 |
-
<label>Lay-Buys Membership Number</label>
|
| 50 |
-
<frontend_type>password</frontend_type>
|
| 51 |
-
<sort_order>59</sort_order>
|
| 52 |
-
<show_in_default>1</show_in_default>
|
| 53 |
-
<show_in_website>1</show_in_website>
|
| 54 |
-
<show_in_store>0</show_in_store>
|
| 55 |
-
</membership_number>
|
| 56 |
-
<multipledesc translate="label comment">
|
| 57 |
-
<label>Line Items Description</label>
|
| 58 |
-
<frontend_type>select</frontend_type>
|
| 59 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 60 |
-
<sort_order>60</sort_order>
|
| 61 |
-
<show_in_default>1</show_in_default>
|
| 62 |
-
<show_in_website>1</show_in_website>
|
| 63 |
-
<show_in_store>1</show_in_store>
|
| 64 |
-
</multipledesc>
|
| 65 |
-
<desc translate="label comment">
|
| 66 |
-
<label>Description</label>
|
| 67 |
-
<frontend_type>textarea</frontend_type>
|
| 68 |
-
<sort_order>61</sort_order>
|
| 69 |
-
<show_in_default>1</show_in_default>
|
| 70 |
-
<show_in_website>1</show_in_website>
|
| 71 |
-
<show_in_store>1</show_in_store>
|
| 72 |
-
<depends><multipledesc>0</multipledesc></depends>
|
| 73 |
-
<comment>Description of products / services</comment>
|
| 74 |
-
</desc>
|
| 75 |
-
<mind translate="label comment">
|
| 76 |
-
<label>Minimum</label>
|
| 77 |
-
<frontend_type>text</frontend_type>
|
| 78 |
-
<sort_order>62</sort_order>
|
| 79 |
-
<show_in_default>1</show_in_default>
|
| 80 |
-
<show_in_website>1</show_in_website>
|
| 81 |
-
<show_in_store>1</show_in_store>
|
| 82 |
-
<comment>Minimum Deposit Amount (defaults to 20%)</comment>
|
| 83 |
-
</mind>
|
| 84 |
-
<maxd translate="label comment">
|
| 85 |
-
<label>Maximum</label>
|
| 86 |
-
<frontend_type>text</frontend_type>
|
| 87 |
-
<sort_order>63</sort_order>
|
| 88 |
-
<show_in_default>1</show_in_default>
|
| 89 |
-
<show_in_website>1</show_in_website>
|
| 90 |
-
<show_in_store>1</show_in_store>
|
| 91 |
-
<comment>Maximum Deposit Amount (defaults to 50%)</comment>
|
| 92 |
-
</maxd>
|
| 93 |
-
<months translate="label comment">
|
| 94 |
-
<label>Months</label>
|
| 95 |
-
<frontend_type>text</frontend_type>
|
| 96 |
-
<sort_order>64</sort_order>
|
| 97 |
-
<show_in_default>1</show_in_default>
|
| 98 |
-
<show_in_website>1</show_in_website>
|
| 99 |
-
<show_in_store>1</show_in_store>
|
| 100 |
-
<comment>Maximum Number of Months to pay Balance (defaults to 3)</comment>
|
| 101 |
-
</months>
|
| 102 |
-
<adminfee translate="label comment">
|
| 103 |
-
<label>Show Lay-Buy Fee in Description</label>
|
| 104 |
-
<frontend_type>select</frontend_type>
|
| 105 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 106 |
-
<sort_order>65</sort_order>
|
| 107 |
-
<show_in_default>1</show_in_default>
|
| 108 |
-
<show_in_website>1</show_in_website>
|
| 109 |
-
<show_in_store>0</show_in_store>
|
| 110 |
-
<comment><![CDATA[ This payment option attracts a 0.9% surcharge. For more detail please login to <a href="https://www.lay-buys.com/vtmob/login/" target="_blank" title="https://www.lay-buys.com/vtmob/login/">merchant panel</a> using your merchant credentials.]]></comment>
|
| 111 |
-
</adminfee>
|
| 112 |
-
<conditional_criteria_total translate="label comment">
|
| 113 |
-
<label>Minimum Cart Total</label>
|
| 114 |
-
<config_path>laybuy/conditional_criteria/total</config_path>
|
| 115 |
-
<frontend_type>text</frontend_type>
|
| 116 |
-
<comment>The checkout total the order must reach before this payment method becomes active.</comment>
|
| 117 |
-
<sort_order>67</sort_order>
|
| 118 |
-
<show_in_default>1</show_in_default>
|
| 119 |
-
<show_in_website>1</show_in_website>
|
| 120 |
-
<show_in_store>1</show_in_store>
|
| 121 |
-
<shared>1</shared>
|
| 122 |
-
</conditional_criteria_total>
|
| 123 |
-
<allowspecificcategory translate="label comment">
|
| 124 |
-
<label>Allowed Categories</label>
|
| 125 |
-
<config_path>laybuy/conditional_criteria/allowspecificcategory</config_path>
|
| 126 |
-
<frontend_type>select</frontend_type>
|
| 127 |
-
<sort_order>69</sort_order>
|
| 128 |
-
<source_model>laybuy/system_config_source_allowspecificcategory</source_model>
|
| 129 |
-
<show_in_default>1</show_in_default>
|
| 130 |
-
<show_in_website>1</show_in_website>
|
| 131 |
-
<show_in_store>1</show_in_store>
|
| 132 |
-
</allowspecificcategory>
|
| 133 |
-
<conditional_criteria_category translate="comment">
|
| 134 |
-
<config_path>laybuy/conditional_criteria/categories</config_path>
|
| 135 |
-
<frontend_type>multiselect</frontend_type>
|
| 136 |
-
<source_model>laybuy/system_config_source_categories</source_model>
|
| 137 |
-
<can_be_empty>1</can_be_empty>
|
| 138 |
-
<comment>The checkout products of the orders must be in these categories before this payment method becomes active.</comment>
|
| 139 |
-
<sort_order>71</sort_order>
|
| 140 |
-
<depends><allowspecificcategory>1</allowspecificcategory></depends>
|
| 141 |
-
<show_in_default>1</show_in_default>
|
| 142 |
-
<show_in_website>1</show_in_website>
|
| 143 |
-
<show_in_store>1</show_in_store>
|
| 144 |
-
<shared>1</shared>
|
| 145 |
-
</conditional_criteria_category>
|
| 146 |
-
<allowspecificgroup translate="label comment">
|
| 147 |
-
<label>Allowed Customer Groups</label>
|
| 148 |
-
<config_path>laybuy/conditional_criteria/allowspecificgroup</config_path>
|
| 149 |
-
<frontend_type>select</frontend_type>
|
| 150 |
-
<sort_order>72</sort_order>
|
| 151 |
-
<source_model>laybuy/system_config_source_allowspecificgroup</source_model>
|
| 152 |
-
<show_in_default>1</show_in_default>
|
| 153 |
-
<show_in_website>1</show_in_website>
|
| 154 |
-
<show_in_store>1</show_in_store>
|
| 155 |
-
</allowspecificgroup>
|
| 156 |
-
<conditional_criteria_customergroup translate="comment">
|
| 157 |
-
<config_path>laybuy/conditional_criteria/customergroup</config_path>
|
| 158 |
-
<frontend_type>multiselect</frontend_type>
|
| 159 |
-
<source_model>laybuy/system_config_source_groups</source_model>
|
| 160 |
-
<comment>The checkout customer must be in these customer groups before this payment method becomes active.</comment>
|
| 161 |
-
<sort_order>73</sort_order>
|
| 162 |
-
<depends><allowspecificgroup>1</allowspecificgroup></depends>
|
| 163 |
-
<show_in_default>1</show_in_default>
|
| 164 |
-
<show_in_website>1</show_in_website>
|
| 165 |
-
<show_in_store>1</show_in_store>
|
| 166 |
-
<shared>1</shared>
|
| 167 |
-
</conditional_criteria_customergroup>
|
| 168 |
-
<conditional_criteria_exclude_products translate="label comment">
|
| 169 |
-
<label>Excluded Product Ids</label>
|
| 170 |
-
<config_path>laybuy/conditional_criteria/xproducts</config_path>
|
| 171 |
-
<frontend_type>textarea</frontend_type>
|
| 172 |
-
<can_be_empty>1</can_be_empty>
|
| 173 |
-
<comment>Add product ids separated by comma(,) for which method will not available.</comment>
|
| 174 |
-
<sort_order>75</sort_order>
|
| 175 |
-
<show_in_default>1</show_in_default>
|
| 176 |
-
<show_in_website>1</show_in_website>
|
| 177 |
-
<show_in_store>1</show_in_store>
|
| 178 |
-
<shared>1</shared>
|
| 179 |
-
</conditional_criteria_exclude_products>
|
| 180 |
-
<image translate="label comment">
|
| 181 |
-
<label>Image/Logo</label>
|
| 182 |
-
<frontend_type>image</frontend_type>
|
| 183 |
-
<backend_model>adminhtml/system_config_backend_image</backend_model>
|
| 184 |
-
<upload_dir config="system/filesystem/media" scope_info="1">laybuy</upload_dir>
|
| 185 |
-
<base_url type="media" scope_info="1">laybuy</base_url>
|
| 186 |
-
<sort_order>77</sort_order>
|
| 187 |
-
<show_in_default>1</show_in_default>
|
| 188 |
-
<show_in_website>1</show_in_website>
|
| 189 |
-
<show_in_store>1</show_in_store>
|
| 190 |
-
<comment>logo or image (max. 750x90) to appear on Lay-Buys page for your branding or white-labeling.</comment>
|
| 191 |
-
</image>
|
| 192 |
-
<allowspecific translate="label comment">
|
| 193 |
-
<label>Payment Applicable From</label>
|
| 194 |
-
<frontend_type>select</frontend_type>
|
| 195 |
-
<sort_order>79</sort_order>
|
| 196 |
-
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
| 197 |
-
<show_in_default>1</show_in_default>
|
| 198 |
-
<show_in_website>1</show_in_website>
|
| 199 |
-
</allowspecific>
|
| 200 |
-
<specificcountry translate="label comment">
|
| 201 |
-
<label>Countries Payment Applicable From</label>
|
| 202 |
-
<frontend_type>multiselect</frontend_type>
|
| 203 |
-
<sort_order>81</sort_order>
|
| 204 |
-
<source_model>adminhtml/system_config_source_country</source_model>
|
| 205 |
-
<show_in_default>1</show_in_default>
|
| 206 |
-
<show_in_website>1</show_in_website>
|
| 207 |
-
<depends><allowspecific>1</allowspecific></depends>
|
| 208 |
-
</specificcountry>
|
| 209 |
-
<sort_order translate="label comment">
|
| 210 |
-
<label>Sort Order</label>
|
| 211 |
-
<frontend_type>text</frontend_type>
|
| 212 |
-
<sort_order>82</sort_order>
|
| 213 |
-
<show_in_default>1</show_in_default>
|
| 214 |
-
<show_in_website>1</show_in_website>
|
| 215 |
-
<show_in_store>1</show_in_store>
|
| 216 |
-
</sort_order>
|
| 217 |
-
<heading_sftp translate="label">
|
| 218 |
-
<label>Api Credentials</label>
|
| 219 |
-
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
| 220 |
-
<sort_order>83</sort_order>
|
| 221 |
-
<show_in_default>1</show_in_default>
|
| 222 |
-
<show_in_website>1</show_in_website>
|
| 223 |
-
</heading_sftp>
|
| 224 |
-
<settlement_reports_ftp_ip translate="label comment">
|
| 225 |
-
<label>Api IP-Address</label>
|
| 226 |
-
<comment>By default it is "https://lay-buys.com/report/".</comment>
|
| 227 |
-
<config_path>laybuy/fetch_reports/ftp_ip</config_path>
|
| 228 |
-
<frontend_type>text</frontend_type>
|
| 229 |
-
<sort_order>85</sort_order>
|
| 230 |
-
<show_in_default>1</show_in_default>
|
| 231 |
-
<show_in_website>1</show_in_website>
|
| 232 |
-
<shared>1</shared>
|
| 233 |
-
</settlement_reports_ftp_ip>
|
| 234 |
-
<heading_schedule translate="label">
|
| 235 |
-
<label>Scheduled Fetching</label>
|
| 236 |
-
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
| 237 |
-
<sort_order>87</sort_order>
|
| 238 |
-
<show_in_default>1</show_in_default>
|
| 239 |
-
<show_in_website>1</show_in_website>
|
| 240 |
-
<shared>1</shared>
|
| 241 |
-
</heading_schedule>
|
| 242 |
-
<settlement_reports_active translate="label">
|
| 243 |
-
<label>Enable Automatic Fetching</label>
|
| 244 |
-
<config_path>laybuy/fetch_reports/active</config_path>
|
| 245 |
-
<frontend_type>select</frontend_type>
|
| 246 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 247 |
-
<sort_order>89</sort_order>
|
| 248 |
-
<show_in_default>1</show_in_default>
|
| 249 |
-
<show_in_website>1</show_in_website>
|
| 250 |
-
<shared>1</shared>
|
| 251 |
-
</settlement_reports_active>
|
| 252 |
-
<settlement_reports_schedule translate="label comment">
|
| 253 |
-
<label>Schedule</label>
|
| 254 |
-
<config_path>laybuy/fetch_reports/schedule</config_path>
|
| 255 |
-
<frontend_type>select</frontend_type>
|
| 256 |
-
<source_model>laybuy/system_config_source_fetchingSchedule</source_model>
|
| 257 |
-
<backend_model>laybuy/system_config_backend_cron</backend_model>
|
| 258 |
-
<sort_order>91</sort_order>
|
| 259 |
-
<show_in_default>1</show_in_default>
|
| 260 |
-
<shared>1</shared>
|
| 261 |
-
</settlement_reports_schedule>
|
| 262 |
-
<settlement_reports_time translate="label">
|
| 263 |
-
<label>Time of Day</label>
|
| 264 |
-
<config_path>laybuy/fetch_reports/time</config_path>
|
| 265 |
-
<frontend_type>time</frontend_type>
|
| 266 |
-
<sort_order>100</sort_order>
|
| 267 |
-
<show_in_default>1</show_in_default>
|
| 268 |
-
<shared>1</shared>
|
| 269 |
-
</settlement_reports_time>
|
| 270 |
-
<
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
</config>
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<payment>
|
| 5 |
+
<groups>
|
| 6 |
+
<laybuy translate="label comment" module="laybuy">
|
| 7 |
+
<label>PUT IT ON LAY-BUY (powered by PayPal)</label>
|
| 8 |
+
<frontend_type>text</frontend_type>
|
| 9 |
+
<sort_order>999</sort_order>
|
| 10 |
+
<show_in_default>1</show_in_default>
|
| 11 |
+
<show_in_website>1</show_in_website>
|
| 12 |
+
<show_in_store>1</show_in_store>
|
| 13 |
+
<fields>
|
| 14 |
+
<active translate="label comment">
|
| 15 |
+
<label>Enabled</label>
|
| 16 |
+
<frontend_type>select</frontend_type>
|
| 17 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 18 |
+
<sort_order>10</sort_order>
|
| 19 |
+
<show_in_default>1</show_in_default>
|
| 20 |
+
<show_in_website>1</show_in_website>
|
| 21 |
+
<show_in_store>0</show_in_store>
|
| 22 |
+
</active>
|
| 23 |
+
<title translate="label comment">
|
| 24 |
+
<label>Title</label>
|
| 25 |
+
<frontend_type>text</frontend_type>
|
| 26 |
+
<sort_order>20</sort_order>
|
| 27 |
+
<show_in_default>1</show_in_default>
|
| 28 |
+
<show_in_website>1</show_in_website>
|
| 29 |
+
<show_in_store>1</show_in_store>
|
| 30 |
+
</title>
|
| 31 |
+
<order_status translate="label comment">
|
| 32 |
+
<label>New Order Status</label>
|
| 33 |
+
<frontend_type>select</frontend_type>
|
| 34 |
+
<source_model>adminhtml/system_config_source_order_status</source_model>
|
| 35 |
+
<sort_order>51</sort_order>
|
| 36 |
+
<show_in_default>1</show_in_default>
|
| 37 |
+
<show_in_website>1</show_in_website>
|
| 38 |
+
<show_in_store>0</show_in_store>
|
| 39 |
+
</order_status>
|
| 40 |
+
<submit_url translate="label comment">
|
| 41 |
+
<label>Gateway URL</label>
|
| 42 |
+
<frontend_type>text</frontend_type>
|
| 43 |
+
<sort_order>58</sort_order>
|
| 44 |
+
<show_in_default>1</show_in_default>
|
| 45 |
+
<show_in_website>0</show_in_website>
|
| 46 |
+
<show_in_store>0</show_in_store>
|
| 47 |
+
</submit_url>
|
| 48 |
+
<membership_number translate="label comment">
|
| 49 |
+
<label>Lay-Buys Membership Number</label>
|
| 50 |
+
<frontend_type>password</frontend_type>
|
| 51 |
+
<sort_order>59</sort_order>
|
| 52 |
+
<show_in_default>1</show_in_default>
|
| 53 |
+
<show_in_website>1</show_in_website>
|
| 54 |
+
<show_in_store>0</show_in_store>
|
| 55 |
+
</membership_number>
|
| 56 |
+
<multipledesc translate="label comment">
|
| 57 |
+
<label>Line Items Description</label>
|
| 58 |
+
<frontend_type>select</frontend_type>
|
| 59 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 60 |
+
<sort_order>60</sort_order>
|
| 61 |
+
<show_in_default>1</show_in_default>
|
| 62 |
+
<show_in_website>1</show_in_website>
|
| 63 |
+
<show_in_store>1</show_in_store>
|
| 64 |
+
</multipledesc>
|
| 65 |
+
<desc translate="label comment">
|
| 66 |
+
<label>Description</label>
|
| 67 |
+
<frontend_type>textarea</frontend_type>
|
| 68 |
+
<sort_order>61</sort_order>
|
| 69 |
+
<show_in_default>1</show_in_default>
|
| 70 |
+
<show_in_website>1</show_in_website>
|
| 71 |
+
<show_in_store>1</show_in_store>
|
| 72 |
+
<depends><multipledesc>0</multipledesc></depends>
|
| 73 |
+
<comment>Description of products / services</comment>
|
| 74 |
+
</desc>
|
| 75 |
+
<mind translate="label comment">
|
| 76 |
+
<label>Minimum</label>
|
| 77 |
+
<frontend_type>text</frontend_type>
|
| 78 |
+
<sort_order>62</sort_order>
|
| 79 |
+
<show_in_default>1</show_in_default>
|
| 80 |
+
<show_in_website>1</show_in_website>
|
| 81 |
+
<show_in_store>1</show_in_store>
|
| 82 |
+
<comment>Minimum Deposit Amount (defaults to 20%)</comment>
|
| 83 |
+
</mind>
|
| 84 |
+
<maxd translate="label comment">
|
| 85 |
+
<label>Maximum</label>
|
| 86 |
+
<frontend_type>text</frontend_type>
|
| 87 |
+
<sort_order>63</sort_order>
|
| 88 |
+
<show_in_default>1</show_in_default>
|
| 89 |
+
<show_in_website>1</show_in_website>
|
| 90 |
+
<show_in_store>1</show_in_store>
|
| 91 |
+
<comment>Maximum Deposit Amount (defaults to 50%)</comment>
|
| 92 |
+
</maxd>
|
| 93 |
+
<months translate="label comment">
|
| 94 |
+
<label>Months</label>
|
| 95 |
+
<frontend_type>text</frontend_type>
|
| 96 |
+
<sort_order>64</sort_order>
|
| 97 |
+
<show_in_default>1</show_in_default>
|
| 98 |
+
<show_in_website>1</show_in_website>
|
| 99 |
+
<show_in_store>1</show_in_store>
|
| 100 |
+
<comment>Maximum Number of Months to pay Balance (defaults to 3)</comment>
|
| 101 |
+
</months>
|
| 102 |
+
<adminfee translate="label comment">
|
| 103 |
+
<label>Show Lay-Buy Fee in Description</label>
|
| 104 |
+
<frontend_type>select</frontend_type>
|
| 105 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 106 |
+
<sort_order>65</sort_order>
|
| 107 |
+
<show_in_default>1</show_in_default>
|
| 108 |
+
<show_in_website>1</show_in_website>
|
| 109 |
+
<show_in_store>0</show_in_store>
|
| 110 |
+
<comment><![CDATA[ This payment option attracts a 0.9% surcharge. For more detail please login to <a href="https://www.lay-buys.com/vtmob/login/" target="_blank" title="https://www.lay-buys.com/vtmob/login/">merchant panel</a> using your merchant credentials.]]></comment>
|
| 111 |
+
</adminfee>
|
| 112 |
+
<conditional_criteria_total translate="label comment">
|
| 113 |
+
<label>Minimum Cart Total</label>
|
| 114 |
+
<config_path>laybuy/conditional_criteria/total</config_path>
|
| 115 |
+
<frontend_type>text</frontend_type>
|
| 116 |
+
<comment>The checkout total the order must reach before this payment method becomes active.</comment>
|
| 117 |
+
<sort_order>67</sort_order>
|
| 118 |
+
<show_in_default>1</show_in_default>
|
| 119 |
+
<show_in_website>1</show_in_website>
|
| 120 |
+
<show_in_store>1</show_in_store>
|
| 121 |
+
<shared>1</shared>
|
| 122 |
+
</conditional_criteria_total>
|
| 123 |
+
<allowspecificcategory translate="label comment">
|
| 124 |
+
<label>Allowed Categories</label>
|
| 125 |
+
<config_path>laybuy/conditional_criteria/allowspecificcategory</config_path>
|
| 126 |
+
<frontend_type>select</frontend_type>
|
| 127 |
+
<sort_order>69</sort_order>
|
| 128 |
+
<source_model>laybuy/system_config_source_allowspecificcategory</source_model>
|
| 129 |
+
<show_in_default>1</show_in_default>
|
| 130 |
+
<show_in_website>1</show_in_website>
|
| 131 |
+
<show_in_store>1</show_in_store>
|
| 132 |
+
</allowspecificcategory>
|
| 133 |
+
<conditional_criteria_category translate="comment">
|
| 134 |
+
<config_path>laybuy/conditional_criteria/categories</config_path>
|
| 135 |
+
<frontend_type>multiselect</frontend_type>
|
| 136 |
+
<source_model>laybuy/system_config_source_categories</source_model>
|
| 137 |
+
<can_be_empty>1</can_be_empty>
|
| 138 |
+
<comment>The checkout products of the orders must be in these categories before this payment method becomes active.</comment>
|
| 139 |
+
<sort_order>71</sort_order>
|
| 140 |
+
<depends><allowspecificcategory>1</allowspecificcategory></depends>
|
| 141 |
+
<show_in_default>1</show_in_default>
|
| 142 |
+
<show_in_website>1</show_in_website>
|
| 143 |
+
<show_in_store>1</show_in_store>
|
| 144 |
+
<shared>1</shared>
|
| 145 |
+
</conditional_criteria_category>
|
| 146 |
+
<allowspecificgroup translate="label comment">
|
| 147 |
+
<label>Allowed Customer Groups</label>
|
| 148 |
+
<config_path>laybuy/conditional_criteria/allowspecificgroup</config_path>
|
| 149 |
+
<frontend_type>select</frontend_type>
|
| 150 |
+
<sort_order>72</sort_order>
|
| 151 |
+
<source_model>laybuy/system_config_source_allowspecificgroup</source_model>
|
| 152 |
+
<show_in_default>1</show_in_default>
|
| 153 |
+
<show_in_website>1</show_in_website>
|
| 154 |
+
<show_in_store>1</show_in_store>
|
| 155 |
+
</allowspecificgroup>
|
| 156 |
+
<conditional_criteria_customergroup translate="comment">
|
| 157 |
+
<config_path>laybuy/conditional_criteria/customergroup</config_path>
|
| 158 |
+
<frontend_type>multiselect</frontend_type>
|
| 159 |
+
<source_model>laybuy/system_config_source_groups</source_model>
|
| 160 |
+
<comment>The checkout customer must be in these customer groups before this payment method becomes active.</comment>
|
| 161 |
+
<sort_order>73</sort_order>
|
| 162 |
+
<depends><allowspecificgroup>1</allowspecificgroup></depends>
|
| 163 |
+
<show_in_default>1</show_in_default>
|
| 164 |
+
<show_in_website>1</show_in_website>
|
| 165 |
+
<show_in_store>1</show_in_store>
|
| 166 |
+
<shared>1</shared>
|
| 167 |
+
</conditional_criteria_customergroup>
|
| 168 |
+
<conditional_criteria_exclude_products translate="label comment">
|
| 169 |
+
<label>Excluded Product Ids</label>
|
| 170 |
+
<config_path>laybuy/conditional_criteria/xproducts</config_path>
|
| 171 |
+
<frontend_type>textarea</frontend_type>
|
| 172 |
+
<can_be_empty>1</can_be_empty>
|
| 173 |
+
<comment>Add product ids separated by comma(,) for which method will not available.</comment>
|
| 174 |
+
<sort_order>75</sort_order>
|
| 175 |
+
<show_in_default>1</show_in_default>
|
| 176 |
+
<show_in_website>1</show_in_website>
|
| 177 |
+
<show_in_store>1</show_in_store>
|
| 178 |
+
<shared>1</shared>
|
| 179 |
+
</conditional_criteria_exclude_products>
|
| 180 |
+
<image translate="label comment">
|
| 181 |
+
<label>Image/Logo</label>
|
| 182 |
+
<frontend_type>image</frontend_type>
|
| 183 |
+
<backend_model>adminhtml/system_config_backend_image</backend_model>
|
| 184 |
+
<upload_dir config="system/filesystem/media" scope_info="1">laybuy</upload_dir>
|
| 185 |
+
<base_url type="media" scope_info="1">laybuy</base_url>
|
| 186 |
+
<sort_order>77</sort_order>
|
| 187 |
+
<show_in_default>1</show_in_default>
|
| 188 |
+
<show_in_website>1</show_in_website>
|
| 189 |
+
<show_in_store>1</show_in_store>
|
| 190 |
+
<comment>logo or image (max. 750x90) to appear on Lay-Buys page for your branding or white-labeling.</comment>
|
| 191 |
+
</image>
|
| 192 |
+
<allowspecific translate="label comment">
|
| 193 |
+
<label>Payment Applicable From</label>
|
| 194 |
+
<frontend_type>select</frontend_type>
|
| 195 |
+
<sort_order>79</sort_order>
|
| 196 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
| 197 |
+
<show_in_default>1</show_in_default>
|
| 198 |
+
<show_in_website>1</show_in_website>
|
| 199 |
+
</allowspecific>
|
| 200 |
+
<specificcountry translate="label comment">
|
| 201 |
+
<label>Countries Payment Applicable From</label>
|
| 202 |
+
<frontend_type>multiselect</frontend_type>
|
| 203 |
+
<sort_order>81</sort_order>
|
| 204 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
| 205 |
+
<show_in_default>1</show_in_default>
|
| 206 |
+
<show_in_website>1</show_in_website>
|
| 207 |
+
<depends><allowspecific>1</allowspecific></depends>
|
| 208 |
+
</specificcountry>
|
| 209 |
+
<sort_order translate="label comment">
|
| 210 |
+
<label>Sort Order</label>
|
| 211 |
+
<frontend_type>text</frontend_type>
|
| 212 |
+
<sort_order>82</sort_order>
|
| 213 |
+
<show_in_default>1</show_in_default>
|
| 214 |
+
<show_in_website>1</show_in_website>
|
| 215 |
+
<show_in_store>1</show_in_store>
|
| 216 |
+
</sort_order>
|
| 217 |
+
<heading_sftp translate="label">
|
| 218 |
+
<label>Api Credentials</label>
|
| 219 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
| 220 |
+
<sort_order>83</sort_order>
|
| 221 |
+
<show_in_default>1</show_in_default>
|
| 222 |
+
<show_in_website>1</show_in_website>
|
| 223 |
+
</heading_sftp>
|
| 224 |
+
<settlement_reports_ftp_ip translate="label comment">
|
| 225 |
+
<label>Api IP-Address</label>
|
| 226 |
+
<comment>By default it is "https://lay-buys.com/report/".</comment>
|
| 227 |
+
<config_path>laybuy/fetch_reports/ftp_ip</config_path>
|
| 228 |
+
<frontend_type>text</frontend_type>
|
| 229 |
+
<sort_order>85</sort_order>
|
| 230 |
+
<show_in_default>1</show_in_default>
|
| 231 |
+
<show_in_website>1</show_in_website>
|
| 232 |
+
<shared>1</shared>
|
| 233 |
+
</settlement_reports_ftp_ip>
|
| 234 |
+
<heading_schedule translate="label">
|
| 235 |
+
<label>Scheduled Fetching</label>
|
| 236 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
| 237 |
+
<sort_order>87</sort_order>
|
| 238 |
+
<show_in_default>1</show_in_default>
|
| 239 |
+
<show_in_website>1</show_in_website>
|
| 240 |
+
<shared>1</shared>
|
| 241 |
+
</heading_schedule>
|
| 242 |
+
<settlement_reports_active translate="label">
|
| 243 |
+
<label>Enable Automatic Fetching</label>
|
| 244 |
+
<config_path>laybuy/fetch_reports/active</config_path>
|
| 245 |
+
<frontend_type>select</frontend_type>
|
| 246 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 247 |
+
<sort_order>89</sort_order>
|
| 248 |
+
<show_in_default>1</show_in_default>
|
| 249 |
+
<show_in_website>1</show_in_website>
|
| 250 |
+
<shared>1</shared>
|
| 251 |
+
</settlement_reports_active>
|
| 252 |
+
<settlement_reports_schedule translate="label comment">
|
| 253 |
+
<label>Schedule</label>
|
| 254 |
+
<config_path>laybuy/fetch_reports/schedule</config_path>
|
| 255 |
+
<frontend_type>select</frontend_type>
|
| 256 |
+
<source_model>laybuy/system_config_source_fetchingSchedule</source_model>
|
| 257 |
+
<backend_model>laybuy/system_config_backend_cron</backend_model>
|
| 258 |
+
<sort_order>91</sort_order>
|
| 259 |
+
<show_in_default>1</show_in_default>
|
| 260 |
+
<shared>1</shared>
|
| 261 |
+
</settlement_reports_schedule>
|
| 262 |
+
<settlement_reports_time translate="label">
|
| 263 |
+
<label>Time of Day</label>
|
| 264 |
+
<config_path>laybuy/fetch_reports/time</config_path>
|
| 265 |
+
<frontend_type>time</frontend_type>
|
| 266 |
+
<sort_order>100</sort_order>
|
| 267 |
+
<show_in_default>1</show_in_default>
|
| 268 |
+
<shared>1</shared>
|
| 269 |
+
</settlement_reports_time>
|
| 270 |
+
<heading_express translate="label">
|
| 271 |
+
<label>Enable Express Checkout</label>
|
| 272 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
| 273 |
+
<sort_order>100</sort_order>
|
| 274 |
+
<show_in_default>1</show_in_default>
|
| 275 |
+
<show_in_website>1</show_in_website>
|
| 276 |
+
<shared>1</shared>
|
| 277 |
+
</heading_express>
|
| 278 |
+
<active_express translate="label comment">
|
| 279 |
+
<label>Enabled</label>
|
| 280 |
+
<frontend_type>select</frontend_type>
|
| 281 |
+
<config_path>payment/laybuy_express/active</config_path>
|
| 282 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 283 |
+
<sort_order>101</sort_order>
|
| 284 |
+
<show_in_default>1</show_in_default>
|
| 285 |
+
<show_in_website>1</show_in_website>
|
| 286 |
+
<show_in_store>0</show_in_store>
|
| 287 |
+
</active_express>
|
| 288 |
+
<sort_order>101</sort_order>
|
| 289 |
+
<show_in_default>1</show_in_default>
|
| 290 |
+
<show_in_website>1</show_in_website>
|
| 291 |
+
<show_in_store>0</show_in_store>
|
| 292 |
+
</fields>
|
| 293 |
+
</laybuy>
|
| 294 |
+
</groups>
|
| 295 |
+
</payment>
|
| 296 |
+
</sections>
|
| 297 |
</config>
|
app/code/local/Ced/LayBuy/sql/laybuy_setup/mysql4-upgrade-1.0.0-1.0.1.php
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = $this;
|
| 3 |
+
/* @var $installer Mage_Customer_Model_Entity_Setup */
|
| 4 |
+
|
| 5 |
+
$installer->startSetup();
|
| 6 |
+
|
| 7 |
+
$installer->run("
|
| 8 |
+
CREATE TABLE IF NOT EXISTS `{$installer->getTable('laybuy/laybuyresp')}` (
|
| 9 |
+
`resp_id` int(100) NOT NULL AUTO_INCREMENT,
|
| 10 |
+
`order_id` int(100) NOT NULL,
|
| 11 |
+
`response` text NOT NULL,
|
| 12 |
+
PRIMARY KEY (`resp_id`)
|
| 13 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
| 14 |
+
");
|
| 15 |
+
|
| 16 |
+
$installer->endSetup();
|
app/design/frontend/base/default/layout/laybuy.xml
CHANGED
|
@@ -49,4 +49,85 @@
|
|
| 49 |
<block type="laybuy/customer_account_grid" name="transaction_grid" template="laybuy/customer/account/grid.phtml"/>
|
| 50 |
</reference>
|
| 51 |
</laybuy_report_grid>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
</layout>
|
| 49 |
<block type="laybuy/customer_account_grid" name="transaction_grid" template="laybuy/customer/account/grid.phtml"/>
|
| 50 |
</reference>
|
| 51 |
</laybuy_report_grid>
|
| 52 |
+
|
| 53 |
+
<!-- new code by me starts-->
|
| 54 |
+
<catalog_product_view>
|
| 55 |
+
<reference name="product.info.addtocart">
|
| 56 |
+
<block type="page/html_wrapper" name="product.info.addtocart.laybuy.wrapper" translate="label">
|
| 57 |
+
<label>Laybuy Express Checkout Shortcut Wrapper</label>
|
| 58 |
+
<block type="laybuy/express_layshortcut" name="product.info.addtocart.laybuy" template="laybuy/express/layshortcut.phtml">
|
| 59 |
+
<action method="setIsInCatalogProduct"><value>1</value></action>
|
| 60 |
+
</block>
|
| 61 |
+
</block>
|
| 62 |
+
</reference>
|
| 63 |
+
</catalog_product_view>
|
| 64 |
+
<default>
|
| 65 |
+
<reference name="topCart.extra_actions">
|
| 66 |
+
<block type="laybuy/express_layshortcut" name="laybuy.partner.top_cart.shortcut" template="laybuy/express/layshortcut1.phtml"/>
|
| 67 |
+
</reference>
|
| 68 |
+
<reference name="cart_sidebar.extra_actions">
|
| 69 |
+
<block type="laybuy/express_layshortcut" name="laybuy.partner.cart_sidebar.shortcut" template="laybuy/express/layshortcut1.phtml"/>
|
| 70 |
+
</reference>
|
| 71 |
+
</default>
|
| 72 |
+
<checkout_cart_index>
|
| 73 |
+
<reference name="checkout.cart.top_methods">
|
| 74 |
+
<block type="laybuy/express_layshortcut" name="checkout.cart.methods.laybuy_express.top" before="-" template="laybuy/express/layshortcut1.phtml">
|
| 75 |
+
<action method="setIsQuoteAllowed"><value>1</value></action>
|
| 76 |
+
</block>
|
| 77 |
+
</reference>
|
| 78 |
+
|
| 79 |
+
<reference name="checkout.cart.methods">
|
| 80 |
+
<block type="laybuy/express_layshortcut" name="checkout.cart.methods.laybuy_express.bottom" before="-" template="laybuy/express/layshortcut1.phtml">
|
| 81 |
+
<action method="setIsQuoteAllowed"><value>1</value></action>
|
| 82 |
+
</block>
|
| 83 |
+
</reference>
|
| 84 |
+
|
| 85 |
+
<!-- <update handle="SHORTCUT_popup" />-->
|
| 86 |
+
</checkout_cart_index>
|
| 87 |
+
<laybuy_express_index>
|
| 88 |
+
<remove name="right"/>
|
| 89 |
+
<remove name="left"/>
|
| 90 |
+
<reference name="root">
|
| 91 |
+
<action method="setTemplate"><template>page/1column.phtml</template></action>
|
| 92 |
+
</reference>
|
| 93 |
+
<reference name="content">
|
| 94 |
+
<block type="laybuy/express_layform" name="laybuy.express.layform" template="laybuy/express/extraexpress.phtml">
|
| 95 |
+
</block>
|
| 96 |
+
</reference>
|
| 97 |
+
</laybuy_express_index>
|
| 98 |
+
<laybuy_express_review translate="label">
|
| 99 |
+
<label>Laybuy Express Order Review Form</label>
|
| 100 |
+
<remove name="right"/>
|
| 101 |
+
<remove name="left"/>
|
| 102 |
+
<reference name="root">
|
| 103 |
+
<action method="setTemplate"><template>page/1column.phtml</template></action>
|
| 104 |
+
</reference>
|
| 105 |
+
<reference name="content">
|
| 106 |
+
<block type="laybuy/express_review" name="laybuy.express.review" template="laybuy/express/review.phtml">
|
| 107 |
+
<block type="laybuy/express_review_billing" name="express.review.billing" as="billing" template="laybuy/express/review/address.phtml"/>
|
| 108 |
+
<block type="laybuy/express_review_shipping" name="express.review.shipping" as="shipping" template="laybuy/express/review/address.phtml"/>
|
| 109 |
+
<block type="laybuy/express_review" name="express.review.shipping.method" as="shipping_method" template="laybuy/express/review/shipping/method.phtml"/>
|
| 110 |
+
<block type="laybuy/express_review_details" name="laybuy.express.review.details" as="details" template="laybuy/express/review/details.phtml">
|
| 111 |
+
<action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
|
| 112 |
+
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
|
| 113 |
+
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
|
| 114 |
+
<block type="checkout/cart_totals" name="laybuy.express.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
|
| 115 |
+
</block>
|
| 116 |
+
<block type="checkout/agreements" name="laybuy.express.review.details.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
|
| 117 |
+
</block>
|
| 118 |
+
</reference>
|
| 119 |
+
<reference name="head">
|
| 120 |
+
<action method="addItem"><type>skin_js</type><name>js/checkout/review.js</name></action>
|
| 121 |
+
</reference>
|
| 122 |
+
<block type="core/text_list" name="additional.product.info" />
|
| 123 |
+
</laybuy_express_review>
|
| 124 |
+
<laybuy_express_review_details>
|
| 125 |
+
<block type="laybuy/express_review_details" name="root" output="toHtml" template="laybuy/express/review/details.phtml">
|
| 126 |
+
<action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
|
| 127 |
+
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
|
| 128 |
+
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
|
| 129 |
+
<block type="checkout/cart_totals" name="laybuy.express.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
|
| 130 |
+
</block>
|
| 131 |
+
</laybuy_express_review_details>
|
| 132 |
+
<!-- new code by me ends -->
|
| 133 |
</layout>
|
app/design/frontend/base/default/template/laybuy/express/extraexpress.phtml
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Lay-Buys
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @author Asheesh Singh<asheeshsingh@cedcoss.com>
|
| 24 |
+
* @copyright Copyright LAY-BUYS (2011). (http://lay-buys.com/)
|
| 25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 26 |
+
*/
|
| 27 |
+
?>
|
| 28 |
+
<?php
|
| 29 |
+
/**
|
| 30 |
+
* @see Ced_LayBuy_Block_Form_Laybuy
|
| 31 |
+
*/
|
| 32 |
+
?>
|
| 33 |
+
|
| 34 |
+
<?php
|
| 35 |
+
$storeId=Mage::app()->getStore()->getId();
|
| 36 |
+
$adminFeeDescription = '';
|
| 37 |
+
if(Mage::getStoreConfig('payment/laybuy/adminfee',$storeId)) {
|
| 38 |
+
//$adminFeeDescription = " A 0.9% admin fee is payable to Lay-Buys.";
|
| 39 |
+
$adminFeeDescription = " This payment option attracts a 0.9% surcharge.";
|
| 40 |
+
}
|
| 41 |
+
if(Mage::getStoreConfig('payment/laybuy/months',$storeId)) {
|
| 42 |
+
$paymentmonths=Mage::getStoreConfig('payment/laybuy/months',$storeId);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
?>
|
| 47 |
+
|
| 48 |
+
<link media="all" rel="stylesheet" href="<?php echo Mage::getBaseUrl('skin'); ?>frontend/base/default/css/laybuy/tooltip.css" type="text/css">
|
| 49 |
+
<?php
|
| 50 |
+
$sessionPayment = Mage::getSingleton('checkout/session')->getQuote()->getPayment();
|
| 51 |
+
$customerOptions = Mage::helper('laybuy')->getInstalmentData($sessionPayment);
|
| 52 |
+
/* $customerOptions['INIT'] = $sessionPayment->getData('laybuy_init');
|
| 53 |
+
$customerOptions['MONTHS'] = $sessionPayment->getData('laybuy_months'); */
|
| 54 |
+
|
| 55 |
+
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals();
|
| 56 |
+
$grandtotal = $totals["grand_total"]->getValue();
|
| 57 |
+
?>
|
| 58 |
+
<form method="post" action="<?php echo Mage::getBaseUrl();?>laybuy/express/form">
|
| 59 |
+
<div class="fieldset">
|
| 60 |
+
<ul class="form-list" id="payment_form" style="display:block;">
|
| 61 |
+
<li class="form-alt"><h2 class="legend"><?php echo $this->getExtraMessage() ?></h2></li>
|
| 62 |
+
|
| 63 |
+
<li>
|
| 64 |
+
<label for="init" class="required"><em>*</em><?php echo $this->__('Initial Payment') ?> : </label>
|
| 65 |
+
<div class="input-box">
|
| 66 |
+
<select onChange="document.getElementById('preview-tbl1').src = '<?php echo $this->getUrl('laybuy/standard/docalc',array('_secure'=>true)); ?>?currency=<?php echo Mage::app()->getStore()->getCurrentCurrencyCode(); ?>&amt=<?php echo $grandtotal; ?>&init='+document.getElementById('init').value+'&mnth='+document.getElementById('months').value+'&rnd='+Math.random()+'&html=1';" id="init" name="payment[laybuy_init]" title="<?php echo $this->__('Initial Payment') ?>" class="required-entry">
|
| 67 |
+
<?php foreach ($this->getArray('dp_amount') as $_data): ?>
|
| 68 |
+
<option value="<?php echo $_data['value'] ?>" <?php if(isset($customerOptions['INIT']) && $customerOptions['INIT'] && $customerOptions['INIT']==$_data['value']){ ?> selected="selected" <?php } ?>><?php echo $_data['label'] ?></option>
|
| 69 |
+
<?php endforeach ?>
|
| 70 |
+
</select>
|
| 71 |
+
</div>
|
| 72 |
+
</li>
|
| 73 |
+
<li>
|
| 74 |
+
<label for="months" class="required"><em>*</em><?php echo $this->__('Months to Pay') ?> : </label>
|
| 75 |
+
<div class="input-box">
|
| 76 |
+
<select onChange="document.getElementById('preview-tbl1').src = '<?php echo $this->getUrl('laybuy/standard/docalc',array('_secure'=>true)); ?>?currency=<?php echo Mage::app()->getStore()->getCurrentCurrencyCode(); ?>&amt=<?php echo $grandtotal; ?>&init='+document.getElementById('init').value+'&mnth='+document.getElementById('months').value+'&rnd='+Math.random()+'&html=1';" id="months" name="payment[laybuy_months]" title="<?php echo $this->__('Months to Pay') ?>" class="required-entry">
|
| 77 |
+
<?php $_recommendedMonth = isset($customerOptions['MONTHS']) && $customerOptions['MONTHS']?$customerOptions['MONTHS']:$this->getConfigData('months'); ?>
|
| 78 |
+
<?php foreach ($this->getArray('months') as $_data): ?>
|
| 79 |
+
<option value="<?php echo $_data['value'] ?>"<?php if($_data['value']==$_recommendedMonth): ?> selected="selected"<?php endif ?>><?php echo $_data['label'] ?></option>
|
| 80 |
+
<?php endforeach ?>
|
| 81 |
+
</select>
|
| 82 |
+
</div>
|
| 83 |
+
</li>
|
| 84 |
+
<li>
|
| 85 |
+
<label for="preview-tbl1"><?php echo $this->__('Plan Preview') ?></label>
|
| 86 |
+
<div id="preview-tbl1-wrapper" class="input-box" style="width:100% !important">
|
| 87 |
+
<iframe src="<?php echo $this->getUrl('laybuy/standard/docalc',array('_secure'=>true)); ?>?currency=<?php echo Mage::app()->getStore()->getCurrentCurrencyCode(); ?>&amt=<?php echo $grandtotal; ?>&init=<?php if(isset($customerOptions['INIT']) && $customerOptions['INIT']){ $a=$customerOptions['INIT'];$b=trim($a,"%");echo $b; } else { $c=$this->getConfigData('mind');$d=trim($c,"%");echo $d; } ?>&mnth=<?php echo $_recommendedMonth; ?>&html=1" name="preview-tbl1" id="preview-tbl1" style="width:100%; height:120px; border:0; margin:0; overflow:hidden" marginheight="0" marginwidth="0" noscroll></iframe>
|
| 88 |
+
|
| 89 |
+
</div>
|
| 90 |
+
</li>
|
| 91 |
+
|
| 92 |
+
<li>
|
| 93 |
+
<div class="buttons-set" style="margin-top: 0px; text-align:left;">
|
| 94 |
+
<label for="preview-tbl12"><?php echo $this->__('* Here initial Down-Payment and Lay-Buy Installment Plan excludes the shipping.') ?></label>
|
| 95 |
+
<br> <label for="preview-tbl12"><?php echo $this->__('Your goods/services will be delivered once your final payment has been received.') ?></label>
|
| 96 |
+
<p class="required">* Required Fields</p>
|
| 97 |
+
<button class="button" title="Continue" type="submit"><span><span>Continue</span></span></button>
|
| 98 |
+
<label style="float: right ! important; padding-top: 6px;">
|
| 99 |
+
<a class="callBackTip" title="<?php echo Mage::helper('laybuy')->__('Lay-Buy is an affordable payment plan option that allows you to pay-off a product or service via one down payment, with the balance paid over')?>
|
| 100 |
+
<?php
|
| 101 |
+
$secondlast=$paymentmonths-1;
|
| 102 |
+
for($i=1;$i<=$paymentmonths;$i++){
|
| 103 |
+
|
| 104 |
+
echo $i;
|
| 105 |
+
if($i==$paymentmonths){
|
| 106 |
+
}
|
| 107 |
+
else{
|
| 108 |
+
if($i==$secondlast){
|
| 109 |
+
echo " ";
|
| 110 |
+
}
|
| 111 |
+
else{
|
| 112 |
+
echo ",";
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
if($i==$secondlast){
|
| 118 |
+
echo "or"." ";
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
?>
|
| 124 |
+
<?php echo Mage::helper('laybuy')->__('monthly instalments. Your purchase is delivered to you after the final instalment payment is completed.'.$adminFeeDescription) ?>">
|
| 125 |
+
<?php echo Mage::helper('laybuy')->__('What is LAY-BUY?') ?></a></label>
|
| 126 |
+
<script type="text/javascript">
|
| 127 |
+
laybuy(function(){
|
| 128 |
+
// List of all parameters and their default values:
|
| 129 |
+
laybuy('a.callBackTip').aToolTip({
|
| 130 |
+
// no need to change/override
|
| 131 |
+
closeTipBtn: 'aToolTipCloseBtn',
|
| 132 |
+
toolTipId: 'aToolTip',
|
| 133 |
+
// ok to override
|
| 134 |
+
fixed: false, // Set true to activate fixed position
|
| 135 |
+
clickIt: true, // set to true for click activated tooltip
|
| 136 |
+
inSpeed: 200, // Speed tooltip fades in
|
| 137 |
+
outSpeed: 100, // Speed tooltip fades out
|
| 138 |
+
tipContent: '<?php echo Mage::helper('laybuy')->__('Lay-Buy is an affordable payment plan option that allows you to pay-off a product or service via one down payment, with the balance paid over 1, 2 or 3 monthly instalments. Your purchase is delivered to you after the final instalment payment is completed.'.$adminFeeDescription) ?>', // Pass in content or it will use objects 'title' attribute
|
| 139 |
+
toolTipClass: 'defaultTheme', // Set class name for custom theme/styles
|
| 140 |
+
xOffset: 5, // x position
|
| 141 |
+
yOffset: 5, // y position
|
| 142 |
+
onShow: function(){}, // callback function that fires after atooltip has shown
|
| 143 |
+
onHide: function(){} // callback function that fires after atooltip has faded out
|
| 144 |
+
});
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
});
|
| 149 |
+
</script>
|
| 150 |
+
</div>
|
| 151 |
+
</li>
|
| 152 |
+
</ul>
|
| 153 |
+
</div>
|
| 154 |
+
</form>
|
app/design/frontend/base/default/template/laybuy/express/layshortcut.phtml
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
<?php $model="";?>
|
| 3 |
+
<?php $product_id="";?>
|
| 4 |
+
<?php $store_id="";?>
|
| 5 |
+
<?php $store_id=Mage::app()->getStore()->getStoreId();?>
|
| 6 |
+
<?php $model=Mage::getModel("laybuy/express");?>
|
| 7 |
+
<?php $quote=Mage::getModel('checkout/cart')->getQuote();?>
|
| 8 |
+
<?php $product_id = Mage::registry('current_product')->getId();?>
|
| 9 |
+
<?php if($model->isAvailable($quote) && $model->checkForCategoriesAndProducts($product_id,$store_id)){// ?>
|
| 10 |
+
<p class="paypal-logo">
|
| 11 |
+
<?php if ($this->isOrPositionBefore()): ?>
|
| 12 |
+
<span class="paypal-or"><?php echo $this->__('-OR-');?></span>
|
| 13 |
+
<?php endif; ?>
|
| 14 |
+
|
| 15 |
+
<a id="laybuy_express_link" style="cursor: pointer;float:left;"><img src="https://lay-buys.com/gateway/LAY-BUY.png" alt="<?php echo Mage::helper('laybuy')->__('Checkout with Laybuy Express');?>" title="<?php echo Mage::helper('laybuy')->__('Checkout with Laybuy Express');?>" /></a>
|
| 16 |
+
<span id="payment-please-wait" class="please-wait" style="display:none;margin:5px;float:left;">
|
| 17 |
+
<img class="v-middle" title="Loading next step..." alt="Loading next step..." src="<?php echo Mage::getBaseUrl("skin");?>frontend/default/default/images/opc-ajax-loader.gif"/>
|
| 18 |
+
</span>
|
| 19 |
+
<p style="clear:both;"></p>
|
| 20 |
+
<?php if ($this->isOrPositionAfter()): ?>
|
| 21 |
+
<span class="paypal-or"><?php echo $this->__('-OR-');?></span>
|
| 22 |
+
<?php endif; ?>
|
| 23 |
+
</p>
|
| 24 |
+
|
| 25 |
+
<script type="text/javascript">
|
| 26 |
+
laybuy(document).ready(function(){
|
| 27 |
+
laybuy("a#laybuy_express_link").click(function(){
|
| 28 |
+
laybuy("#payment-please-wait").css("display","block");
|
| 29 |
+
var other_data = laybuy('#product_addtocart_form').serialize();
|
| 30 |
+
var url=laybuy('#product_addtocart_form').attr('action');
|
| 31 |
+
var url1='<?php echo Mage::getBaseurl();?>laybuy/express';
|
| 32 |
+
laybuy.post( url, other_data,function(data){
|
| 33 |
+
window.location = url1;
|
| 34 |
+
});
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
});
|
| 38 |
+
|
| 39 |
+
</script>
|
| 40 |
+
|
| 41 |
+
<?php }?>
|
app/design/frontend/base/default/template/laybuy/express/layshortcut1.phtml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php $model="";?>
|
| 2 |
+
<?php $product_id="";?>
|
| 3 |
+
<?php $store_id="";?>
|
| 4 |
+
<?php $store_id=Mage::app()->getStore()->getStoreId();?>
|
| 5 |
+
<?php $quote=Mage::getModel('checkout/cart')->getQuote();?>
|
| 6 |
+
<?php $model=Mage::getModel("laybuy/express");?>
|
| 7 |
+
<?php if($model->isAvailable($quote)){ // && $model->checkForCategoriesAndProducts($product_id,$store_id)?>
|
| 8 |
+
<p class="paypal-logo">
|
| 9 |
+
<?php if ($this->isOrPositionBefore()): ?>
|
| 10 |
+
<span class="paypal-or"><?php echo $this->__('-OR-');?></span>
|
| 11 |
+
<?php endif; ?>
|
| 12 |
+
<a id="laybuy_express_link" style="cursor: pointer;" href="<?php echo Mage::getBaseurl();?>laybuy/express" ><img src="https://lay-buys.com/gateway/LAY-BUY.png" alt="<?php echo Mage::helper('laybuy')->__('Checkout with Laybuy Express');?>" title="<?php echo Mage::helper('laybuy')->__('Checkout with Laybuy Express');?>" /></a>
|
| 13 |
+
<?php if ($this->isOrPositionAfter()): ?>
|
| 14 |
+
<span class="paypal-or"><?php echo $this->__('-OR-');?></span>
|
| 15 |
+
<?php endif; ?>
|
| 16 |
+
</p>
|
| 17 |
+
<?php }?>
|
app/design/frontend/base/default/template/laybuy/express/review.phtml
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
/** @var $this Mage_Paypal_Block_Express_Review */
|
| 27 |
+
|
| 28 |
+
$billingBlock = $this->getChild('billing')->setFieldNamePrefix('billing')->setHideEmailAddress(true);
|
| 29 |
+
$shippingAddress = $this->getShippingAddress();
|
| 30 |
+
?>
|
| 31 |
+
<div class="page-title">
|
| 32 |
+
<h1><?php echo $this->__('Review Order') ?></h1>
|
| 33 |
+
</div>
|
| 34 |
+
<?php echo $this->getMessagesBlock()->toHtml() ?>
|
| 35 |
+
<script type="text/javascript">
|
| 36 |
+
//<![CDATA[
|
| 37 |
+
var countryRegions = <?php echo $this->helper('directory')->getRegionJson() ?>
|
| 38 |
+
//]]>
|
| 39 |
+
</script>
|
| 40 |
+
<h2 class="sub-title">
|
| 41 |
+
Please confirm your addresses
|
| 42 |
+
</h2>
|
| 43 |
+
<div class="paypal-review-order">
|
| 44 |
+
<form method="post" id="order_review_form" action="<?php echo $this->getPlaceOrderUrl() ?>">
|
| 45 |
+
<?php if(!$billingBlock->isCustomerLoggedIn()): ?>
|
| 46 |
+
<div class="info-set col2-set">
|
| 47 |
+
<h2 class="legend"><?php echo $this->__('Customer Information') ?></h2>
|
| 48 |
+
<ul class="form-list form-list-narrow">
|
| 49 |
+
<li id="customer-info-form" class="address-form">
|
| 50 |
+
<div class="field">
|
| 51 |
+
<label for="customer:email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
| 52 |
+
<div class="input-box">
|
| 53 |
+
<input type="text" name="customer-email" id="customer:email" value="<?php echo $this->escapeHtml($billingBlock->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
|
| 54 |
+
</div>
|
| 55 |
+
</div>
|
| 56 |
+
</li>
|
| 57 |
+
</ul>
|
| 58 |
+
</div>
|
| 59 |
+
<?php endif ?>
|
| 60 |
+
<div class="info-set col2-set">
|
| 61 |
+
<div class="col-1" id="billing-address">
|
| 62 |
+
<h2 class="legend"><?php echo $this->__('Billing Address') ?></h2>
|
| 63 |
+
<?php if ($shippingAddress): ?>
|
| 64 |
+
<?php echo $billingBlock->setShowAsShippingCheckbox(true)->toHtml(); ?>
|
| 65 |
+
<?php else: ?>
|
| 66 |
+
<?php echo $billingBlock->toHtml(); ?>
|
| 67 |
+
<?php endif; ?>
|
| 68 |
+
</div>
|
| 69 |
+
<?php if ($shippingAddress): ?>
|
| 70 |
+
<div class="col-2" id="shipping-address">
|
| 71 |
+
<h2 class="legend"><?php echo $this->__('Shipping Address') ?></h2>
|
| 72 |
+
<?php echo $this->getChild('shipping')->setFieldNamePrefix('shipping')->setHideEmailAddress(true)->toHtml(); ?>
|
| 73 |
+
</div>
|
| 74 |
+
</div>
|
| 75 |
+
|
| 76 |
+
<div class="info-set col2-set">
|
| 77 |
+
<div class="col-2">
|
| 78 |
+
<div class="box paypal-shipping-method">
|
| 79 |
+
<div class="box-title">
|
| 80 |
+
<h3><?php echo $this->__('Shipping Method') ?></h3>
|
| 81 |
+
</div>
|
| 82 |
+
<div class="box-content">
|
| 83 |
+
<?php echo $this->getChild('shipping_method')->toHtml(); ?>
|
| 84 |
+
</div>
|
| 85 |
+
</div>
|
| 86 |
+
</div>
|
| 87 |
+
<?php endif; ?>
|
| 88 |
+
</div>
|
| 89 |
+
|
| 90 |
+
<div class="info-set">
|
| 91 |
+
<h2 class="legend"><?php echo $this->__('Items in Your Shopping Cart') ?><span class="separator"> | </span><a href="<?php echo $this->getUrl('checkout/cart') ?>"><?php echo $this->__('Edit Shopping Cart') ?></a></h2>
|
| 92 |
+
<div id="details-reload">
|
| 93 |
+
<?php echo $this->getChildHtml('details') ?>
|
| 94 |
+
</div>
|
| 95 |
+
</div>
|
| 96 |
+
<?php echo $this->getChildHtml('agreements'); ?>
|
| 97 |
+
<div class="buttons-set buttons-set-order" id="review-buttons-container">
|
| 98 |
+
<button type="button" id="review_button" value="<?php echo $this->__('Place Order') ?>" class="button btn-checkout"><span><span><?php echo $this->__('Place Order') ?></span></span></button>
|
| 99 |
+
<button type="button" id="review_submit" value="<?php echo $this->__('Place Order') ?>" class="button btn-checkout"><span><span><?php echo $this->__('Place Order') ?></span></span></button>
|
| 100 |
+
<button type="button" id="update_order" class="button btn-checkout"><span><span><?php echo $this->__('Update Order Data') ?></span></span></button>
|
| 101 |
+
<span class="please-wait" id="review-please-wait" style="display:none;">
|
| 102 |
+
<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Submitting order information...') ?>" title="<?php echo $this->__('Submitting order information...') ?>" class="v-middle" /> <?php echo $this->__('Submitting order information...') ?>
|
| 103 |
+
</span>
|
| 104 |
+
</div>
|
| 105 |
+
</form>
|
| 106 |
+
</div>
|
| 107 |
+
<script type="text/javascript">
|
| 108 |
+
//<![CDATA[
|
| 109 |
+
// submit buttons are not needed when submitting with ajax
|
| 110 |
+
$('review_submit').hide();
|
| 111 |
+
if ($('update_shipping_method_submit')) {
|
| 112 |
+
$('update_shipping_method_submit').hide();
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
<?php if ($this->getUseAjax()):?>
|
| 116 |
+
OrderReviewController.prototype._submitOrder = function() {
|
| 117 |
+
if (this._canSubmitOrder) {
|
| 118 |
+
if (this._pleaseWait) {
|
| 119 |
+
this._pleaseWait.show();
|
| 120 |
+
}
|
| 121 |
+
new Ajax.Request(this.form.action, {
|
| 122 |
+
parameters: {isAjax: 1, method: 'POST'},
|
| 123 |
+
onSuccess: function(transport) {
|
| 124 |
+
try{
|
| 125 |
+
response = eval('(' + transport.responseText + ')');
|
| 126 |
+
} catch (e) {
|
| 127 |
+
response = {};
|
| 128 |
+
}
|
| 129 |
+
if (response.redirect) {
|
| 130 |
+
setLocation(response.redirect);
|
| 131 |
+
return;
|
| 132 |
+
}
|
| 133 |
+
if (response.success) {
|
| 134 |
+
setLocation('<?php echo $this->getSuccessUrl()?>');
|
| 135 |
+
return;
|
| 136 |
+
} else {
|
| 137 |
+
var msg = response.error_messages;
|
| 138 |
+
if (typeof(msg)=='object') {
|
| 139 |
+
msg = msg.join("\n");
|
| 140 |
+
}
|
| 141 |
+
if (msg) {
|
| 142 |
+
$('review-please-wait').hide();
|
| 143 |
+
alert(msg);
|
| 144 |
+
return;
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
$('review-please-wait').hide();
|
| 148 |
+
alert('<?php echo $this->jsQuoteEscape($this->__('Unknown Error. Please try again later.')); ?>');
|
| 149 |
+
return;
|
| 150 |
+
},
|
| 151 |
+
onFailure: function(){
|
| 152 |
+
alert('<?php echo $this->jsQuoteEscape($this->__('Server Error. Please try again.')) ?>');
|
| 153 |
+
$('review-please-wait').hide();
|
| 154 |
+
}
|
| 155 |
+
});
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
<?php endif ?>
|
| 159 |
+
<?php
|
| 160 |
+
/* $shippingMethodsUpdateUrl="";
|
| 161 |
+
$UpdateOrderSubmitUrl="";
|
| 162 |
+
$shippingMethodsUpdateUrl="http://192.168.1.44/magento18/magento/index.php/laybuy/express/updateOrder/";
|
| 163 |
+
$UpdateOrderSubmitUrl="http://192.168.1.44/magento18/magento/index.php/laybuy/express/updateShippingMethods/" ; */?>
|
| 164 |
+
PayPalExpressAjax = new OrderReviewController($('order_review_form'), $('review_button'),
|
| 165 |
+
'shipping_method', null, 'details-reload'
|
| 166 |
+
);
|
| 167 |
+
PayPalExpressAjax.addPleaseWait($('review-please-wait'));
|
| 168 |
+
PayPalExpressAjax.setShippingAddressContainer($('shipping-address'));
|
| 169 |
+
PayPalExpressAjax.setShippingMethodContainer('shipping-method-container');
|
| 170 |
+
PayPalExpressAjax.shippingMethodsUpdateUrl = '<?php echo $this->escapeHtml($this->getUpdateShippingMethodsUrl());?>';//$this->escapeHtml($this->getUpdateShippingMethodsUrl()) $UpdateOrderSubmitUrl
|
| 171 |
+
PayPalExpressAjax.setUpdateButton($('update_order'),'<?php echo $this->escapeHtml($this->getUpdateOrderSubmitUrl());?>','details-reload');//$this->escapeHtml($this->getUpdateOrderSubmitUrl()) $shippingMethodsUpdateUrl
|
| 172 |
+
if ($('billing:as_shipping')) {
|
| 173 |
+
PayPalExpressAjax.setCopyElement($('billing:as_shipping'));
|
| 174 |
+
}
|
| 175 |
+
//]]>
|
| 176 |
+
</script>
|
app/design/frontend/base/default/template/laybuy/express/review/address.phtml
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
?>
|
| 27 |
+
<?php $prefix = $this->getFieldNamePrefix();?>
|
| 28 |
+
|
| 29 |
+
<fieldset>
|
| 30 |
+
<ul class="form-list form-list-narrow">
|
| 31 |
+
<li id="<?php echo $prefix ?>-address-form" class="address-form">
|
| 32 |
+
<fieldset>
|
| 33 |
+
<input type="hidden" name="<?php echo $prefix ?>[address_id]" value="<?php echo $this->getAddress()->getId() ?>" id="<?php echo $prefix ?>:address_id" />
|
| 34 |
+
<ul>
|
| 35 |
+
<li class="fields"><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat($prefix . ':%s')->setFieldNameFormat($prefix . '[%s]')->toHtml() ?></li>
|
| 36 |
+
<li class="fields">
|
| 37 |
+
<div class="field">
|
| 38 |
+
<label for="<?php echo $prefix ?>:company"><?php echo $this->__('Company') ?></label>
|
| 39 |
+
<div class="input-box">
|
| 40 |
+
<input type="text" id="<?php echo $prefix ?>:company" name="<?php echo $prefix ?>[company]" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
|
| 41 |
+
</div>
|
| 42 |
+
</div>
|
| 43 |
+
<?php if(!$this->isCustomerLoggedIn() && !$this->getHideEmailAddress()): ?>
|
| 44 |
+
<div class="field">
|
| 45 |
+
<label for="<?php echo $prefix ?>:email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
| 46 |
+
<div class="input-box">
|
| 47 |
+
<input type="text" name="<?php echo $prefix ?>[email]" id="<?php echo $prefix ?>:email" value="<?php echo $this->escapeHtml($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
|
| 48 |
+
</div>
|
| 49 |
+
</div>
|
| 50 |
+
<?php endif; ?>
|
| 51 |
+
</li>
|
| 52 |
+
<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
|
| 53 |
+
<li class="wide">
|
| 54 |
+
<label for="<?php echo $prefix ?>:street1" class="required"><em>*</em><?php echo $this->__('Address') ?></label>
|
| 55 |
+
<div class="input-box">
|
| 56 |
+
<input type="text" title="<?php echo $this->__('Street Address') ?>" name="<?php echo $prefix ?>[street][]" id="<?php echo $prefix ?>:street1" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>" class="input-text <?php echo $_streetValidationClass ?>" />
|
| 57 |
+
</div>
|
| 58 |
+
</li>
|
| 59 |
+
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
|
| 60 |
+
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
|
| 61 |
+
<li class="add-field">
|
| 62 |
+
<div class="input-box">
|
| 63 |
+
<input type="text" title="<?php echo $this->__('Street Address %s', $_i) ?>" name="<?php echo $prefix ?>[street][]" id="<?php echo $prefix ?>:street<?php echo $_i?>" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>" class="input-text <?php echo $_streetValidationClass ?>" />
|
| 64 |
+
</div>
|
| 65 |
+
</li>
|
| 66 |
+
<?php endfor; ?>
|
| 67 |
+
<?php if ($this->helper('customer/address')->isVatAttributeVisible()) : ?>
|
| 68 |
+
<li class="wide">
|
| 69 |
+
<label for="<?php echo $prefix ?>:vat_id"><?php echo $this->__('VAT Number') ?></label>
|
| 70 |
+
<div class="input-box">
|
| 71 |
+
<input type="text" id="<?php echo $prefix ?>:vat_id" name="<?php echo $prefix ?>[vat_id]" value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()) ?>" title="<?php echo $this->__('VAT Number') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('vat_id') ?>" />
|
| 72 |
+
</div>
|
| 73 |
+
</li>
|
| 74 |
+
<?php endif; ?>
|
| 75 |
+
<li class="fields">
|
| 76 |
+
<div class="field">
|
| 77 |
+
<label for="<?php echo $prefix ?>:city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
|
| 78 |
+
<div class="input-box">
|
| 79 |
+
<input type="text" title="<?php echo $this->__('City') ?>" name="<?php echo $prefix ?>[city]" value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="<?php echo $prefix ?>:city" />
|
| 80 |
+
</div>
|
| 81 |
+
</div>
|
| 82 |
+
<div class="field">
|
| 83 |
+
<label for="<?php echo $prefix ?>:region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
|
| 84 |
+
<div class="input-box">
|
| 85 |
+
<select id="<?php echo $prefix ?>:region_id" name="<?php echo $prefix ?>[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
|
| 86 |
+
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
| 87 |
+
</select>
|
| 88 |
+
<script type="text/javascript">
|
| 89 |
+
//<![CDATA[
|
| 90 |
+
$('<?php echo $prefix ?>:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
|
| 91 |
+
//]]>
|
| 92 |
+
</script>
|
| 93 |
+
<input type="text" id="<?php echo $prefix ?>:region" name="<?php echo $prefix ?>[region]" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
|
| 94 |
+
</div>
|
| 95 |
+
</div>
|
| 96 |
+
</li>
|
| 97 |
+
<li class="fields">
|
| 98 |
+
<div class="field">
|
| 99 |
+
<label for="<?php echo $prefix ?>:postcode" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
|
| 100 |
+
<div class="input-box">
|
| 101 |
+
<input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="<?php echo $prefix ?>[postcode]" id="<?php echo $prefix ?>:postcode" value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
|
| 102 |
+
</div>
|
| 103 |
+
</div>
|
| 104 |
+
<div class="field">
|
| 105 |
+
<label for="<?php echo $prefix ?>:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
|
| 106 |
+
<div class="input-box">
|
| 107 |
+
<?php echo $this->getCountryHtmlSelect($prefix) ?>
|
| 108 |
+
</div>
|
| 109 |
+
</div>
|
| 110 |
+
</li>
|
| 111 |
+
<li class="fields">
|
| 112 |
+
<div class="field">
|
| 113 |
+
<label for="<?php echo $prefix ?>:telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
|
| 114 |
+
<div class="input-box">
|
| 115 |
+
<input type="text" name="<?php echo $prefix ?>[telephone]" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="<?php echo $prefix ?>:telephone" />
|
| 116 |
+
</div>
|
| 117 |
+
</div>
|
| 118 |
+
<div class="field">
|
| 119 |
+
<label for="<?php echo $prefix ?>:fax"><?php echo $this->__('Fax') ?></label>
|
| 120 |
+
<div class="input-box">
|
| 121 |
+
<input type="text" name="<?php echo $prefix ?>[fax]" value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>" title="<?php echo $this->__('Fax') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('fax') ?>" id="<?php echo $prefix ?>:fax" />
|
| 122 |
+
</div>
|
| 123 |
+
</div>
|
| 124 |
+
</li>
|
| 125 |
+
<?php echo $this->getChildHtml('form.additional.info'); ?>
|
| 126 |
+
<?php if ($this->getShowAsShippingCheckbox()): ?>
|
| 127 |
+
<li class="control">
|
| 128 |
+
<div class="field">
|
| 129 |
+
<div class="input-box">
|
| 130 |
+
<input type="checkbox" name="<?php echo $prefix ?>[as_shipping]" class="checkbox" value="1" title="<?php echo $this->__('Same as shipping') ?>" id="<?php echo $prefix ?>:as_shipping" <?php if ($this->getAddress()->getSameAsBilling()):?>checked="checked"<?php endif;?>/>
|
| 131 |
+
</div>
|
| 132 |
+
<label for="<?php echo $prefix ?>:as_shipping"><?php echo $this->__('Same as shipping') ?></label>
|
| 133 |
+
</div>
|
| 134 |
+
</li>
|
| 135 |
+
<?php endif; ?>
|
| 136 |
+
</ul>
|
| 137 |
+
</fieldset>
|
| 138 |
+
</li>
|
| 139 |
+
</ul>
|
| 140 |
+
</fieldset>
|
| 141 |
+
<script type="text/javascript">
|
| 142 |
+
//<![CDATA[
|
| 143 |
+
var <?php echo $prefix ?>RegionUpdater = new RegionUpdater('<?php echo $prefix ?>:country_id', '<?php echo $prefix ?>:region', '<?php echo $prefix ?>:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, '<?php echo $prefix ?>:postcode');
|
| 144 |
+
<?php echo $prefix ?>RegionUpdater.update();
|
| 145 |
+
//]]>
|
| 146 |
+
</script>
|
app/design/frontend/base/default/template/laybuy/express/review/details.phtml
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @see Mage_Paypal_Block_Express_Review_Details
|
| 29 |
+
*/
|
| 30 |
+
?>
|
| 31 |
+
<table id="details-table" class="data-table">
|
| 32 |
+
<?php if ($this->helper('tax')->displayCartBothPrices()): $colspan = $rowspan = 2; else: $colspan = $rowspan = 1; endif; ?>
|
| 33 |
+
<col />
|
| 34 |
+
<col width="1" />
|
| 35 |
+
<col width="1" />
|
| 36 |
+
<col width="1" />
|
| 37 |
+
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
|
| 38 |
+
<col width="1" />
|
| 39 |
+
<col width="1" />
|
| 40 |
+
<?php endif; ?>
|
| 41 |
+
<thead>
|
| 42 |
+
<tr>
|
| 43 |
+
<th rowspan="<?php echo $rowspan ?>"><?php echo $this->__('Product Name') ?></th>
|
| 44 |
+
<th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Price') ?></th>
|
| 45 |
+
<th rowspan="<?php echo $rowspan ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
|
| 46 |
+
<th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Subtotal') ?></th>
|
| 47 |
+
</tr>
|
| 48 |
+
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
|
| 49 |
+
<tr>
|
| 50 |
+
<th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
|
| 51 |
+
<th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
|
| 52 |
+
<th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
|
| 53 |
+
<th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
|
| 54 |
+
</tr>
|
| 55 |
+
<?php endif; ?>
|
| 56 |
+
</thead>
|
| 57 |
+
<?php echo $this->getChildHtml('totals'); ?>
|
| 58 |
+
<tbody>
|
| 59 |
+
<?php foreach($this->getItems() as $_item): ?>
|
| 60 |
+
<?php echo $this->getItemHtml($_item) ?>
|
| 61 |
+
<?php endforeach ?>
|
| 62 |
+
</tbody>
|
| 63 |
+
</table>
|
| 64 |
+
<script type="text/javascript">decorateTable('details-table');</script>
|
app/design/frontend/base/default/template/laybuy/express/review/shipping/method.phtml
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category design
|
| 22 |
+
* @package base_default
|
| 23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
/** @var $this Mage_Paypal_Block_Express_Review */
|
| 27 |
+
?>
|
| 28 |
+
<fieldset id="shipping-method-container">
|
| 29 |
+
<?php if ($this->getCanEditShippingMethod() || !$this->getCurrentShippingRate()):?>
|
| 30 |
+
<?php if ($groups = $this->getShippingRateGroups()):?>
|
| 31 |
+
<?php $currentRate = $this->getCurrentShippingRate(); ?>
|
| 32 |
+
<select name="shipping_method" id="shipping_method" style="width:250px;" class="required-entry">
|
| 33 |
+
<?php if (!$currentRate):?>
|
| 34 |
+
<option value=""><?php echo $this->__('Please select a shipping method...') ?></option>
|
| 35 |
+
<?php endif;?>
|
| 36 |
+
<?php foreach ($groups as $code => $rates):?>
|
| 37 |
+
<optgroup label="<?php echo $this->escapeHtml($this->getCarrierName($code)) ?>" style="font-style:normal;">
|
| 38 |
+
<?php foreach ($rates as $rate):?>
|
| 39 |
+
<option value="<?php echo $this->renderShippingRateValue($rate)?>"<?php echo ($currentRate === $rate) ? ' selected="selected"' : '' ;?>>
|
| 40 |
+
<?php echo $this->renderShippingRateOption($rate)?>
|
| 41 |
+
</option>
|
| 42 |
+
<?php endforeach;?>
|
| 43 |
+
</optgroup>
|
| 44 |
+
<?php endforeach;?>
|
| 45 |
+
</select>
|
| 46 |
+
<?php else: ?>
|
| 47 |
+
<p><strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong></p>
|
| 48 |
+
<?php endif;?>
|
| 49 |
+
<?php else: ?>
|
| 50 |
+
<p><strong><?php echo $this->renderShippingRateOption($this->getCurrentShippingRate())?></strong></p>
|
| 51 |
+
<?php endif; ?>
|
| 52 |
+
</fieldset>
|
| 53 |
+
<div style="display:none" id="shipping_method_update"><p><?php echo $this->__('Please update order data to get shipping methods and rates') ?></p></div>
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Ced_LayBuy</name>
|
| 4 |
-
<version>2.1.8.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -18,12 +18,11 @@ PUT IT ON LAY-BUY enables online shoppers to pay-off a product or service via a
|
|
| 18 |
Merchants however only deliver the product or service after receipt of the final instalment payment
|
| 19 |

|
| 20 |
This effectively increases sales and radically improves cash flow where all the customer monies are paid directly into your PayPal account</description>
|
| 21 |
-
<notes>1.
|
| 22 |
-
|
| 23 |
-
<
|
| 24 |
-
<
|
| 25 |
-
<
|
| 26 |
-
<contents><target name="magelocal"><dir name="Ced"><dir name="LayBuy"><dir name="Block"><dir name="Adminhtml"><file name="Docalc.php" hash="c12af05bee0d480ac49835b46ca8011e"/><dir name="Orders"><file name="Grid.php" hash="54a924cd69f95cf9496f91702a4edeec"/><file name="Grid.php.bkp" hash="b37908e3e7f57787c4b3d441be869ba9"/></dir><file name="Orders.php" hash="aa89abe43868eedab8cb195b5dcbe77f"/><dir name="Report"><dir name="Details"><file name="Form.php" hash="e0ce57d85efc14656d4294021e5f5257"/></dir><file name="Details.php" hash="16317e0652d7e33e1207d0a1b29ed185"/><dir name="Edit"><file name="Form.php" hash="ca0b74b0301d0051930478f87aec2080"/></dir><file name="Edit.php" hash="5dc6f961714c5d38a228f6b943c3127d"/><file name="Grid.php" hash="a94a86483b880c9908572e3fc8f5d30d"/><dir name="Renderer"><file name="Email.php" hash="8e6c0938d80f629cd285303018945ea1"/><file name="Order.php" hash="51a2ba685b652f69df633ccfa4b5900a"/><file name="Record.php" hash="95eb9f836a50f3f80d254a7cdd8e1d6e"/></dir></dir><file name="Report.php" hash="ff77fef080779db3a699cdb8a4703c49"/></dir><dir name="Customer"><dir name="Account"><file name="Details.php" hash="5bb9caf5b0a6e9584046f6af9ee4ae5f"/><file name="Grid.php" hash="3b170ed3f70422b3a64263535d3543e3"/></dir></dir><dir name="Form"><file name="Laybuy.php" hash="cbf8b96d0fa26d4b772bafd021e3fc83"/></dir><dir name="Info"><file name="Laybuy.php" hash="bced26100dc8bbadc334b54349734637"/></dir><dir name="Revise"><file name="Redirect.php" hash="6f63613d0fe5540a296804c14263a614"/></dir><dir name="Standard"><file name="Docalc.php" hash="42b2b63a23577c888cccc5f6c20b8867"/><file name="Redirect.php" hash="bdf403ef8c7c290ce0af83cdd172dcb7"/></dir></dir><dir name="Helper"><file name="Config.php" hash="360b6125612be9de5cd0e3b69f4422c2"/><file name="Data.php" hash="7e5ba01ef723858f4752d03cf2242103"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Report"><file name="Collection.php" hash="a3e133f1128200662330a5e21a94c809"/></dir><file name="Report.php" hash="25568238c401ab5e5768596fb76f7ef8"/><dir name="Revise"><file name="Collection.php" hash="2a502f75e4634e4f231f93226ef49b8a"/></dir><file name="Revise.php" hash="cd1a424882417e0ec94561a8cca378e8"/><file name="Setup.php" hash="261838defadf805c7ee29768f6ea8cec"/></dir><file name="Observer.php" hash="e085e396516583f6685648f75d967a66"/><file name="Report.php" hash="ffb651448186ad401e238b2060074317"/><file name="Revise.php" hash="b9bbea4b6760b464ec8ff66c872def7a"/><file name="Standard.php" hash="b991b733940156d1b24b6a0c813d68e0"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Cron.php" hash="955ae77c29ecbc063d8f779898d08472"/><file name="Cron.php.bkp" hash="24c8fcf93531c9877d03f2eebde2e2dd"/></dir><dir name="Source"><file name="Allowspecificcategory.php" hash="0463f2be60a2695e4f76411c979b6bc8"/><file name="Allowspecificgroup.php" hash="a27c9bf1231a59a8f38668b525c420ba"/><file name="Categories.php" hash="92c61dba3c23e7838cddbaaee8f21d05"/><file name="FetchingSchedule.php" hash="7ad862c46ec8f54299cc92ae87b61322"/><file name="FetchingSchedule.php.bkp" hash="4f3e5aec5a17991d1625d6f17c0f7d32"/><file name="Groups.php" hash="87a205676d93d59a26d1d7bb69266991"/></dir></dir></dir></dir><file name="README.txt" hash="7930d4ac1e8f9957bb2052983eab4340"/><dir name="controllers"><dir name="Adminhtml"><file name="OrdersController.php" hash="b439600c08514fb9ada1ae0e75272e21"/><file name="ReportController.php" hash="b22ab26daaeca1c067427288230d1656"/></dir><file name="ReportController.php" hash="e2c5e9ce734b2c3320eb503e05baecae"/><file name="ReviseController.php" hash="39cf4f4031522b1cf0f623f51c186715"/><file name="StandardController.php" hash="0c4233798441091d6749766c0a894789"/></dir><dir name="etc"><file name="adminhtml.xml" hash="6bc550c65f0f65b11d6dbb38aafcb63d"/><file name="config.xml" hash="b4989e2e7bc0e017b0202523cdc13097"/><file name="system.xml" hash="de7ca437cd91076c098ec22b3cf10fb8"/></dir><dir name="sql"><dir name="laybuy_setup"><file name="mysql4-install-0.1.0.php" hash="68e359cd24b6051d0c2a91daad899d71"/><file name="mysql4-upgrade-0.1.0-0.2.0.php" hash="bec5e37090cb5a6da6c8ba3652a8bd32"/><file name="mysql4-upgrade-0.2.0-0.3.0.php" hash="97aa7a2a8c91e46c896a6d04d9554aeb"/><file name="mysql4-upgrade-0.3.0-0.4.0.php" hash="9b147158166b94d52e0cfff369ce965c"/><file name="mysql4-upgrade-0.4.0-0.5.0.php" hash="7626925b0cac03d0918eb6b1d51e6d19"/><file name="mysql4-upgrade-0.5.0-0.6.0.php" hash="bc96daed76ca1f04b1eb422508bc3a4b"/><file name="mysql4-upgrade-0.6.0-0.7.0.php" hash="6aa013f47e3b78e4d78e2cba9b471cd4"/><file name="mysql4-upgrade-0.7.0-0.8.0.php" hash="c2ea0f16c8f1e0dc7412a6a0fda1c622"/><file name="mysql4-upgrade-0.8.0-0.9.0.php" hash="d98ba6bef5f4f46ca741d5db014686f1"/><file name="mysql4-upgrade-0.9.0-1.0.0.php" hash="a20364c9f3a1b2a6a7e33a2e2f03bd60"/></dir></dir><file name="README.txt" hash="7930d4ac1e8f9957bb2052983eab4340"/></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="laybuy.xml" hash="963cc90317ac79c032f2530eca1813ba"/></dir><dir name="template"><dir name="laybuy"><dir name="checkout"><dir name="onepage"><dir name="review"><file name="button.phtml" hash="a1e678a76d674b223e944bdd4de0625a"/></dir></dir></dir><dir name="customer"><dir name="account"><file name="details.phtml" hash="965a58454b4b3cdcc115d78e595f7c33"/><file name="grid.phtml" hash="2dc802991a69b459f263f4e78c657549"/></dir></dir><dir name="form"><file name="extra.phtml" hash="535609083ce3e06706ec30766b354d8a"/><file name="extra.phtml.bkp" hash="e089ba0a3bd4ff1c0bc631c88ba32dd2"/><file name="laybuy.phtml" hash="5169cbb58cb7fec4312eb70325829e70"/><file name="laybuy.phtml.bkp" hash="a1c8dc8ff7ebd565d0100785ad089f64"/></dir><dir name="info"><file name="default.phtml" hash="b0bdfa731e4410c99a79c3b5b0a86cff"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="laybuy.xml" hash="b60d76e466dac9154654041350d5e829"/></dir><dir name="template"><dir name="laybuy"><dir name="info"><file name="default.phtml" hash="a9dfb322a83df7bc53bb2a64c6f192e3"/><dir name="pdf"><file name="laybuy.phtml" hash="e96cab97e4bd4ca32a022e90d5449eae"/></dir></dir><file name="notification.phtml" hash="efb99f36ea192d6bc8c60d53dec8a6e1"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ced_LayBuy.xml" hash="394d4e115e1955ba12681f6a81cb118d"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Ced_LayBuy.csv" hash="f79a1a6ca61c5e7a7463c380eb00896d"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="laybuy"><file name="tooltip.css" hash="ece078bf3d8bb27db4a616fdad505671"/></dir></dir><dir name="images"><dir name="laybuy"><file name="closeBtn.png" hash="b0be9d9ef1053c79b0ebdcef83b53f44"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="laybuy"><file name="jquery.atooltip.js" hash="5ad78b7e8ac539053ff56a2ea25e4d4c"/><file name="jquery.min.js" hash="41ab3fafa358a66f764b91d072f16615"/></dir></dir></target></contents>
|
| 27 |
<compatible/>
|
| 28 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 29 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Ced_LayBuy</name>
|
| 4 |
+
<version>2.1.8.4</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
| 7 |
<channel>community</channel>
|
| 18 |
Merchants however only deliver the product or service after receipt of the final instalment payment
|
| 19 |

|
| 20 |
This effectively increases sales and radically improves cash flow where all the customer monies are paid directly into your PayPal account</description>
|
| 21 |
+
<notes>1.New secure communication protocal.</notes>
|
| 22 |
+
<authors><author><name>Warrin</name><user>Warrin</user><email>warrin@lay-buys.com</email></author><author><name>Asheesh Singh</name><user>asheeshsingh</user><email>asheeshsingh@cedcoss.com</email></author><author><name>Sanjeev Kumar Gupta</name><user>sanjeevgupta</user><email>sanjeevkumargupta@cedcoss.com</email></author></authors>
|
| 23 |
+
<date>2015-04-14</date>
|
| 24 |
+
<time>11:52:59</time>
|
| 25 |
+
<contents><target name="magelocal"><dir name="Ced"><dir name="LayBuy"><dir><dir name="Block"><dir name="Adminhtml"><file name="Docalc.php" hash="c12af05bee0d480ac49835b46ca8011e"/><dir name="Orders"><file name="Grid.php" hash="54a924cd69f95cf9496f91702a4edeec"/><file name="Grid.php.bkp" hash="b37908e3e7f57787c4b3d441be869ba9"/></dir><file name="Orders.php" hash="aa89abe43868eedab8cb195b5dcbe77f"/><dir name="Report"><dir name="Details"><file name="Form.php" hash="e0ce57d85efc14656d4294021e5f5257"/></dir><file name="Details.php" hash="16317e0652d7e33e1207d0a1b29ed185"/><dir name="Edit"><file name="Form.php" hash="ca0b74b0301d0051930478f87aec2080"/></dir><file name="Edit.php" hash="5dc6f961714c5d38a228f6b943c3127d"/><file name="Grid.php" hash="a94a86483b880c9908572e3fc8f5d30d"/><dir name="Renderer"><file name="Email.php" hash="8e6c0938d80f629cd285303018945ea1"/><file name="Order.php" hash="51a2ba685b652f69df633ccfa4b5900a"/><file name="Record.php" hash="95eb9f836a50f3f80d254a7cdd8e1d6e"/></dir></dir><file name="Report.php" hash="ff77fef080779db3a699cdb8a4703c49"/></dir><dir name="Customer"><dir name="Account"><file name="Details.php" hash="5bb9caf5b0a6e9584046f6af9ee4ae5f"/><file name="Grid.php" hash="3b170ed3f70422b3a64263535d3543e3"/></dir></dir><dir name="Express"><file name="Layform.php" hash="5220c8b272517893117c106cfcb225f1"/><file name="Layshortcut.php" hash="6f816b7629cd900f0fa96717a717d54e"/><file name="Redirect.php" hash="6f55337e5b979cca8c7cff64e955327f"/><dir name="Review"><file name="Billing.php" hash="b54899379bc5203920b8ebb92a557783"/><file name="Details.php" hash="94e0a0692b80c2e74897bded2e3d8bfb"/><file name="Shipping.php" hash="419447e905bd26df390660b906de4293"/></dir><file name="Review.php" hash="2aaa2ee5979b99f9e1c8fc62f8462056"/></dir><dir name="Form"><file name="Laybuy.php" hash="cbf8b96d0fa26d4b772bafd021e3fc83"/></dir><dir name="Info"><file name="Laybuy.php" hash="bced26100dc8bbadc334b54349734637"/></dir><dir name="Payment"><file name="Info.php" hash="ada79889134af121d15cc20b5d20e631"/></dir><dir name="Revise"><file name="Redirect.php" hash="6f63613d0fe5540a296804c14263a614"/></dir><dir name="Standard"><file name="Docalc.php" hash="42b2b63a23577c888cccc5f6c20b8867"/><file name="Redirect.php" hash="bdf403ef8c7c290ce0af83cdd172dcb7"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="OrdersController.php" hash="b439600c08514fb9ada1ae0e75272e21"/><file name="ReportController.php" hash="b22ab26daaeca1c067427288230d1656"/></dir><file name="ExpressController.php" hash="7ea759f39d712fb1ae1fc5216c503bc6"/><file name="ReportController.php" hash="e2c5e9ce734b2c3320eb503e05baecae"/><file name="ReviseController.php" hash="39cf4f4031522b1cf0f623f51c186715"/><file name="StandardController.php" hash="0c4233798441091d6749766c0a894789"/></dir><dir name="etc"><file name="adminhtml.xml" hash="6bc550c65f0f65b11d6dbb38aafcb63d"/><file name="config.xml" hash="80e5e4827e2bfd3dd5fe16aa567bb284"/><file name="system.xml" hash="083f553c6c6a29b965467e91ba722446"/></dir><dir name="Helper"><file name="Config.php" hash="360b6125612be9de5cd0e3b69f4422c2"/><file name="Data.php" hash="6860d634141dd0f96ac93fe17e57d6ff"/></dir><dir name="Model"><file name="Abstract.php" hash="bbe69ad50f5aa1e02fa0d581addbc06e"/><file name="Config.php" hash="6d45f8a0d8d6d3deeb0ed6e13fbeafc0"/><file name="Express.php" hash="b411edad160b1adf63e9581884b3579b"/><file name="Laybuyresp.php" hash="66379c09b62cc940a8aef23e796f3128"/><dir name="Mysql4"><dir name="Laybuyresp"><file name="Collection.php" hash="fff7dbedfd6536c10251d50843924798"/></dir><file name="Laybuyresp.php" hash="1270556aab8ccaf4c92e1f3c902153dc"/><dir name="Region"><file name="Collection.php" hash="8c99fda8daf14cbb54ff4a6bd515084c"/></dir><dir name="Report"><file name="Collection.php" hash="a3e133f1128200662330a5e21a94c809"/></dir><file name="Report.php" hash="25568238c401ab5e5768596fb76f7ef8"/><dir name="Revise"><file name="Collection.php" hash="2a502f75e4634e4f231f93226ef49b8a"/></dir><file name="Revise.php" hash="cd1a424882417e0ec94561a8cca378e8"/><file name="Setup.php" hash="261838defadf805c7ee29768f6ea8cec"/></dir><file name="Observer.php" hash="e085e396516583f6685648f75d967a66"/><file name="Pro.php" hash="47788ab1d076d7cd809e19b4a4e8bc11"/><file name="Report.php" hash="ffb651448186ad401e238b2060074317"/><file name="Revise.php" hash="b9bbea4b6760b464ec8ff66c872def7a"/><file name="Standard.php" hash="b991b733940156d1b24b6a0c813d68e0"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Cron.php" hash="955ae77c29ecbc063d8f779898d08472"/><file name="Cron.php.bkp" hash="24c8fcf93531c9877d03f2eebde2e2dd"/></dir><dir name="Source"><file name="Allowspecificcategory.php" hash="0463f2be60a2695e4f76411c979b6bc8"/><file name="Allowspecificgroup.php" hash="a27c9bf1231a59a8f38668b525c420ba"/><file name="Categories.php" hash="92c61dba3c23e7838cddbaaee8f21d05"/><file name="FetchingSchedule.php" hash="7ad862c46ec8f54299cc92ae87b61322"/><file name="FetchingSchedule.php.bkp" hash="4f3e5aec5a17991d1625d6f17c0f7d32"/><file name="Groups.php" hash="87a205676d93d59a26d1d7bb69266991"/></dir></dir></dir></dir><dir name="sql"><dir name="laybuy_setup"><file name="mysql4-install-0.1.0.php" hash="68e359cd24b6051d0c2a91daad899d71"/><file name="mysql4-upgrade-0.1.0-0.2.0.php" hash="bec5e37090cb5a6da6c8ba3652a8bd32"/><file name="mysql4-upgrade-0.2.0-0.3.0.php" hash="97aa7a2a8c91e46c896a6d04d9554aeb"/><file name="mysql4-upgrade-0.3.0-0.4.0.php" hash="9b147158166b94d52e0cfff369ce965c"/><file name="mysql4-upgrade-0.4.0-0.5.0.php" hash="7626925b0cac03d0918eb6b1d51e6d19"/><file name="mysql4-upgrade-0.5.0-0.6.0.php" hash="bc96daed76ca1f04b1eb422508bc3a4b"/><file name="mysql4-upgrade-0.6.0-0.7.0.php" hash="6aa013f47e3b78e4d78e2cba9b471cd4"/><file name="mysql4-upgrade-0.7.0-0.8.0.php" hash="c2ea0f16c8f1e0dc7412a6a0fda1c622"/><file name="mysql4-upgrade-0.8.0-0.9.0.php" hash="d98ba6bef5f4f46ca741d5db014686f1"/><file name="mysql4-upgrade-0.9.0-1.0.0.php" hash="a20364c9f3a1b2a6a7e33a2e2f03bd60"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="047c77c6ad5a49b47165ed242279fd4e"/></dir></dir></dir><file name="README.txt" hash="7930d4ac1e8f9957bb2052983eab4340"/></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="laybuy.xml" hash="b8732c983d0c9c7c8807208985ca3953"/></dir><dir name="template"><dir name="laybuy"><dir><dir name="checkout"><dir name="onepage"><dir name="review"><file name="button.phtml" hash="a1e678a76d674b223e944bdd4de0625a"/></dir></dir></dir><dir name="customer"><dir name="account"><file name="details.phtml" hash="965a58454b4b3cdcc115d78e595f7c33"/><file name="grid.phtml" hash="2dc802991a69b459f263f4e78c657549"/></dir></dir><dir name="express"><file name="extraexpress.phtml" hash="51ceb076c4eff7c1ea7cd931d65c9f3f"/><file name="layshortcut1.phtml" hash="a3b7490f991dcd03571a02c2e68a8020"/><file name="layshortcut.phtml" hash="96e953a90a36b7fd98f714db1ca6a407"/><dir name="review"><file name="address.phtml" hash="56f47a05c89dcff636144d1e5171188d"/><file name="details.phtml" hash="d9cfdaa646d2d6693002bf6f00064201"/><dir name="shipping"><file name="method.phtml" hash="f71cbdfc5a8fe543eb03c8475a1818d3"/></dir></dir><file name="review.phtml" hash="962f5e4e7d5e0720849eea77db6098b1"/></dir><dir name="form"><file name="extra.phtml" hash="535609083ce3e06706ec30766b354d8a"/><file name="extra.phtml.bkp" hash="e089ba0a3bd4ff1c0bc631c88ba32dd2"/><file name="laybuy.phtml" hash="5169cbb58cb7fec4312eb70325829e70"/><file name="laybuy.phtml.bkp" hash="a1c8dc8ff7ebd565d0100785ad089f64"/></dir><dir name="info"><file name="default.phtml" hash="b0bdfa731e4410c99a79c3b5b0a86cff"/></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="laybuy.xml" hash="b60d76e466dac9154654041350d5e829"/></dir><dir name="template"><dir name="laybuy"><dir><dir name="info"><file name="default.phtml" hash="a9dfb322a83df7bc53bb2a64c6f192e3"/><dir name="pdf"><file name="laybuy.phtml" hash="e96cab97e4bd4ca32a022e90d5449eae"/></dir></dir></dir><file name="notification.phtml" hash="efb99f36ea192d6bc8c60d53dec8a6e1"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ced_LayBuy.xml" hash="394d4e115e1955ba12681f6a81cb118d"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Ced_LayBuy.csv" hash="f79a1a6ca61c5e7a7463c380eb00896d"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="laybuy"><file name="tooltip.css" hash="ece078bf3d8bb27db4a616fdad505671"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="laybuy"><file name="jquery.atooltip.js" hash="5ad78b7e8ac539053ff56a2ea25e4d4c"/><file name="jquery.min.js" hash="41ab3fafa358a66f764b91d072f16615"/></dir></dir></target></contents>
|
|
|
|
| 26 |
<compatible/>
|
| 27 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 28 |
</package>
|
skin/frontend/base/default/images/laybuy/closeBtn.png
DELETED
|
Binary file
|
