Version Notes
This extension implements Litle XML
Additional features include enhanced reporting on orders, transactions, and customers.
Download this release
Release Info
Developer | Litle |
Extension | Litle_Payments |
Version | 8.13.3 |
Comparing to | |
See all releases |
Code changes from version 8.13.2 to 8.13.3
- app/code/local/Litle/CreditCard/Block/Form/CreditCard.php +203 -166
- app/code/local/Litle/CreditCard/Helper/Data.php +24 -33
- app/code/local/Litle/CreditCard/Model/Order/Payment.php +10 -10
- app/code/local/Litle/CreditCard/Model/PaymentLogic.php +404 -322
- app/code/local/Litle/CreditCard/etc/config.xml +1 -1
- app/code/local/Litle/CreditCard/etc/system.xml +15 -4
- app/code/local/Litle/LEcheck/Block/Form/LEcheck.php +2 -2
- app/code/local/Litle/LEcheck/etc/config.xml +1 -1
- app/code/local/Litle/LitleSDK/Obj2xml.php +2 -2
- app/code/local/Litle/Palorus/Block/Adminhtml/Customer/Edit/Tab/Vault.php +94 -0
- app/code/local/Litle/Palorus/Block/Vault.php +105 -0
- app/code/local/Litle/Palorus/Block/Vault/List.php +64 -0
- app/code/local/Litle/Palorus/Helper/Data.php +210 -128
- app/code/local/Litle/Palorus/Model/Mysql4/Vault.php +24 -7
- app/code/local/Litle/Palorus/Model/Mysql4/Vault/Collection.php +12 -1
- app/code/local/Litle/Palorus/Model/Vault.php +146 -1
- app/code/local/Litle/Palorus/controllers/Adminhtml/VaultController.php +59 -0
- app/code/local/Litle/Palorus/controllers/VaultController.php +88 -0
- app/code/local/Litle/Palorus/etc/config.xml +41 -8
- app/code/local/Litle/Palorus/sql/palorus_setup/mysql4-upgrade-8.13.2-8.13.3.php +49 -0
- app/design/adminhtml/default/default/layout/litle.xml +6 -2
- app/design/adminhtml/default/default/template/litle/customer/tab/vault.phtml +33 -0
- app/design/adminhtml/default/default/template/litle/form/litlecc.phtml +158 -0
- app/design/adminhtml/default/default/template/{payment → litle}/form/litleecheck.phtml +0 -0
- app/design/adminhtml/default/default/template/payment/form/litlecc.phtml +0 -138
- app/design/frontend/base/default/layout/litlecreditcard.xml +27 -2
- app/design/frontend/{default/default/template/payment → base/default/template/litle}/form/litlecc.phtml +115 -119
- app/design/frontend/{default/default/template/payment → base/default/template/litle}/form/litleecheck.phtml +3 -3
- app/design/frontend/base/default/template/{payment → litle}/form/litlejs.phtml +0 -0
- app/design/frontend/base/default/template/litle/vault/list.phtml +49 -0
- app/design/frontend/base/default/template/payment/form/litlecc.phtml +0 -254
- app/design/frontend/base/default/template/payment/form/litleecheck.phtml +0 -35
- package.xml +2 -2
app/code/local/Litle/CreditCard/Block/Form/CreditCard.php
CHANGED
@@ -1,178 +1,215 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Magento
|
4 |
-
*
|
5 |
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
*
|
8 |
-
*
|
9 |
-
*
|
10 |
-
*
|
11 |
-
*
|
12 |
-
*
|
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 |
-
*
|
20 |
*
|
21 |
-
* @category
|
22 |
-
* @package
|
23 |
-
* @copyright
|
24 |
-
* @license
|
|
|
25 |
*/
|
26 |
-
|
27 |
-
|
28 |
class Litle_CreditCard_Block_Form_CreditCard extends Mage_Payment_Block_Form
|
29 |
{
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
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 |
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Magento
|
|
|
5 |
* NOTICE OF LICENSE
|
6 |
+
* This source file is subject to the Open Software License (OSL 3.0) that is
|
7 |
+
* bundled with this package in the file LICENSE.txt. It is also available
|
8 |
+
* through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php If you did not receive a copy of
|
10 |
+
* the license and are unable to obtain it through the world-wide-web, please
|
11 |
+
* send an email to license@magentocommerce.com so we can send you a copy
|
12 |
+
* immediately.
|
|
|
|
|
13 |
* DISCLAIMER
|
|
|
14 |
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
15 |
+
* versions in the future. If you wish to customize Magento for your needs
|
16 |
+
* please refer to http://www.magentocommerce.com for more information.
|
17 |
*
|
18 |
+
* @category Mage
|
19 |
+
* @package Mage_Payment
|
20 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
21 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License
|
22 |
+
* (OSL 3.0)
|
23 |
*/
|
|
|
|
|
24 |
class Litle_CreditCard_Block_Form_CreditCard extends Mage_Payment_Block_Form
|
25 |
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
*
|
29 |
+
* @var array
|
30 |
+
*/
|
31 |
+
protected $_storedCards = null;
|
32 |
+
|
33 |
+
protected function _construct()
|
34 |
+
{
|
35 |
+
parent::_construct();
|
36 |
+
$this->setTemplate('litle/form/litlecc.phtml');
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Retrieve payment configuration object
|
41 |
+
*
|
42 |
+
* @return Mage_Payment_Model_Config
|
43 |
+
*/
|
44 |
+
protected function _getConfig()
|
45 |
+
{
|
46 |
+
return Mage::getSingleton('payment/config');
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
public function getCurrency()
|
51 |
+
{
|
52 |
+
return Mage::app()->getStore()->getCurrentCurrencyCode();
|
53 |
+
}
|
54 |
+
|
55 |
+
public function getMerchantIdMap()
|
56 |
+
{
|
57 |
+
return Mage::getStoreConfig('payment/CreditCard/merchant_id');
|
58 |
+
}
|
59 |
+
|
60 |
+
public function getReportGroup()
|
61 |
+
{
|
62 |
+
$string2Eval = 'return array' . $this->getMerchantIdMap() . ";";
|
63 |
+
$merchant_map = eval($string2Eval);
|
64 |
+
$reportGroup = $merchant_map[$this->getCurrency()];
|
65 |
+
return $reportGroup;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Retrieve availables credit card types
|
70 |
+
*
|
71 |
+
* @return array
|
72 |
+
*/
|
73 |
+
public function getCcAvailableTypes()
|
74 |
+
{
|
75 |
+
$types = $this->_getConfig()->getCcTypes();
|
76 |
+
if ($method = $this->getMethod()) {
|
77 |
+
$availableTypes = $method->getConfigData('cctypes');
|
78 |
+
if ($availableTypes) {
|
79 |
+
$availableTypes = explode(',', $availableTypes);
|
80 |
+
foreach ($types as $code => $name) {
|
81 |
+
if (! in_array($code, $availableTypes)) {
|
82 |
+
unset($types[$code]);
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
return $types;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Retrieve credit card expire months
|
92 |
+
*
|
93 |
+
* @return array
|
94 |
+
*/
|
95 |
+
public function getCcMonths()
|
96 |
+
{
|
97 |
+
$months = $this->getData('cc_months');
|
98 |
+
if (is_null($months)) {
|
99 |
+
$months[0] = $this->__('Month');
|
100 |
+
$months = array_merge($months, $this->_getConfig()->getMonths());
|
101 |
+
$this->setData('cc_months', $months);
|
102 |
+
}
|
103 |
+
return $months;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Retrieve credit card expire years
|
108 |
+
*
|
109 |
+
* @return array
|
110 |
+
*/
|
111 |
+
public function getCcYears()
|
112 |
+
{
|
113 |
+
$years = $this->getData('cc_years');
|
114 |
+
if (is_null($years)) {
|
115 |
+
$years = $this->_getConfig()->getYears();
|
116 |
+
$years = array(
|
117 |
+
0 => $this->__('Year')
|
118 |
+
) + $years;
|
119 |
+
$this->setData('cc_years', $years);
|
120 |
+
}
|
121 |
+
return $years;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Retrive has verification configuration
|
126 |
+
*
|
127 |
+
* @return boolean
|
128 |
+
*/
|
129 |
+
public function hasVerification()
|
130 |
+
{
|
131 |
+
if ($this->getMethod()) {
|
132 |
+
$configData = $this->getMethod()->getConfigData('useccv');
|
133 |
+
if (is_null($configData)) {
|
134 |
+
return true;
|
135 |
+
}
|
136 |
+
return (bool) $configData;
|
137 |
+
}
|
138 |
+
return true;
|
139 |
+
}
|
140 |
+
|
141 |
+
/* Whether switch/solo card type available */
|
142 |
+
public function hasSsCardType()
|
143 |
+
{
|
144 |
+
$availableTypes = explode(',', $this->getMethod()->getConfigData('cctypes'));
|
145 |
+
$ssPresenations = array_intersect(array(
|
146 |
+
'SS',
|
147 |
+
'SM',
|
148 |
+
'SO'
|
149 |
+
), $availableTypes);
|
150 |
+
if ($availableTypes && count($ssPresenations) > 0) {
|
151 |
+
return true;
|
152 |
+
}
|
153 |
+
return false;
|
154 |
+
}
|
155 |
+
|
156 |
+
/* solo/switch card start year @return array */
|
157 |
+
public function getSsStartYears()
|
158 |
+
{
|
159 |
+
$years = array();
|
160 |
+
$first = date("Y");
|
161 |
+
|
162 |
+
for ($index = 5; $index >= 0; $index --) {
|
163 |
+
$year = $first - $index;
|
164 |
+
$years[$year] = $year;
|
165 |
+
}
|
166 |
+
$years = array(
|
167 |
+
0 => $this->__('Year')
|
168 |
+
) + $years;
|
169 |
+
return $years;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function getPaypageEnabled()
|
173 |
+
{
|
174 |
+
return Mage::getStoreConfig('payment/CreditCard/paypage_enable');
|
175 |
+
}
|
176 |
+
|
177 |
+
public function getVaultEnabled()
|
178 |
+
{
|
179 |
+
return Mage::helper('palorus')->isVaultEnabled();
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
*
|
184 |
+
* @return Litle_Palorus_Model_Mysql4_Vault_Collection
|
185 |
+
*/
|
186 |
+
public function getStoredCards()
|
187 |
+
{
|
188 |
+
if (is_null($this->_storedCards)) {
|
189 |
+
$this->_storedCards = Mage::getModel('palorus/vault')->getCollection()->addCustomerFilter(Mage::helper('palorus')->getCustomer());
|
190 |
+
}
|
191 |
+
return $this->_storedCards;
|
192 |
+
}
|
193 |
+
|
194 |
+
public function hasStoredCards()
|
195 |
+
{
|
196 |
+
if (count($this->getStoredCards())) {
|
197 |
+
return true;
|
198 |
+
}
|
199 |
+
return false;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Render block HTML
|
204 |
+
*
|
205 |
+
* @return string
|
206 |
+
*/
|
207 |
+
protected function _toHtml()
|
208 |
+
{
|
209 |
+
Mage::dispatchEvent('payment_form_block_to_html_before', array(
|
210 |
+
'block' => $this
|
211 |
+
));
|
212 |
+
return parent::_toHtml();
|
213 |
+
}
|
214 |
}
|
215 |
|
app/code/local/Litle/CreditCard/Helper/Data.php
CHANGED
@@ -27,40 +27,31 @@ class Litle_CreditCard_Helper_Data extends Mage_Core_Helper_Abstract
|
|
27 |
return ($this->isMOPLitleCC($mop) || $this->isMOPLitleECheck($mop));
|
28 |
}
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
$
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
$
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
42 |
}
|
43 |
-
|
44 |
-
return $this->populateStoredCreditCard($purchases);
|
45 |
}
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
$setter = 1;
|
57 |
-
}
|
58 |
-
}
|
59 |
-
if ($setter === 0)
|
60 |
-
{
|
61 |
-
array_push($unique, $purchases[$y]);
|
62 |
-
}
|
63 |
-
}
|
64 |
-
return $unique;
|
65 |
}
|
66 |
}
|
27 |
return ($this->isMOPLitleCC($mop) || $this->isMOPLitleECheck($mop));
|
28 |
}
|
29 |
|
30 |
+
// This method converts dollars to cents, and takes care of trailing decimals if any.
|
31 |
+
public function formatAmount($amountInDecimal, $roundUp) {
|
32 |
+
if( empty($amountInDecimal) || $amountInDecimal === "" )
|
33 |
+
return $amountInDecimal;
|
34 |
+
|
35 |
+
$amountInCents = ((double)$amountInDecimal) * 100;
|
36 |
+
$amountToReturn = (int)$amountInCents;
|
37 |
+
|
38 |
+
// check to see if we have left over decimals -- i.e. the incoming amount had more than 2 decimals
|
39 |
+
if( $amountInCents != (double)$amountToReturn)
|
40 |
+
{
|
41 |
+
// yes, more decimals than needed indeed!
|
42 |
+
$amountToReturn = ($roundUp) ? ($amountToReturn + 1) : ($amountToReturn);
|
43 |
}
|
44 |
+
return $amountToReturn;
|
|
|
45 |
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Are we using the sandbox?
|
49 |
+
*
|
50 |
+
* @return boolean
|
51 |
+
*/
|
52 |
+
public function isSandbox()
|
53 |
+
{
|
54 |
+
$url = Mage::getStoreConfig('payment/CreditCard/url');
|
55 |
+
return (stristr($url, '.testlitle.com/sandbox') !== false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
}
|
57 |
}
|
app/code/local/Litle/CreditCard/Model/Order/Payment.php
CHANGED
@@ -32,12 +32,12 @@ class Litle_CreditCard_Model_Order_Payment extends Mage_Sales_Model_Order_Paymen
|
|
32 |
if ($this->_isTransactionExists()) {
|
33 |
return $this;
|
34 |
}
|
35 |
-
|
36 |
foreach($order->getItemsCollection() as $item){
|
37 |
if ($item->getQtyRefunded() > 0)
|
38 |
$item->setQtyRefunded(0)->save();
|
39 |
}
|
40 |
-
|
41 |
$order
|
42 |
->setBaseDiscountRefunded(0)
|
43 |
->setBaseShippingRefunded(0)
|
@@ -55,7 +55,7 @@ class Litle_CreditCard_Model_Order_Payment extends Mage_Sales_Model_Order_Paymen
|
|
55 |
->setSubtotalRefunded(0)
|
56 |
->setTaxRefunded(0)
|
57 |
->setTotalRefunded(0)->save();
|
58 |
-
|
59 |
// update transactions, order state and add comments
|
60 |
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID, null, true);
|
61 |
$message = $this->hasMessage() ? $this->getMessage() : "Voided Refund.";
|
@@ -88,7 +88,7 @@ class Litle_CreditCard_Model_Order_Payment extends Mage_Sales_Model_Order_Paymen
|
|
88 |
$orderItem->setRowInvoiced(0);
|
89 |
$orderItem->setBaseRowInvoiced(0);
|
90 |
}
|
91 |
-
|
92 |
$order
|
93 |
->setBaseDiscountInvoiced(0)
|
94 |
->setBaseShippingInvoiced(0)
|
@@ -107,19 +107,19 @@ class Litle_CreditCard_Model_Order_Payment extends Mage_Sales_Model_Order_Paymen
|
|
107 |
->setBaseShippingTaxInvoiced(0)
|
108 |
->setTotalPaid(0)
|
109 |
->setBaseTotalPaid(0);
|
110 |
-
|
111 |
$this->setBaseShippingCaptured(0);
|
112 |
$this->setShippingCaptured(0);
|
113 |
$this->setAmountPaid(0);
|
114 |
$this->setBaseAmountPaid(0);
|
115 |
$this->setBaseAmountPaidOnline(0);
|
116 |
-
|
117 |
$order->setBaseGrandTotal($order->getGrandTotal());
|
118 |
-
|
119 |
foreach ($order->getInvoiceCollection() as $invoice) {
|
120 |
-
$invoice->setState(
|
121 |
}
|
122 |
-
|
123 |
|
124 |
|
125 |
// update transactions, order state and add comments
|
@@ -129,7 +129,7 @@ class Litle_CreditCard_Model_Order_Payment extends Mage_Sales_Model_Order_Paymen
|
|
129 |
$message = $this->_appendTransactionToMessage($transaction, $message);
|
130 |
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
|
131 |
}
|
132 |
-
|
133 |
|
134 |
/**
|
135 |
* Void payment either online or offline (process void notification)
|
32 |
if ($this->_isTransactionExists()) {
|
33 |
return $this;
|
34 |
}
|
35 |
+
|
36 |
foreach($order->getItemsCollection() as $item){
|
37 |
if ($item->getQtyRefunded() > 0)
|
38 |
$item->setQtyRefunded(0)->save();
|
39 |
}
|
40 |
+
|
41 |
$order
|
42 |
->setBaseDiscountRefunded(0)
|
43 |
->setBaseShippingRefunded(0)
|
55 |
->setSubtotalRefunded(0)
|
56 |
->setTaxRefunded(0)
|
57 |
->setTotalRefunded(0)->save();
|
58 |
+
|
59 |
// update transactions, order state and add comments
|
60 |
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID, null, true);
|
61 |
$message = $this->hasMessage() ? $this->getMessage() : "Voided Refund.";
|
88 |
$orderItem->setRowInvoiced(0);
|
89 |
$orderItem->setBaseRowInvoiced(0);
|
90 |
}
|
91 |
+
|
92 |
$order
|
93 |
->setBaseDiscountInvoiced(0)
|
94 |
->setBaseShippingInvoiced(0)
|
107 |
->setBaseShippingTaxInvoiced(0)
|
108 |
->setTotalPaid(0)
|
109 |
->setBaseTotalPaid(0);
|
110 |
+
|
111 |
$this->setBaseShippingCaptured(0);
|
112 |
$this->setShippingCaptured(0);
|
113 |
$this->setAmountPaid(0);
|
114 |
$this->setBaseAmountPaid(0);
|
115 |
$this->setBaseAmountPaidOnline(0);
|
116 |
+
|
117 |
$order->setBaseGrandTotal($order->getGrandTotal());
|
118 |
+
|
119 |
foreach ($order->getInvoiceCollection() as $invoice) {
|
120 |
+
$invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_CANCELED)->save();
|
121 |
}
|
122 |
+
|
123 |
|
124 |
|
125 |
// update transactions, order state and add comments
|
129 |
$message = $this->_appendTransactionToMessage($transaction, $message);
|
130 |
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
|
131 |
}
|
132 |
+
|
133 |
|
134 |
/**
|
135 |
* Void payment either online or offline (process void notification)
|
app/code/local/Litle/CreditCard/Model/PaymentLogic.php
CHANGED
@@ -1,72 +1,74 @@
|
|
1 |
<?php
|
2 |
-
require_once('Litle/LitleSDK/LitleOnline.php');
|
3 |
|
4 |
class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
|
5 |
{
|
|
|
6 |
/**
|
7 |
* unique internal payment method identifier
|
8 |
*/
|
9 |
protected $_code = 'creditcard';
|
10 |
|
11 |
protected $_formBlockType = 'creditcard/form_creditCard';
|
|
|
12 |
/**
|
13 |
-
* this should probably be true if you're using this
|
14 |
-
* method to take payments
|
15 |
*/
|
16 |
-
protected $_isGateway
|
17 |
|
18 |
/**
|
19 |
* can this method authorise?
|
20 |
*/
|
21 |
-
protected $_canAuthorize
|
22 |
|
23 |
/**
|
24 |
* can this method capture funds?
|
25 |
*/
|
26 |
-
protected $_canCapture
|
27 |
|
28 |
/**
|
29 |
* can we capture only partial amounts?
|
30 |
*/
|
31 |
-
protected $_canCapturePartial
|
32 |
|
33 |
/**
|
34 |
* can this method refund?
|
35 |
*/
|
36 |
-
protected $_canRefund
|
37 |
|
38 |
-
protected $_canRefundInvoicePartial
|
39 |
|
40 |
/**
|
41 |
* can this method void transactions?
|
42 |
*/
|
43 |
-
protected $_canVoid
|
44 |
|
45 |
/**
|
46 |
* can admins use this payment method?
|
47 |
*/
|
48 |
-
protected $_canUseInternal
|
49 |
|
50 |
/**
|
51 |
* show this method on the checkout page
|
52 |
*/
|
53 |
-
protected $_canUseCheckout
|
54 |
|
55 |
/**
|
56 |
* available for multi shipping checkouts?
|
57 |
*/
|
58 |
-
protected $_canUseForMultishipping
|
59 |
|
60 |
/**
|
61 |
* can this method save cc info for later use?
|
62 |
*/
|
63 |
protected $_canSaveCc = false;
|
64 |
|
65 |
-
public function getConfigData($fieldToLookFor, $store =
|
66 |
{
|
67 |
$returnFromThisModel = Mage::getStoreConfig('payment/CreditCard/' . $fieldToLookFor);
|
68 |
-
if(
|
69 |
-
|
|
|
70 |
|
71 |
return $returnFromThisModel;
|
72 |
}
|
@@ -74,48 +76,50 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
|
|
74 |
public function isFromVT($payment, $txnType)
|
75 |
{
|
76 |
$parentTxnId = $payment->getParentTransactionId();
|
77 |
-
if(
|
78 |
-
|
79 |
-
|
80 |
}
|
81 |
}
|
82 |
|
83 |
public function assignData($data)
|
84 |
{
|
85 |
-
if( $
|
86 |
-
|
87 |
-
|
88 |
-
$data = new Varien_Object($data);
|
89 |
-
}
|
90 |
|
|
|
91 |
$info = $this->getInfoInstance();
|
92 |
$info->setAdditionalInformation('paypage_enabled', $data->getPaypageEnabled());
|
93 |
$info->setAdditionalInformation('paypage_registration_id', $data->getPaypageRegistrationId());
|
94 |
$info->setAdditionalInformation('paypage_order_id', $data->getOrderId());
|
95 |
$info->setAdditionalInformation('cc_vaulted', $data->getCcVaulted());
|
|
|
96 |
}
|
97 |
-
return parent::assignData($data);
|
98 |
-
}
|
99 |
|
|
|
|
|
|
|
|
|
100 |
|
|
|
|
|
101 |
|
102 |
public function validate()
|
103 |
{
|
104 |
-
//no cc validation required.
|
105 |
return $this;
|
106 |
}
|
107 |
|
108 |
public function litleCcTypeEnum(Varien_Object $payment)
|
109 |
{
|
110 |
-
$typeEnum =
|
111 |
-
if ($payment->getCcType() ==
|
112 |
-
$typeEnum =
|
113 |
-
}
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
else{
|
118 |
-
$typeEnum =$payment->getCcType();
|
119 |
}
|
120 |
return $typeEnum;
|
121 |
}
|
@@ -123,56 +127,67 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
|
|
123 |
public function getCreditCardInfo(Varien_Object $payment)
|
124 |
{
|
125 |
$retArray = array();
|
126 |
-
$retArray[
|
127 |
-
$retArray[
|
128 |
-
preg_match(
|
129 |
-
$retArray[
|
130 |
-
$retArray[
|
131 |
|
132 |
return $retArray;
|
133 |
}
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
public function getPaypageInfo($payment)
|
136 |
{
|
137 |
$info = $this->getInfoInstance();
|
138 |
|
139 |
$retArray = array();
|
140 |
-
$retArray[
|
141 |
-
$retArray[
|
142 |
-
preg_match(
|
143 |
-
$retArray[
|
144 |
-
$retArray[
|
145 |
|
146 |
return $retArray;
|
147 |
}
|
148 |
|
149 |
public function getTokenInfo($payment)
|
150 |
{
|
151 |
-
$
|
152 |
-
|
153 |
-
$vaultIndex = $info->getAdditionalInformation('cc_vaulted');
|
154 |
-
$purchases = Mage::helper('creditcard')->uniqueCreditCard(Mage::helper('customer')->getCustomer()->getEntityId());
|
155 |
|
156 |
$retArray = array();
|
157 |
-
$retArray[
|
158 |
-
$retArray[
|
159 |
-
$retArray[
|
160 |
-
|
161 |
-
$payment->
|
|
|
|
|
162 |
return $retArray;
|
163 |
}
|
164 |
-
|
165 |
-
public function creditCardOrPaypageOrToken($payment)
|
|
|
166 |
$info = $this->getInfoInstance();
|
167 |
$vaultIndex = $info->getAdditionalInformation('cc_vaulted');
|
168 |
$payment_hash = array();
|
169 |
-
if ($vaultIndex > 0){
|
170 |
$payment_hash['token'] = $this->getTokenInfo($payment);
|
171 |
-
}
|
172 |
-
elseif ($info->getAdditionalInformation('paypage_enabled') == "1" ){
|
173 |
$payment_hash['paypage'] = $this->getPaypageInfo($payment);
|
174 |
-
}
|
175 |
-
else{
|
176 |
$payment_hash['card'] = $this->getCreditCardInfo($payment);
|
177 |
}
|
178 |
return $payment_hash;
|
@@ -180,184 +195,187 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
|
|
180 |
|
181 |
public function getContactInformation($contactInfo)
|
182 |
{
|
183 |
-
if(!empty($contactInfo)){
|
184 |
$retArray = array();
|
185 |
-
$retArray[
|
186 |
-
$retArray[
|
187 |
-
$retArray[
|
188 |
-
$retArray[
|
189 |
-
$retArray[
|
190 |
-
$retArray[
|
191 |
-
$retArray[
|
192 |
-
$retArray[
|
193 |
-
$retArray[
|
194 |
-
$retArray[
|
195 |
-
$retArray[
|
196 |
-
$retArray[
|
197 |
return $retArray;
|
198 |
}
|
199 |
-
return
|
200 |
}
|
201 |
|
202 |
-
|
203 |
public function getBillToAddress(Varien_Object $payment)
|
204 |
{
|
205 |
$order = $payment->getOrder();
|
206 |
-
if(!empty($order)){
|
207 |
-
$billing = $order
|
208 |
-
if(!empty($billing)){
|
209 |
return $this->getContactInformation($billing);
|
210 |
}
|
211 |
}
|
212 |
-
return
|
213 |
}
|
214 |
|
215 |
public function getShipToAddress(Varien_Object $payment)
|
216 |
{
|
217 |
$order = $payment->getOrder();
|
218 |
-
if(!empty($order)){
|
219 |
$shipping = $order->getShippingAddress();
|
220 |
-
if(!empty($shipping)){
|
221 |
return $this->getContactInformation($shipping);
|
222 |
}
|
223 |
}
|
224 |
-
return
|
225 |
}
|
226 |
|
227 |
-
|
228 |
public function getIpAddress(Varien_Object $payment)
|
229 |
{
|
230 |
$order = $payment->getOrder();
|
231 |
-
if(!empty($order)){
|
232 |
return $order->getRemoteIp();
|
233 |
}
|
234 |
-
return
|
235 |
}
|
236 |
|
237 |
-
|
238 |
-
|
239 |
-
public function getMerchantId(Varien_Object $payment){
|
240 |
$order = $payment->getOrder();
|
241 |
$currency = $order->getOrderCurrencyCode();
|
242 |
-
$string2Eval = 'return array' . $this->getConfigData(
|
243 |
$merchant_map = eval($string2Eval);
|
244 |
$merchantId = $merchant_map[$currency];
|
245 |
return $merchantId;
|
246 |
}
|
247 |
|
248 |
-
|
249 |
public function merchantData(Varien_Object $payment)
|
250 |
{
|
251 |
$order = $payment->getOrder();
|
252 |
-
$hash = array(
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
|
|
262 |
);
|
263 |
return $hash;
|
264 |
}
|
265 |
|
266 |
-
|
267 |
-
|
268 |
$retArray = array();
|
269 |
|
270 |
-
if (strlen($url)>13){
|
271 |
-
$url = str_replace('http://',''
|
272 |
-
$url = str_replace('https://',''
|
273 |
-
$url_temp = explode('/'
|
274 |
$url = $url_temp['0'];
|
275 |
-
if (strlen($url)>13){
|
276 |
-
$url = str_replace('www.',''
|
277 |
-
if (strlen($url)>13){
|
278 |
-
$url_temp2 = explode('.'
|
279 |
$count = count($url_temp2);
|
280 |
-
}
|
281 |
-
|
|
|
282 |
$url = $url_temp2['0'];
|
283 |
-
}else{
|
284 |
$url = $url_temp2['0'] . '.' . $url_temp2['1'];
|
285 |
}
|
286 |
}
|
287 |
}
|
288 |
}
|
289 |
-
|
290 |
-
$url = substr($url,0,13);
|
291 |
-
if(substr($url,12) === '.'){
|
292 |
-
$url = substr($url,0,12);
|
293 |
-
}
|
294 |
-
|
295 |
-
$url = substr($url,1,12);
|
296 |
}
|
297 |
$retArray['url'] = $url;
|
298 |
|
299 |
return $retArray;
|
300 |
}
|
301 |
|
302 |
-
public function getOrderDate(Varien_Object $payment)
|
|
|
303 |
$order = $payment->getOrder();
|
304 |
$date = $order->getCreatedAtFormated(short);
|
305 |
-
$date_temp = explode('/'
|
306 |
$month = $date_temp['0'];
|
307 |
-
if ((int)$month < 10){
|
308 |
$month = '0' . $month;
|
309 |
}
|
310 |
-
$day
|
311 |
-
if ((int)$day < 10){
|
312 |
$day = '0' . $day;
|
313 |
}
|
314 |
-
$year_temp = explode(' '
|
315 |
$year = '20' . $year_temp['0'];
|
316 |
return $year . '-' . $month . '-' . $day;
|
317 |
}
|
318 |
|
319 |
-
public function getLineItemData(Varien_Object $payment)
|
|
|
320 |
$order = $payment->getOrder();
|
321 |
$items = $order->getAllItems();
|
322 |
$i = 0;
|
323 |
$lineItemArray = array();
|
324 |
-
foreach ($items as $itemId => $item)
|
325 |
-
{
|
326 |
$name = $item->getName();
|
327 |
-
$unitPrice
|
328 |
-
$sku
|
329 |
-
$ids
|
330 |
-
$qty
|
331 |
-
|
332 |
-
if(
|
333 |
-
$name = substr($name,0,26);
|
334 |
-
|
335 |
$lineItemArray[$i] = array(
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
|
|
343 |
}
|
344 |
return $lineItemArray;
|
345 |
}
|
346 |
|
347 |
-
|
348 |
public function getEnhancedData(Varien_Object $payment)
|
349 |
{
|
350 |
$order = $payment->getOrder();
|
351 |
$billing = $order->getBillingAddress();
|
352 |
-
|
353 |
-
$hash = array(
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
|
|
|
|
|
|
|
|
|
|
361 |
);
|
362 |
return $hash;
|
363 |
}
|
@@ -365,255 +383,319 @@ class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
|
|
365 |
public function getFraudCheck(Varien_Object $payment)
|
366 |
{
|
367 |
$order = $payment->getOrder();
|
368 |
-
$hash = array(
|
|
|
369 |
);
|
370 |
return $hash;
|
371 |
}
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
$new = $litleResponse->getElementsByTagName($parentNode)->item(0);
|
|
|
|
|
|
|
|
|
|
|
377 |
}
|
378 |
-
|
379 |
-
$new = $litleResponse->getElementsByTagName($parentNode)->item(0)->getElementsByTagName($childNode)->item(0)->nodeValue;
|
380 |
-
}
|
381 |
-
|
382 |
return $new;
|
383 |
}
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
$payment->
|
398 |
-
|
399 |
-
$payment->
|
400 |
-
|
401 |
-
|
|
|
|
|
|
|
402 |
}
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
else
|
433 |
-
throw new Mage_Payment_Model_Info_Exception(
|
|
|
|
|
434 |
}
|
435 |
-
}
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
->setIsTransactionClosed(0)
|
444 |
-
->setTransactionAdditionalInfo("additional_information", XMLParser::getNode($litleResponse,'message'));
|
445 |
-
|
446 |
}
|
447 |
return true;
|
448 |
}
|
449 |
-
}
|
450 |
-
else{
|
451 |
Mage::throwException($message);
|
452 |
}
|
453 |
-
|
454 |
-
|
455 |
}
|
|
|
456 |
/**
|
457 |
-
* this method is called if we are just authorising
|
458 |
-
* a transaction
|
459 |
*/
|
460 |
public function authorize(Varien_Object $payment, $amount)
|
461 |
{
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
->setStatus(
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
}
|
472 |
-
else{
|
473 |
$order = $payment->getOrder();
|
474 |
-
$orderId =
|
475 |
-
$amountToPass = ($amount
|
476 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
477 |
$hash = array(
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
|
|
|
|
486 |
);
|
|
|
|
|
|
|
487 |
$payment_hash = $this->creditCardOrPaypageOrToken($payment);
|
488 |
-
$hash_temp = array_merge($hash
|
489 |
$merchantData = $this->merchantData($payment);
|
490 |
-
$hash_in = array_merge($hash_temp
|
|
|
491 |
$litleRequest = new LitleOnlineRequest();
|
492 |
$litleResponse = $litleRequest->authorizationRequest($hash_in);
|
493 |
-
$this->processResponse($payment
|
494 |
-
|
495 |
-
Mage::helper(
|
|
|
|
|
|
|
496 |
}
|
497 |
}
|
|
|
|
|
498 |
}
|
499 |
|
500 |
/**
|
501 |
-
* this method is called if we are authorising AND
|
502 |
-
* capturing a transaction
|
503 |
*/
|
504 |
-
public function capture
|
505 |
{
|
506 |
-
if (preg_match(
|
507 |
-
|
508 |
-
$payment
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
->setCcType("Litle VT");
|
515 |
|
516 |
return;
|
517 |
}
|
518 |
|
519 |
-
$this->isFromVT($payment,
|
520 |
|
521 |
$order = $payment->getOrder();
|
522 |
-
if (!empty($order)){
|
|
|
|
|
|
|
|
|
523 |
|
524 |
-
$orderId
|
525 |
-
$amountToPass = ($amount
|
526 |
-
$isPartialCapture = ($amount < $order->getGrandTotal()) ?
|
527 |
-
$isSale = ($payment->getCcTransId() !=
|
528 |
|
529 |
-
if(
|
530 |
-
{
|
531 |
$hash = array(
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
);
|
536 |
} else {
|
537 |
$hash_temp = array(
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
|
|
543 |
);
|
544 |
$payment_hash = $this->creditCardOrPaypageOrToken($payment);
|
545 |
-
$hash = array_merge($hash_temp
|
546 |
}
|
547 |
$merchantData = $this->merchantData($payment);
|
548 |
-
$hash_in = array_merge($hash
|
549 |
$litleRequest = new LitleOnlineRequest();
|
550 |
|
551 |
-
if(
|
552 |
-
{
|
553 |
$litleResponse = $litleRequest->saleRequest($hash_in);
|
554 |
-
Mage::helper(
|
555 |
-
Mage::helper("palorus")->saveVault($payment, $litleResponse);
|
556 |
} else {
|
557 |
$litleResponse = $litleRequest->captureRequest($hash_in);
|
558 |
}
|
|
|
|
|
|
|
|
|
559 |
}
|
560 |
-
$this->processResponse($payment
|
|
|
|
|
561 |
}
|
562 |
|
563 |
/**
|
564 |
* called if refunding
|
565 |
*/
|
566 |
-
public function refund
|
567 |
{
|
568 |
-
$this->isFromVT($payment,
|
569 |
-
|
570 |
$order = $payment->getOrder();
|
571 |
$isPartialRefund = ($amount < $order->getGrandTotal()) ? true : false;
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
return $this;
|
587 |
}
|
588 |
|
589 |
/**
|
590 |
* called if voiding a payment
|
591 |
*/
|
592 |
-
public function void
|
593 |
{
|
594 |
-
$this->isFromVT($payment,
|
595 |
|
596 |
$order = $payment->getOrder();
|
597 |
-
if (!empty($order)){
|
598 |
$hash = array(
|
599 |
-
|
600 |
);
|
601 |
$merchantData = $this->merchantData($payment);
|
602 |
-
$hash_in = array_merge($hash
|
603 |
$litleRequest = new LitleOnlineRequest();
|
604 |
-
|
605 |
-
if(Mage::helper(
|
|
|
606 |
$litleResponse = $litleRequest->authReversalRequest($hash_in);
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
}
|
611 |
-
$this->processResponse($payment
|
|
|
|
|
612 |
}
|
613 |
-
|
614 |
public function cancel(Varien_Object $payment)
|
615 |
{
|
616 |
$this->void($payment);
|
617 |
-
}
|
618 |
|
|
|
|
|
|
|
619 |
}
|
1 |
<?php
|
2 |
+
require_once ('Litle/LitleSDK/LitleOnline.php');
|
3 |
|
4 |
class Litle_CreditCard_Model_PaymentLogic extends Mage_Payment_Model_Method_Cc
|
5 |
{
|
6 |
+
|
7 |
/**
|
8 |
* unique internal payment method identifier
|
9 |
*/
|
10 |
protected $_code = 'creditcard';
|
11 |
|
12 |
protected $_formBlockType = 'creditcard/form_creditCard';
|
13 |
+
|
14 |
/**
|
15 |
+
* this should probably be true if you're using this method to take payments
|
|
|
16 |
*/
|
17 |
+
protected $_isGateway = true;
|
18 |
|
19 |
/**
|
20 |
* can this method authorise?
|
21 |
*/
|
22 |
+
protected $_canAuthorize = true;
|
23 |
|
24 |
/**
|
25 |
* can this method capture funds?
|
26 |
*/
|
27 |
+
protected $_canCapture = true;
|
28 |
|
29 |
/**
|
30 |
* can we capture only partial amounts?
|
31 |
*/
|
32 |
+
protected $_canCapturePartial = true;
|
33 |
|
34 |
/**
|
35 |
* can this method refund?
|
36 |
*/
|
37 |
+
protected $_canRefund = true;
|
38 |
|
39 |
+
protected $_canRefundInvoicePartial = true;
|
40 |
|
41 |
/**
|
42 |
* can this method void transactions?
|
43 |
*/
|
44 |
+
protected $_canVoid = true;
|
45 |
|
46 |
/**
|
47 |
* can admins use this payment method?
|
48 |
*/
|
49 |
+
protected $_canUseInternal = true;
|
50 |
|
51 |
/**
|
52 |
* show this method on the checkout page
|
53 |
*/
|
54 |
+
protected $_canUseCheckout = true;
|
55 |
|
56 |
/**
|
57 |
* available for multi shipping checkouts?
|
58 |
*/
|
59 |
+
protected $_canUseForMultishipping = true;
|
60 |
|
61 |
/**
|
62 |
* can this method save cc info for later use?
|
63 |
*/
|
64 |
protected $_canSaveCc = false;
|
65 |
|
66 |
+
public function getConfigData($fieldToLookFor, $store = null)
|
67 |
{
|
68 |
$returnFromThisModel = Mage::getStoreConfig('payment/CreditCard/' . $fieldToLookFor);
|
69 |
+
if (is_null($returnFromThisModel)) {
|
70 |
+
$returnFromThisModel = parent::getConfigData($fieldToLookFor, $store);
|
71 |
+
}
|
72 |
|
73 |
return $returnFromThisModel;
|
74 |
}
|
76 |
public function isFromVT($payment, $txnType)
|
77 |
{
|
78 |
$parentTxnId = $payment->getParentTransactionId();
|
79 |
+
if ($parentTxnId == 'Litle VT') {
|
80 |
+
Mage::throwException(
|
81 |
+
"This order was placed using Litle Virtual Terminal. Please process the $txnType by logging into Litle Virtual Terminal (https://vt.litle.com).");
|
82 |
}
|
83 |
}
|
84 |
|
85 |
public function assignData($data)
|
86 |
{
|
87 |
+
if (! ($data instanceof Varien_Object)) {
|
88 |
+
$data = new Varien_Object($data);
|
89 |
+
}
|
|
|
|
|
90 |
|
91 |
+
if ($this->getConfigData('paypage_enabled')) {
|
92 |
$info = $this->getInfoInstance();
|
93 |
$info->setAdditionalInformation('paypage_enabled', $data->getPaypageEnabled());
|
94 |
$info->setAdditionalInformation('paypage_registration_id', $data->getPaypageRegistrationId());
|
95 |
$info->setAdditionalInformation('paypage_order_id', $data->getOrderId());
|
96 |
$info->setAdditionalInformation('cc_vaulted', $data->getCcVaulted());
|
97 |
+
$info->setAdditionalInformation('cc_should_save', $data->getCcShouldSave());
|
98 |
}
|
|
|
|
|
99 |
|
100 |
+
if ($this->getConfigData('vault_enable')) {
|
101 |
+
$info->setAdditionalInformation('cc_vaulted', $data->getCcVaulted());
|
102 |
+
$info->setAdditionalInformation('cc_should_save', $data->getCcShouldSave());
|
103 |
+
}
|
104 |
|
105 |
+
return parent::assignData($data);
|
106 |
+
}
|
107 |
|
108 |
public function validate()
|
109 |
{
|
110 |
+
// no cc validation required.
|
111 |
return $this;
|
112 |
}
|
113 |
|
114 |
public function litleCcTypeEnum(Varien_Object $payment)
|
115 |
{
|
116 |
+
$typeEnum = '';
|
117 |
+
if ($payment->getCcType() == 'AE') {
|
118 |
+
$typeEnum = 'AX';
|
119 |
+
} elseif ($payment->getCcType() == 'JCB') {
|
120 |
+
$typeEnum = 'JC';
|
121 |
+
} else {
|
122 |
+
$typeEnum = $payment->getCcType();
|
|
|
|
|
123 |
}
|
124 |
return $typeEnum;
|
125 |
}
|
127 |
public function getCreditCardInfo(Varien_Object $payment)
|
128 |
{
|
129 |
$retArray = array();
|
130 |
+
$retArray['type'] = $this->litleCcTypeEnum($payment);
|
131 |
+
$retArray['number'] = $payment->getCcNumber();
|
132 |
+
preg_match('/\d\d(\d\d)/', $payment->getCcExpYear(), $expYear);
|
133 |
+
$retArray['expDate'] = sprintf('%02d%02d', $payment->getCcExpMonth(), $expYear[1]);
|
134 |
+
$retArray['cardValidationNum'] = $payment->getCcCid();
|
135 |
|
136 |
return $retArray;
|
137 |
}
|
138 |
|
139 |
+
/**
|
140 |
+
* Return the last 4 digits of the card number.
|
141 |
+
*
|
142 |
+
* @param Varien_Object $payment
|
143 |
+
* @return string
|
144 |
+
*/
|
145 |
+
public function getCcLast4($payment)
|
146 |
+
{
|
147 |
+
$numbersOnly = preg_replace('/[^0-9]*/', '', $payment->getCcNumber());
|
148 |
+
return substr($numbersOnly, - 4, 4);
|
149 |
+
}
|
150 |
+
|
151 |
public function getPaypageInfo($payment)
|
152 |
{
|
153 |
$info = $this->getInfoInstance();
|
154 |
|
155 |
$retArray = array();
|
156 |
+
$retArray['type'] = $this->litleCcTypeEnum($payment);
|
157 |
+
$retArray['paypageRegistrationId'] = $info->getAdditionalInformation('paypage_registration_id');
|
158 |
+
preg_match('/\d\d(\d\d)/', $payment->getCcExpYear(), $expYear);
|
159 |
+
$retArray['expDate'] = sprintf('%02d%02d', $payment->getCcExpMonth(), $expYear[1]);
|
160 |
+
$retArray['cardValidationNum'] = $payment->getCcCid();
|
161 |
|
162 |
return $retArray;
|
163 |
}
|
164 |
|
165 |
public function getTokenInfo($payment)
|
166 |
{
|
167 |
+
$vaultIndex = $this->getInfoInstance()->getAdditionalInformation('cc_vaulted');
|
168 |
+
$vaultCard = Mage::getModel('palorus/vault')->load($vaultIndex);
|
|
|
|
|
169 |
|
170 |
$retArray = array();
|
171 |
+
$retArray['type'] = $vaultCard->getType();
|
172 |
+
$retArray['litleToken'] = $vaultCard->getToken();
|
173 |
+
$retArray['cardValidationNum'] = $payment->getCcCid();
|
174 |
+
|
175 |
+
$payment->setCcLast4($vaultCard->getLast4());
|
176 |
+
$payment->setCcType($vaultCard->getType());
|
177 |
+
|
178 |
return $retArray;
|
179 |
}
|
180 |
+
|
181 |
+
public function creditCardOrPaypageOrToken($payment)
|
182 |
+
{
|
183 |
$info = $this->getInfoInstance();
|
184 |
$vaultIndex = $info->getAdditionalInformation('cc_vaulted');
|
185 |
$payment_hash = array();
|
186 |
+
if ($vaultIndex > 0) {
|
187 |
$payment_hash['token'] = $this->getTokenInfo($payment);
|
188 |
+
} elseif ($info->getAdditionalInformation('paypage_enabled') == '1') {
|
|
|
189 |
$payment_hash['paypage'] = $this->getPaypageInfo($payment);
|
190 |
+
} else {
|
|
|
191 |
$payment_hash['card'] = $this->getCreditCardInfo($payment);
|
192 |
}
|
193 |
return $payment_hash;
|
195 |
|
196 |
public function getContactInformation($contactInfo)
|
197 |
{
|
198 |
+
if (! empty($contactInfo)) {
|
199 |
$retArray = array();
|
200 |
+
$retArray['firstName'] = $contactInfo->getFirstname();
|
201 |
+
$retArray['lastName'] = $contactInfo->getLastname();
|
202 |
+
$retArray['companyName'] = $contactInfo->getCompany();
|
203 |
+
$retArray['addressLine1'] = $contactInfo->getStreet(1);
|
204 |
+
$retArray['addressLine2'] = $contactInfo->getStreet(2);
|
205 |
+
$retArray['addressLine3'] = $contactInfo->getStreet(3);
|
206 |
+
$retArray['city'] = $contactInfo->getCity();
|
207 |
+
$retArray['state'] = $contactInfo->getRegion();
|
208 |
+
$retArray['zip'] = $contactInfo->getPostcode();
|
209 |
+
$retArray['country'] = $contactInfo->getCountry();
|
210 |
+
$retArray['email'] = $contactInfo->getCustomerEmail();
|
211 |
+
$retArray['phone'] = $contactInfo->getTelephone();
|
212 |
return $retArray;
|
213 |
}
|
214 |
+
return null;
|
215 |
}
|
216 |
|
|
|
217 |
public function getBillToAddress(Varien_Object $payment)
|
218 |
{
|
219 |
$order = $payment->getOrder();
|
220 |
+
if (! empty($order)) {
|
221 |
+
$billing = $order->getBillingAddress();
|
222 |
+
if (! empty($billing)) {
|
223 |
return $this->getContactInformation($billing);
|
224 |
}
|
225 |
}
|
226 |
+
return null;
|
227 |
}
|
228 |
|
229 |
public function getShipToAddress(Varien_Object $payment)
|
230 |
{
|
231 |
$order = $payment->getOrder();
|
232 |
+
if (! empty($order)) {
|
233 |
$shipping = $order->getShippingAddress();
|
234 |
+
if (! empty($shipping)) {
|
235 |
return $this->getContactInformation($shipping);
|
236 |
}
|
237 |
}
|
238 |
+
return null;
|
239 |
}
|
240 |
|
|
|
241 |
public function getIpAddress(Varien_Object $payment)
|
242 |
{
|
243 |
$order = $payment->getOrder();
|
244 |
+
if (! empty($order)) {
|
245 |
return $order->getRemoteIp();
|
246 |
}
|
247 |
+
return null;
|
248 |
}
|
249 |
|
250 |
+
public function getMerchantId(Varien_Object $payment)
|
251 |
+
{
|
|
|
252 |
$order = $payment->getOrder();
|
253 |
$currency = $order->getOrderCurrencyCode();
|
254 |
+
$string2Eval = 'return array' . $this->getConfigData('merchant_id') . ';';
|
255 |
$merchant_map = eval($string2Eval);
|
256 |
$merchantId = $merchant_map[$currency];
|
257 |
return $merchantId;
|
258 |
}
|
259 |
|
|
|
260 |
public function merchantData(Varien_Object $payment)
|
261 |
{
|
262 |
$order = $payment->getOrder();
|
263 |
+
$hash = array(
|
264 |
+
'user' => $this->getConfigData('user'),
|
265 |
+
'password' => $this->getConfigData('password'),
|
266 |
+
'merchantId' => $this->getMerchantId($payment),
|
267 |
+
'version' => '8.10',
|
268 |
+
'merchantSdk' => 'Magento;8.13.2',
|
269 |
+
'reportGroup' => $this->getMerchantId($payment),
|
270 |
+
'customerId' => $order->getCustomerEmail(),
|
271 |
+
'url' => $this->getConfigData('url'),
|
272 |
+
'proxy' => $this->getConfigData('proxy'),
|
273 |
+
'timeout' => $this->getConfigData('timeout')
|
274 |
);
|
275 |
return $hash;
|
276 |
}
|
277 |
|
278 |
+
public function getCustomBilling($url)
|
279 |
+
{
|
280 |
$retArray = array();
|
281 |
|
282 |
+
if (strlen($url) > 13) {
|
283 |
+
$url = str_replace('http://', '', $url);
|
284 |
+
$url = str_replace('https://', '', $url);
|
285 |
+
$url_temp = explode('/', $url);
|
286 |
$url = $url_temp['0'];
|
287 |
+
if (strlen($url) > 13) {
|
288 |
+
$url = str_replace('www.', '', $url);
|
289 |
+
if (strlen($url) > 13) {
|
290 |
+
$url_temp2 = explode('.', $url);
|
291 |
$count = count($url_temp2);
|
292 |
+
}
|
293 |
+
if ($count < 3) {
|
294 |
+
if (strlen($url_temp2['0'] . '.' . $url_temp2['1']) > 13) {
|
295 |
$url = $url_temp2['0'];
|
296 |
+
} else {
|
297 |
$url = $url_temp2['0'] . '.' . $url_temp2['1'];
|
298 |
}
|
299 |
}
|
300 |
}
|
301 |
}
|
302 |
+
|
303 |
+
$url = substr($url, 0, 13);
|
304 |
+
if (substr($url, 12) === '.') {
|
305 |
+
$url = substr($url, 0, 12);
|
306 |
+
} elseif (substr($url, 0) === '.') {
|
307 |
+
$url = substr($url, 1, 12);
|
|
|
308 |
}
|
309 |
$retArray['url'] = $url;
|
310 |
|
311 |
return $retArray;
|
312 |
}
|
313 |
|
314 |
+
public function getOrderDate(Varien_Object $payment)
|
315 |
+
{
|
316 |
$order = $payment->getOrder();
|
317 |
$date = $order->getCreatedAtFormated(short);
|
318 |
+
$date_temp = explode('/', $date);
|
319 |
$month = $date_temp['0'];
|
320 |
+
if ((int) $month < 10) {
|
321 |
$month = '0' . $month;
|
322 |
}
|
323 |
+
$day = $date_temp['1'];
|
324 |
+
if ((int) $day < 10) {
|
325 |
$day = '0' . $day;
|
326 |
}
|
327 |
+
$year_temp = explode(' ', $date_temp['2']);
|
328 |
$year = '20' . $year_temp['0'];
|
329 |
return $year . '-' . $month . '-' . $day;
|
330 |
}
|
331 |
|
332 |
+
public function getLineItemData(Varien_Object $payment)
|
333 |
+
{
|
334 |
$order = $payment->getOrder();
|
335 |
$items = $order->getAllItems();
|
336 |
$i = 0;
|
337 |
$lineItemArray = array();
|
338 |
+
foreach ($items as $itemId => $item) {
|
|
|
339 |
$name = $item->getName();
|
340 |
+
$unitPrice = $item->getPrice();
|
341 |
+
$sku = $item->getSku();
|
342 |
+
$ids = $item->getProductId();
|
343 |
+
$qty = $item->getQtyToInvoice();
|
344 |
+
|
345 |
+
if (strlen($name) > 26)
|
346 |
+
$name = substr($name, 0, 26);
|
347 |
+
|
348 |
$lineItemArray[$i] = array(
|
349 |
+
'itemSequenceNumber' => ($i + 1),
|
350 |
+
'itemDescription' => $name,
|
351 |
+
'productCode' => $ids,
|
352 |
+
'quantity' => $qty,
|
353 |
+
'lineItemTotal' => Mage::helper('creditcard')->formatAmount(($unitPrice * $qty), true),
|
354 |
+
'unitCost' => Mage::helper('creditcard')->formatAmount(($unitPrice), true)
|
355 |
+
);
|
356 |
+
$i ++;
|
357 |
}
|
358 |
return $lineItemArray;
|
359 |
}
|
360 |
|
|
|
361 |
public function getEnhancedData(Varien_Object $payment)
|
362 |
{
|
363 |
$order = $payment->getOrder();
|
364 |
$billing = $order->getBillingAddress();
|
365 |
+
|
366 |
+
$hash = array(
|
367 |
+
'salesTax' => Mage::helper('creditcard')->formatAmount($order->getTaxAmount(), true),
|
368 |
+
'discountAmount' => Mage::helper('creditcard')->formatAmount($order->getDiscountAmount(), true),
|
369 |
+
'shippingAmount' => Mage::helper('creditcard')->formatAmount($order->getShippingAmount(), true),
|
370 |
+
'destinationPostalCode' => $billing->getPostcode(),
|
371 |
+
'destinationCountryCode' => $billing->getCountry(),
|
372 |
+
'orderDate' => $this->getOrderDate($payment),
|
373 |
+
'detailTax' => array(
|
374 |
+
array(
|
375 |
+
'taxAmount' => Mage::helper('creditcard')->formatAmount($order->getTaxAmount(), true)
|
376 |
+
)
|
377 |
+
),
|
378 |
+
'lineItemData' => $this->getLineItemData($payment)
|
379 |
);
|
380 |
return $hash;
|
381 |
}
|
383 |
public function getFraudCheck(Varien_Object $payment)
|
384 |
{
|
385 |
$order = $payment->getOrder();
|
386 |
+
$hash = array(
|
387 |
+
'customerIpAddress' => $order->getRemoteIp()
|
388 |
);
|
389 |
return $hash;
|
390 |
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Parses Litle response to obtain update customer information.
|
394 |
+
*
|
395 |
+
* @param DOMDocument $litleResponse
|
396 |
+
* @param string $parentNode
|
397 |
+
* @param string $childNode
|
398 |
+
* @return DOMNode
|
399 |
+
*/
|
400 |
+
public function getUpdater($litleResponse, $parentNode, $childNode = null)
|
401 |
+
{
|
402 |
+
if (is_null($childNode)) {
|
403 |
$new = $litleResponse->getElementsByTagName($parentNode)->item(0);
|
404 |
+
} else {
|
405 |
+
$new = $litleResponse->getElementsByTagName($parentNode)
|
406 |
+
->item(0)
|
407 |
+
->getElementsByTagName($childNode)
|
408 |
+
->item(0)->nodeValue;
|
409 |
}
|
410 |
+
|
|
|
|
|
|
|
411 |
return $new;
|
412 |
}
|
413 |
+
|
414 |
+
/**
|
415 |
+
* Updates customer account information with most current from Litle.
|
416 |
+
*
|
417 |
+
* @param Varien_Object $payment
|
418 |
+
* @param DOMDocument $litleResponse
|
419 |
+
*/
|
420 |
+
public function accountUpdater(Varien_Object $payment, $litleResponse)
|
421 |
+
{
|
422 |
+
if ($this->getUpdater($litleResponse, 'newCardInfo') !== null) {
|
423 |
+
$payment->setCcLast4(
|
424 |
+
substr($this->getUpdater($litleResponse, 'newCardInfo', 'number'), - 4));
|
425 |
+
$payment->setCcType($this->getUpdater($litleResponse, 'newCardInfo', 'type'));
|
426 |
+
$payment->setCcExpDate($this->getUpdater($litleResponse, 'newCardInfo', 'expDate'));
|
427 |
+
} elseif ($this->getUpdater($litleResponse, 'newCardTokenInfo') !== null) {
|
428 |
+
$payment->setCcNumber($this->getUpdater($litleResponse, 'newCardTokenInfo', 'litleToken'));
|
429 |
+
$payment->setCcLast4(
|
430 |
+
substr($this->getUpdater($litleResponse, 'newCardTokenInfo', 'litleToken'), - 4));
|
431 |
+
$payment->setCcType($this->getUpdater($litleResponse, 'newCardTokenInfo', 'type'));
|
432 |
+
$payment->setCcExpDate($this->getUpdater($litleResponse, 'newCardTokenInfo', 'expDate'));
|
433 |
+
}
|
434 |
}
|
435 |
+
|
436 |
+
/**
|
437 |
+
* Update Vaulted card information.
|
438 |
+
*
|
439 |
+
* @param Varien_Object $payment
|
440 |
+
* @param DOMDocument $litleResponse
|
441 |
+
*/
|
442 |
+
protected function _saveToken(Varien_Object $payment, DOMDocument $litleResponse)
|
443 |
+
{
|
444 |
+
if (!is_null($this->getUpdater($litleResponse, 'tokenResponse')) &&
|
445 |
+
!is_null($this->getUpdater($litleResponse, 'tokenResponse', 'litleToken'))) {
|
446 |
+
|
447 |
+
$vault = Mage::getModel('palorus/vault')->setTokenFromPayment(
|
448 |
+
$payment,
|
449 |
+
$this->getUpdater($litleResponse, 'tokenResponse', 'litleToken'),
|
450 |
+
$this->getUpdater($litleResponse, 'tokenResponse', 'bin'));
|
451 |
+
|
452 |
+
$this->getInfoInstance()->setAdditionalInformation('vault_id', $vault->getId());
|
453 |
+
}
|
454 |
+
}
|
455 |
+
|
456 |
+
/**
|
457 |
+
*
|
458 |
+
* @param Varien_Object $payment
|
459 |
+
* @param DOMDocument $litleResponse
|
460 |
+
* @throws Mage_Payment_Model_Info_Exception
|
461 |
+
* @return boolean
|
462 |
+
*/
|
463 |
+
public function processResponse(Varien_Object $payment, $litleResponse)
|
464 |
+
{
|
465 |
+
$this->accountUpdater($payment, $litleResponse);
|
466 |
+
|
467 |
+
$message = XmlParser::getAttribute($litleResponse, 'litleOnlineResponse', 'message');
|
468 |
+
if ($message == 'Valid Format') {
|
469 |
+
$isSale = ($payment->getCcTransId() != null) ? false : true;
|
470 |
+
if (isset($litleResponse)) {
|
471 |
+
$litleResponseCode = XMLParser::getNode($litleResponse, 'response');
|
472 |
+
if ($litleResponseCode != '000') {
|
473 |
+
// Mage::throwException('response code is: ' .
|
474 |
+
// $litleResponseCode . 'txn type is: ');
|
475 |
+
if (($litleResponseCode === '362') && Mage::helper('creditcard')->isStateOfOrderEqualTo(
|
476 |
+
$payment->getOrder(), Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE)) {
|
477 |
+
Mage::throwException('The void did not go through. Do a refund instead.');
|
478 |
+
} else {
|
479 |
+
$payment->setStatus('Rejected')
|
480 |
+
->setCcTransId(XMLParser::getNode($litleResponse, 'litleTxnId'))
|
481 |
+
->setLastTransId(XMLParser::getNode($litleResponse, 'litleTxnId'))
|
482 |
+
->setTransactionId(XMLParser::getNode($litleResponse, 'litleTxnId'))
|
483 |
+
->setIsTransactionClosed(0)
|
484 |
+
->setTransactionAdditionalInfo('additional_information',
|
485 |
+
XMLParser::getNode($litleResponse, 'message'));
|
486 |
+
|
487 |
+
if ($isSale)
|
488 |
+
throw new Mage_Payment_Model_Info_Exception(
|
489 |
+
Mage::helper('core')->__(
|
490 |
+
'Transaction was not approved. Contact us or try again later.'));
|
491 |
else
|
492 |
+
throw new Mage_Payment_Model_Info_Exception(
|
493 |
+
Mage::helper('core')->__(
|
494 |
+
'Transaction was not approved. Contact Litle or try again later.'));
|
495 |
}
|
496 |
+
} else {
|
497 |
+
$payment->setStatus('Approved')
|
498 |
+
->setCcTransId(XMLParser::getNode($litleResponse, 'litleTxnId'))
|
499 |
+
->setLastTransId(XMLParser::getNode($litleResponse, 'litleTxnId'))
|
500 |
+
->setTransactionId(XMLParser::getNode($litleResponse, 'litleTxnId'))
|
501 |
+
->setIsTransactionClosed(0)
|
502 |
+
->setTransactionAdditionalInfo('additional_information',
|
503 |
+
XMLParser::getNode($litleResponse, 'message'));
|
|
|
|
|
|
|
504 |
}
|
505 |
return true;
|
506 |
}
|
507 |
+
} else {
|
|
|
508 |
Mage::throwException($message);
|
509 |
}
|
|
|
|
|
510 |
}
|
511 |
+
|
512 |
/**
|
513 |
+
* this method is called if we are just authorising a transaction
|
|
|
514 |
*/
|
515 |
public function authorize(Varien_Object $payment, $amount)
|
516 |
{
|
517 |
+
// @TODO This is the wrong way to do this.
|
518 |
+
if (preg_match('/sales_order_create/i', $_SERVER['REQUEST_URI']) &&
|
519 |
+
($this->getConfigData('paypage_enable') == '1')) {
|
520 |
+
$payment->setStatus('N/A')
|
521 |
+
->setCcTransId('Litle VT')
|
522 |
+
->setLastTransId('Litle VT')
|
523 |
+
->setTransactionId('Litle VT')
|
524 |
+
->setIsTransactionClosed(0)
|
525 |
+
->setCcType('Litle VT');
|
526 |
+
} else {
|
|
|
527 |
$order = $payment->getOrder();
|
528 |
+
$orderId = $order->getIncrementId();
|
529 |
+
$amountToPass = Mage::helper('creditcard')->formatAmount($amount, true);
|
530 |
+
|
531 |
+
if (! empty($order)) {
|
532 |
+
$info = $this->getInfoInstance();
|
533 |
+
if (!$info->getAdditionalInformation('orderSource')) {
|
534 |
+
$info->setAdditionalInformation('orderSource', 'ecommerce');
|
535 |
+
}
|
536 |
+
|
537 |
$hash = array(
|
538 |
+
'orderId' => $orderId,
|
539 |
+
'amount' => $amountToPass,
|
540 |
+
'orderSource' => $info->getAdditionalInformation('orderSource'),
|
541 |
+
'billToAddress' => $this->getBillToAddress($payment),
|
542 |
+
'shipToAddress' => $this->getAddressInfo($payment),
|
543 |
+
'cardholderAuthentication' => $this->getFraudCheck($payment),
|
544 |
+
'enhancedData' => $this->getEnhancedData($payment),
|
545 |
+
'customBilling' => $this->getCustomBilling(
|
546 |
+
Mage::app()->getStore()
|
547 |
+
->getBaseUrl())
|
548 |
);
|
549 |
+
|
550 |
+
|
551 |
+
|
552 |
$payment_hash = $this->creditCardOrPaypageOrToken($payment);
|
553 |
+
$hash_temp = array_merge($hash, $payment_hash);
|
554 |
$merchantData = $this->merchantData($payment);
|
555 |
+
$hash_in = array_merge($hash_temp, $merchantData);
|
556 |
+
|
557 |
$litleRequest = new LitleOnlineRequest();
|
558 |
$litleResponse = $litleRequest->authorizationRequest($hash_in);
|
559 |
+
$this->processResponse($payment, $litleResponse);
|
560 |
+
|
561 |
+
Mage::helper('palorus')->saveCustomerInsight($payment, $litleResponse);
|
562 |
+
if (!is_null($info->getAdditionalInformation('cc_should_save'))) {
|
563 |
+
$this->_saveToken($payment, $litleResponse);
|
564 |
+
}
|
565 |
}
|
566 |
}
|
567 |
+
|
568 |
+
return $this;
|
569 |
}
|
570 |
|
571 |
/**
|
572 |
+
* this method is called if we are authorising AND capturing a transaction
|
|
|
573 |
*/
|
574 |
+
public function capture(Varien_Object $payment, $amount)
|
575 |
{
|
576 |
+
if (preg_match('/sales_order_create/i', $_SERVER['REQUEST_URI']) &&
|
577 |
+
($this->getConfigData('paypage_enable') == '1')) {
|
578 |
+
$payment->setStatus('N/A')
|
579 |
+
->setCcTransId('Litle VT')
|
580 |
+
->setLastTransId('Litle VT')
|
581 |
+
->setTransactionId('Litle VT')
|
582 |
+
->setIsTransactionClosed(0)
|
583 |
+
->setCcType('Litle VT');
|
|
|
584 |
|
585 |
return;
|
586 |
}
|
587 |
|
588 |
+
$this->isFromVT($payment, 'capture');
|
589 |
|
590 |
$order = $payment->getOrder();
|
591 |
+
if (! empty($order)) {
|
592 |
+
$info = $this->getInfoInstance();
|
593 |
+
if (!$info->getAdditionalInformation('orderSource')) {
|
594 |
+
$info->setAdditionalInformation('orderSource', 'ecommerce');
|
595 |
+
}
|
596 |
|
597 |
+
$orderId = $order->getIncrementId();
|
598 |
+
$amountToPass = Mage::helper('creditcard')->formatAmount($amount, true);
|
599 |
+
$isPartialCapture = ($amount < $order->getGrandTotal()) ? 'true' : 'false';
|
600 |
+
$isSale = ($payment->getCcTransId() != null) ? false : true;
|
601 |
|
602 |
+
if (! $isSale) {
|
|
|
603 |
$hash = array(
|
604 |
+
'litleTxnId' => $payment->getParentTransactionId(),
|
605 |
+
'amount' => $amountToPass,
|
606 |
+
'partial' => $isPartialCapture
|
607 |
);
|
608 |
} else {
|
609 |
$hash_temp = array(
|
610 |
+
'orderId' => $orderId,
|
611 |
+
'amount' => $amountToPass,
|
612 |
+
'orderSource' => $info->getAdditionalInformation('orderSource'),
|
613 |
+
'billToAddress' => $this->getBillToAddress($payment),
|
614 |
+
'shipToAddress' => $this->getAddressInfo($payment),
|
615 |
+
'enhancedData' => $this->getEnhancedData($payment)
|
616 |
);
|
617 |
$payment_hash = $this->creditCardOrPaypageOrToken($payment);
|
618 |
+
$hash = array_merge($hash_temp, $payment_hash);
|
619 |
}
|
620 |
$merchantData = $this->merchantData($payment);
|
621 |
+
$hash_in = array_merge($hash, $merchantData);
|
622 |
$litleRequest = new LitleOnlineRequest();
|
623 |
|
624 |
+
if ($isSale) {
|
|
|
625 |
$litleResponse = $litleRequest->saleRequest($hash_in);
|
626 |
+
Mage::helper('palorus')->saveCustomerInsight($payment, $litleResponse);
|
|
|
627 |
} else {
|
628 |
$litleResponse = $litleRequest->captureRequest($hash_in);
|
629 |
}
|
630 |
+
|
631 |
+
if (! is_null($info->getAdditionalInformation('cc_should_save'))) {
|
632 |
+
$this->_saveToken($payment, $litleResponse);
|
633 |
+
}
|
634 |
}
|
635 |
+
$this->processResponse($payment, $litleResponse);
|
636 |
+
|
637 |
+
return $this;
|
638 |
}
|
639 |
|
640 |
/**
|
641 |
* called if refunding
|
642 |
*/
|
643 |
+
public function refund(Varien_Object $payment, $amount)
|
644 |
{
|
645 |
+
$this->isFromVT($payment, 'refund');
|
646 |
+
|
647 |
$order = $payment->getOrder();
|
648 |
$isPartialRefund = ($amount < $order->getGrandTotal()) ? true : false;
|
649 |
+
|
650 |
+
$amountToPass = Mage::helper('creditcard')->formatAmount($amount, true);
|
651 |
+
if (! empty($order)) {
|
652 |
+
$hash = array(
|
653 |
+
'litleTxnId' => $payment->getCcTransId(),
|
654 |
+
'amount' => $amountToPass
|
655 |
+
);
|
656 |
+
$merchantData = $this->merchantData($payment);
|
657 |
+
$hash_in = array_merge($hash, $merchantData);
|
658 |
+
$litleRequest = new LitleOnlineRequest();
|
659 |
+
$litleResponse = $litleRequest->creditRequest($hash_in);
|
660 |
+
}
|
661 |
+
$this->processResponse($payment, $litleResponse);
|
662 |
+
|
663 |
return $this;
|
664 |
}
|
665 |
|
666 |
/**
|
667 |
* called if voiding a payment
|
668 |
*/
|
669 |
+
public function void(Varien_Object $payment)
|
670 |
{
|
671 |
+
$this->isFromVT($payment, 'void');
|
672 |
|
673 |
$order = $payment->getOrder();
|
674 |
+
if (! empty($order)) {
|
675 |
$hash = array(
|
676 |
+
'litleTxnId' => $payment->getCcTransId()
|
677 |
);
|
678 |
$merchantData = $this->merchantData($payment);
|
679 |
+
$hash_in = array_merge($hash, $merchantData);
|
680 |
$litleRequest = new LitleOnlineRequest();
|
681 |
+
|
682 |
+
if (Mage::helper('creditcard')->isStateOfOrderEqualTo($order,
|
683 |
+
Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH)) {
|
684 |
$litleResponse = $litleRequest->authReversalRequest($hash_in);
|
685 |
+
} else {
|
686 |
+
$litleResponse = $litleRequest->voidRequest($hash_in);
|
687 |
+
}
|
688 |
}
|
689 |
+
$this->processResponse($payment, $litleResponse);
|
690 |
+
|
691 |
+
return $this;
|
692 |
}
|
693 |
+
|
694 |
public function cancel(Varien_Object $payment)
|
695 |
{
|
696 |
$this->void($payment);
|
|
|
697 |
|
698 |
+
|
699 |
+
return $this;
|
700 |
+
}
|
701 |
}
|
app/code/local/Litle/CreditCard/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Litle_CreditCard>
|
5 |
-
<version>8.13.
|
6 |
</Litle_CreditCard>
|
7 |
</modules>
|
8 |
<global>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Litle_CreditCard>
|
5 |
+
<version>8.13.3</version>
|
6 |
</Litle_CreditCard>
|
7 |
</modules>
|
8 |
<global>
|
app/code/local/Litle/CreditCard/etc/system.xml
CHANGED
@@ -111,31 +111,42 @@
|
|
111 |
<paypage_id translate="label">
|
112 |
<label>Paypage Id</label>
|
113 |
<frontend_type>text</frontend_type>
|
114 |
-
<sort_order>
|
115 |
<show_in_default>1</show_in_default>
|
116 |
<show_in_website>1</show_in_website>
|
117 |
<show_in_store>0</show_in_store>
|
|
|
118 |
</paypage_id>
|
119 |
<paypage_url translate="label">
|
120 |
<label>Paypage Merchant URL</label>
|
121 |
<frontend_type>text</frontend_type>
|
122 |
-
<sort_order>
|
123 |
<show_in_default>1</show_in_default>
|
124 |
<show_in_website>1</show_in_website>
|
125 |
<show_in_store>0</show_in_store>
|
|
|
126 |
</paypage_url>
|
127 |
<paypage_enable translate="label">
|
128 |
<label>Paypage Enabled</label>
|
129 |
<frontend_type>select</frontend_type>
|
130 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
131 |
-
<sort_order>
|
132 |
<show_in_default>1</show_in_default>
|
133 |
<show_in_website>1</show_in_website>
|
134 |
<show_in_store>0</show_in_store>
|
135 |
</paypage_enable>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
</fields>
|
137 |
</CreditCard>
|
138 |
</groups>
|
139 |
</payment>
|
140 |
</sections>
|
141 |
-
</config>
|
111 |
<paypage_id translate="label">
|
112 |
<label>Paypage Id</label>
|
113 |
<frontend_type>text</frontend_type>
|
114 |
+
<sort_order>101</sort_order>
|
115 |
<show_in_default>1</show_in_default>
|
116 |
<show_in_website>1</show_in_website>
|
117 |
<show_in_store>0</show_in_store>
|
118 |
+
<depends><paypage_enable>1</paypage_enable></depends>
|
119 |
</paypage_id>
|
120 |
<paypage_url translate="label">
|
121 |
<label>Paypage Merchant URL</label>
|
122 |
<frontend_type>text</frontend_type>
|
123 |
+
<sort_order>101</sort_order>
|
124 |
<show_in_default>1</show_in_default>
|
125 |
<show_in_website>1</show_in_website>
|
126 |
<show_in_store>0</show_in_store>
|
127 |
+
<depends><paypage_enable>1</paypage_enable></depends>
|
128 |
</paypage_url>
|
129 |
<paypage_enable translate="label">
|
130 |
<label>Paypage Enabled</label>
|
131 |
<frontend_type>select</frontend_type>
|
132 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
133 |
+
<sort_order>100</sort_order>
|
134 |
<show_in_default>1</show_in_default>
|
135 |
<show_in_website>1</show_in_website>
|
136 |
<show_in_store>0</show_in_store>
|
137 |
</paypage_enable>
|
138 |
+
<vault_enable translate="label">
|
139 |
+
<label>Vault Enabled</label>
|
140 |
+
<frontend_type>select</frontend_type>
|
141 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
142 |
+
<sort_order>110</sort_order>
|
143 |
+
<show_in_default>1</show_in_default>
|
144 |
+
<show_in_website>1</show_in_website>
|
145 |
+
<show_in_store>0</show_in_store>
|
146 |
+
</vault_enable>
|
147 |
</fields>
|
148 |
</CreditCard>
|
149 |
</groups>
|
150 |
</payment>
|
151 |
</sections>
|
152 |
+
</config>
|
app/code/local/Litle/LEcheck/Block/Form/LEcheck.php
CHANGED
@@ -4,7 +4,7 @@ class Litle_LEcheck_Block_Form_LEcheck extends Mage_Payment_Block_Form
|
|
4 |
protected function _construct()
|
5 |
{
|
6 |
parent::_construct();
|
7 |
-
$this->setTemplate('
|
8 |
}
|
9 |
|
10 |
public function getAccountAvailableTypes()
|
@@ -23,4 +23,4 @@ class Litle_LEcheck_Block_Form_LEcheck extends Mage_Payment_Block_Form
|
|
23 |
}
|
24 |
return $types;
|
25 |
}
|
26 |
-
}
|
4 |
protected function _construct()
|
5 |
{
|
6 |
parent::_construct();
|
7 |
+
$this->setTemplate('litle/form/litleecheck.phtml');
|
8 |
}
|
9 |
|
10 |
public function getAccountAvailableTypes()
|
23 |
}
|
24 |
return $types;
|
25 |
}
|
26 |
+
}
|
app/code/local/Litle/LEcheck/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Litle_LEcheck>
|
5 |
-
<version>8.13.
|
6 |
</Litle_LEcheck>
|
7 |
</modules>
|
8 |
<global>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Litle_LEcheck>
|
5 |
+
<version>8.13.3</version>
|
6 |
</Litle_LEcheck>
|
7 |
</modules>
|
8 |
<global>
|
app/code/local/Litle/LitleSDK/Obj2xml.php
CHANGED
@@ -62,14 +62,14 @@ class Obj2xml {
|
|
62 |
{
|
63 |
if ($value === "REQUIRED"){
|
64 |
throw new InvalidArgumentException("Missing Required Field: /$key/");
|
65 |
-
}elseif (substr($key,0
|
66 |
$temp_node = $transacType->addChild('lineItemData');
|
67 |
Obj2xml::iterateChildren($value,$temp_node);
|
68 |
}elseif (substr($key,0,-1) == 'detailTax'){
|
69 |
$temp_node = $transacType->addChild('detailTax');
|
70 |
Obj2xml::iterateChildren($value,$temp_node);
|
71 |
}elseif (((is_string($value)) || is_numeric($value))) {
|
72 |
-
$transacType->addChild($key,$value);
|
73 |
}elseif(is_array($value))
|
74 |
{
|
75 |
$node = $transacType->addChild($key);
|
62 |
{
|
63 |
if ($value === "REQUIRED"){
|
64 |
throw new InvalidArgumentException("Missing Required Field: /$key/");
|
65 |
+
}elseif (substr($key, 0, 12) === 'lineItemData'){
|
66 |
$temp_node = $transacType->addChild('lineItemData');
|
67 |
Obj2xml::iterateChildren($value,$temp_node);
|
68 |
}elseif (substr($key,0,-1) == 'detailTax'){
|
69 |
$temp_node = $transacType->addChild('detailTax');
|
70 |
Obj2xml::iterateChildren($value,$temp_node);
|
71 |
}elseif (((is_string($value)) || is_numeric($value))) {
|
72 |
+
$transacType->addChild($key,str_replace('&','&',$value));
|
73 |
}elseif(is_array($value))
|
74 |
{
|
75 |
$node = $transacType->addChild($key);
|
app/code/local/Litle/Palorus/Block/Adminhtml/Customer/Edit/Tab/Vault.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Litle Vault Info block
|
5 |
+
*
|
6 |
+
* @author jholden
|
7 |
+
*/
|
8 |
+
class Litle_Palorus_Block_Adminhtml_Customer_Edit_Tab_Vault
|
9 |
+
extends Mage_Adminhtml_Block_Template
|
10 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
11 |
+
{
|
12 |
+
|
13 |
+
protected function _construct()
|
14 |
+
{
|
15 |
+
parent::_construct();
|
16 |
+
$this->setTemplate('litle/customer/tab/vault.phtml');
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Returns the registry customer.
|
21 |
+
*
|
22 |
+
* @return Mage_Customer_Model_Customer
|
23 |
+
*/
|
24 |
+
public function getCustomer()
|
25 |
+
{
|
26 |
+
return Mage::registry('current_customer');
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Returns a collection of vaulted cards for the registry customer.
|
31 |
+
*
|
32 |
+
* @return Litle_Palorus_Model_Mysql4_Vault_Collection
|
33 |
+
*/
|
34 |
+
public function getStoredCards()
|
35 |
+
{
|
36 |
+
return Mage::getModel('palorus/vault')->getCollection()->addCustomerFilter($this->getCustomer());
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* URL to delete a stored card.
|
41 |
+
*
|
42 |
+
* @param Litle_Palorus_Model_Vault $card
|
43 |
+
* @return string
|
44 |
+
*/
|
45 |
+
public function getCardDeleteUrl(Litle_Palorus_Model_Vault $card)
|
46 |
+
{
|
47 |
+
$params = array(
|
48 |
+
'customer_id' => $this->getCustomer()->getId(),
|
49 |
+
'vault_id' => $card->getId()
|
50 |
+
);
|
51 |
+
return $this->getUrl('palorus/adminhtml_vault/deleteCard', $params);
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Retrieve the label used for the tab relating to this block
|
56 |
+
*
|
57 |
+
* @return string
|
58 |
+
*/
|
59 |
+
public function getTabLabel()
|
60 |
+
{
|
61 |
+
return $this->__('Litle Stored Cards');
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Retrieve the title used by this tab
|
66 |
+
*
|
67 |
+
* @return string
|
68 |
+
*/
|
69 |
+
public function getTabTitle()
|
70 |
+
{
|
71 |
+
return $this->__('Click here to view stored cards for this customer');
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Determines whether to display the tab
|
76 |
+
* Add logic here to decide whether you want the tab to display
|
77 |
+
*
|
78 |
+
* @return bool
|
79 |
+
*/
|
80 |
+
public function canShowTab()
|
81 |
+
{
|
82 |
+
return true;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Stops the tab being hidden
|
87 |
+
*
|
88 |
+
* @return bool
|
89 |
+
*/
|
90 |
+
public function isHidden()
|
91 |
+
{
|
92 |
+
return false;
|
93 |
+
}
|
94 |
+
}
|
app/code/local/Litle/Palorus/Block/Vault.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Stored card rendering block
|
4 |
+
*/
|
5 |
+
class Litle_Palorus_Block_Vault extends Mage_Core_Block_Abstract
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @var array
|
9 |
+
*/
|
10 |
+
protected $_params = array();
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Renders the block.
|
14 |
+
*
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
protected function _toHtml ()
|
18 |
+
{
|
19 |
+
if ($this->getPaymentProfile() && $this->getType()) {
|
20 |
+
switch ($this->getType()) {
|
21 |
+
case 'oneline':
|
22 |
+
return $this->_getOneline();
|
23 |
+
case 'json':
|
24 |
+
return $this->_getJson();
|
25 |
+
case 'html':
|
26 |
+
return $this->_getHtml();
|
27 |
+
}
|
28 |
+
}
|
29 |
+
return '';
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Sets rendering params.
|
34 |
+
*
|
35 |
+
* Supported params:
|
36 |
+
* show_exp_date
|
37 |
+
* container_tag
|
38 |
+
*
|
39 |
+
* @param array $params
|
40 |
+
* @return Litle_Palorus_Block_Vault
|
41 |
+
*/
|
42 |
+
public function setParams (array $params)
|
43 |
+
{
|
44 |
+
$this->_params = $params;
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Param getter.
|
50 |
+
*
|
51 |
+
* @param string $param
|
52 |
+
* @return mixed
|
53 |
+
*/
|
54 |
+
public function getParam ($param)
|
55 |
+
{
|
56 |
+
return isset($this->_params[$param]) ? $this->_params[$param] : false;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @return string
|
61 |
+
*/
|
62 |
+
protected function _getOneline ()
|
63 |
+
{
|
64 |
+
$profile = $this->getPaymentProfile();
|
65 |
+
$str = Mage::helper('palorus')->__(
|
66 |
+
'Card Type: %s, xxxx-%s, Exp: %s/%s',
|
67 |
+
$profile->getType(),
|
68 |
+
$profile->getLast4(),
|
69 |
+
$profile->getExpirationMonth(),
|
70 |
+
$profile->getExpirationYear()
|
71 |
+
);
|
72 |
+
return $str;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @return string
|
77 |
+
*/
|
78 |
+
protected function _getJson ()
|
79 |
+
{
|
80 |
+
$profile = $this->getPaymentProfile();
|
81 |
+
return Mage::helper('core')->jsonEncode($profile->getData());
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @return string
|
86 |
+
*/
|
87 |
+
protected function _getHtml ()
|
88 |
+
{
|
89 |
+
$profile = $this->getPaymentProfile();
|
90 |
+
$tag = $this->getParam('container_tag') ? $this->getParam('container_tag') : 'address';
|
91 |
+
|
92 |
+
$str = '<' . $tag . '>';
|
93 |
+
if ($profile->getCardType()) {
|
94 |
+
$str .= Mage::helper('palorus')->__('Card Type: %s<br />', $profile->getType());
|
95 |
+
}
|
96 |
+
$str .= Mage::helper('palorus')->__('Card Number: XXXX-%s<br />', $profile->getLast4());
|
97 |
+
|
98 |
+
if ($this->getParam('show_exp_date')) {
|
99 |
+
$str .= Mage::helper('palorus')->__('Expiration: %s/%s<br />', $profile->getExpirationMonth(), $profile->getExpirationYear());
|
100 |
+
}
|
101 |
+
$str = $str . '</' . $tag . '>';
|
102 |
+
|
103 |
+
return $str;
|
104 |
+
}
|
105 |
+
}
|
app/code/local/Litle/Palorus/Block/Vault/List.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Litle_Palorus_Block_Vault_List extends Mage_Core_Block_Template
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Retrieve customer model
|
8 |
+
*
|
9 |
+
* @return Mage_Customer_Model_Customer
|
10 |
+
*/
|
11 |
+
public function getCustomer()
|
12 |
+
{
|
13 |
+
return Mage::getSingleton('customer/session')->getCustomer();
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Returns an array of stored cards.
|
18 |
+
*
|
19 |
+
* @return array
|
20 |
+
*/
|
21 |
+
public function getStoredCards()
|
22 |
+
{
|
23 |
+
if (!$this->hasData('stored_cards')) {
|
24 |
+
$cards = Mage::getModel('palorus/vault')->visibleStoredCards($this->getCustomer()
|
25 |
+
->getId());
|
26 |
+
|
27 |
+
$this->setStoredCards($cards);
|
28 |
+
}
|
29 |
+
return $this->getData('stored_cards');
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
*
|
34 |
+
* @return string
|
35 |
+
*/
|
36 |
+
public function getDeleteUrl()
|
37 |
+
{
|
38 |
+
return $this->getUrl('*/*/delete');
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
*
|
43 |
+
* @todo New card url
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
// public function getAddUrl()
|
47 |
+
// {
|
48 |
+
// return $this->getUrl('*/*/new');
|
49 |
+
// }
|
50 |
+
|
51 |
+
/**
|
52 |
+
*
|
53 |
+
* @todo Edit card url
|
54 |
+
* @param OnePica_AuthnetCim_Model_PaymentProfile $profile
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
// public function getEditUrl(OnePica_AuthnetCim_Model_PaymentProfile
|
58 |
+
// $profile)
|
59 |
+
// {
|
60 |
+
// return $this->getUrl('*/*/edit', array(
|
61 |
+
// 'profile_id' => $profile->getId()
|
62 |
+
// ));
|
63 |
+
// }
|
64 |
+
}
|
app/code/local/Litle/Palorus/Helper/Data.php
CHANGED
@@ -1,128 +1,210 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|