Version Notes
Initial stable release
Download this release
Release Info
Developer | Brian McGowan |
Extension | Cardpay_HighRisk |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Cardpay/HighRisk/Block/Creditcard.php +236 -0
- app/code/community/Cardpay/HighRisk/Block/Form.php +53 -0
- app/code/community/Cardpay/HighRisk/Block/Info.php +98 -0
- app/code/community/Cardpay/HighRisk/Helper/Data.php +106 -0
- app/code/community/Cardpay/HighRisk/Model/Creditcard.php +148 -0
- app/code/community/Cardpay/HighRisk/Model/PaymentMethod.php +473 -0
- app/code/community/Cardpay/HighRisk/Model/Resource/Creditcard.php +36 -0
- app/code/community/Cardpay/HighRisk/Model/Resource/Creditcard/Collection.php +36 -0
- app/code/community/Cardpay/HighRisk/Model/Source/Cctype.php +37 -0
- app/code/community/Cardpay/HighRisk/Model/Source/PaymentAction.php +46 -0
- app/code/community/Cardpay/HighRisk/controllers/CreditcardController.php +245 -0
- app/code/community/Cardpay/HighRisk/etc/config.xml +114 -0
- app/code/community/Cardpay/HighRisk/etc/system.xml +161 -0
- app/code/community/Cardpay/HighRisk/sql/highrisk_setup/install-1.0.0.php +64 -0
- app/design/adminhtml/default/default/template/highrisk/form.phtml +143 -0
- app/design/frontend/base/default/layout/highrisk.xml +56 -0
- app/design/frontend/base/default/template/highrisk/creditcard/delete.phtml +61 -0
- app/design/frontend/base/default/template/highrisk/creditcard/edit.phtml +134 -0
- app/design/frontend/base/default/template/highrisk/creditcard/index.phtml +64 -0
- app/design/frontend/base/default/template/highrisk/form.phtml +167 -0
- app/etc/modules/Cardpay_HighRisk.xml +12 -0
- app/locale/en_US/Cardpay_HighRisk.csv +1 -0
- package.xml +18 -0
app/code/community/Cardpay/HighRisk/Block/Creditcard.php
ADDED
@@ -0,0 +1,236 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Cardpay Solutions HighRisk credit card block.
|
21 |
+
*
|
22 |
+
* @category Cardpay
|
23 |
+
* @package Cardpay_HighRisk
|
24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaymerchant.com>
|
25 |
+
*/
|
26 |
+
class Cardpay_HighRisk_Block_Creditcard extends Mage_Core_Block_Template
|
27 |
+
{
|
28 |
+
const TYPE_EDIT = 'edit';
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Returns credit card
|
32 |
+
*
|
33 |
+
* @return Cardpay_HighRisk_Model_Creditcard credit card object
|
34 |
+
*/
|
35 |
+
public function creditCard()
|
36 |
+
{
|
37 |
+
$id = Mage::app()->getRequest()->getParam('id');
|
38 |
+
$card = Mage::getModel('highrisk/creditcard')->load($id);
|
39 |
+
return $card;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* If existing card being edited
|
44 |
+
*
|
45 |
+
* @return bool if existing card edit
|
46 |
+
*/
|
47 |
+
public function isEditMode()
|
48 |
+
{
|
49 |
+
if ($this->getType() == self::TYPE_EDIT) {
|
50 |
+
return true;
|
51 |
+
}
|
52 |
+
return false;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Returns url for add
|
57 |
+
*
|
58 |
+
* @return string add url
|
59 |
+
*/
|
60 |
+
public function getAddUrl()
|
61 |
+
{
|
62 |
+
return $this->getUrl('customer/creditcard/new');
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Returns url for edit
|
67 |
+
*
|
68 |
+
* @param int $id id of credit card
|
69 |
+
*
|
70 |
+
* @return string edit url
|
71 |
+
*/
|
72 |
+
public function getEditUrl($id)
|
73 |
+
{
|
74 |
+
return $this->getUrl('customer/creditcard/edit', array('id' => $id));
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Returns url for delete
|
79 |
+
*
|
80 |
+
* @param int $id id of credit card
|
81 |
+
*
|
82 |
+
* @return string delete url
|
83 |
+
*/
|
84 |
+
public function getDeleteUrl($id)
|
85 |
+
{
|
86 |
+
return $this->getUrl('customer/creditcard/delete', array('id' => $id));
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Returns url for delete confirm
|
91 |
+
*
|
92 |
+
* @param int $id id of credit card
|
93 |
+
*
|
94 |
+
* @return string delete confirm url
|
95 |
+
*/
|
96 |
+
public function getDeleteConfirmUrl($id)
|
97 |
+
{
|
98 |
+
return $this->getUrl('customer/creditcard/deleteconfirm', array('id' => $id));
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Returns url for new or edit form action
|
103 |
+
*
|
104 |
+
* @return string form action url
|
105 |
+
*/
|
106 |
+
public function getFormAction()
|
107 |
+
{
|
108 |
+
if ($this->getType() == self::TYPE_EDIT) {
|
109 |
+
$url = $this->getUrl(
|
110 |
+
'customer/creditcard/update',
|
111 |
+
array('id' => Mage::app()->getRequest()->getParam('id'))
|
112 |
+
);
|
113 |
+
} else {
|
114 |
+
$url = $this->getUrl('customer/creditcard/save');
|
115 |
+
}
|
116 |
+
return $url;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Returns page title
|
121 |
+
*
|
122 |
+
* @return string page title
|
123 |
+
*/
|
124 |
+
public function getTitle()
|
125 |
+
{
|
126 |
+
$title = '';
|
127 |
+
if ($this->getType() == self::TYPE_EDIT) {
|
128 |
+
$title = 'Edit Credit Card';
|
129 |
+
} else {
|
130 |
+
$title = 'Add Credit Card';
|
131 |
+
}
|
132 |
+
return $this->__($title);
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Returns url for back
|
137 |
+
*
|
138 |
+
* @return string back url
|
139 |
+
*/
|
140 |
+
public function getBackUrl()
|
141 |
+
{
|
142 |
+
return $this->getUrl('customer/creditcard/index');
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Returns credit card expire months
|
147 |
+
*
|
148 |
+
* @return array expiration months
|
149 |
+
*/
|
150 |
+
public function getCcMonths()
|
151 |
+
{
|
152 |
+
$months = $this->getData('cc_months');
|
153 |
+
if (is_null($months)) {
|
154 |
+
$months[0] = $this->__('Month');
|
155 |
+
$months = array_merge($months, Mage::getSingleton('payment/config')->getMonths());
|
156 |
+
$this->setData('cc_months', $months);
|
157 |
+
}
|
158 |
+
return $months;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Returns credit card expire years
|
163 |
+
*
|
164 |
+
* @return array expiration years
|
165 |
+
*/
|
166 |
+
public function getCcYears()
|
167 |
+
{
|
168 |
+
$years = $this->getData('cc_years');
|
169 |
+
if (is_null($years)) {
|
170 |
+
$years = Mage::getSingleton('payment/config')->getYears();
|
171 |
+
$years = array(0=>$this->__('Year'))+$years;
|
172 |
+
$this->setData('cc_years', $years);
|
173 |
+
}
|
174 |
+
return $years;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Returns available credit card types
|
179 |
+
*
|
180 |
+
* @return array card types
|
181 |
+
*/
|
182 |
+
public function getCcAvailableTypes()
|
183 |
+
{
|
184 |
+
$types = Mage::getSingleton('payment/config')->getCcTypes();
|
185 |
+
if ($method = Mage::getModel('highrisk/paymentmethod')) {
|
186 |
+
$availableTypes = $method->getConfigData('cctypes');
|
187 |
+
if ($availableTypes) {
|
188 |
+
$availableTypes = explode(',', $availableTypes);
|
189 |
+
foreach ($types as $code=>$name) {
|
190 |
+
if (!in_array($code, $availableTypes)) {
|
191 |
+
unset($types[$code]);
|
192 |
+
}
|
193 |
+
}
|
194 |
+
}
|
195 |
+
}
|
196 |
+
return $types;
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* If make default should be shown
|
201 |
+
*
|
202 |
+
* @return bool if can make default
|
203 |
+
*/
|
204 |
+
public function canShowMakeDefault()
|
205 |
+
{
|
206 |
+
$model = Mage::getModel('highrisk/creditcard');
|
207 |
+
$cardCount = count($model->currentCustomerCards());
|
208 |
+
|
209 |
+
if ($this->getType() == self::TYPE_EDIT) {
|
210 |
+
$cardId = $this->getRequest()->getParam('id');
|
211 |
+
$card = $model->load($cardId);
|
212 |
+
if ($card->getIsDefault()) {
|
213 |
+
return false;
|
214 |
+
} else {
|
215 |
+
return true;
|
216 |
+
}
|
217 |
+
} else {
|
218 |
+
if ($cardCount > 0) {
|
219 |
+
return true;
|
220 |
+
} else {
|
221 |
+
return false;
|
222 |
+
}
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* If cc cid should be shown
|
228 |
+
*
|
229 |
+
* @return bool if cid
|
230 |
+
*/
|
231 |
+
public function hasVerification()
|
232 |
+
{
|
233 |
+
$method = Mage::getModel('highrisk/paymentmethod');
|
234 |
+
return $method->getConfigData('useccv');
|
235 |
+
}
|
236 |
+
}
|
app/code/community/Cardpay/HighRisk/Block/Form.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Cardpay Solutions HighRisk form block.
|
21 |
+
*
|
22 |
+
* @category Cardpay
|
23 |
+
* @package Cardpay_HighRisk
|
24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaymerchant.com>
|
25 |
+
*/
|
26 |
+
class Cardpay_HighRisk_Block_Form extends Mage_Payment_Block_Form_Cc
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Internal constructor. Set template.
|
30 |
+
*/
|
31 |
+
protected function _construct()
|
32 |
+
{
|
33 |
+
parent::_construct();
|
34 |
+
$this->setTemplate('highrisk/form.phtml');
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* If credit card can be saved
|
39 |
+
*
|
40 |
+
* @return bool if can save
|
41 |
+
*/
|
42 |
+
public function canSaveCard()
|
43 |
+
{
|
44 |
+
$methodRegister = Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER;
|
45 |
+
if (Mage::getModel('highrisk/paymentmethod')->getConfigData('use_vault')
|
46 |
+
&& (Mage::getSingleton('customer/session')->isLoggedIn()
|
47 |
+
|| Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == $methodRegister)
|
48 |
+
) {
|
49 |
+
return true;
|
50 |
+
}
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Cardpay/HighRisk/Block/Info.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php.
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* First Data HighRisk info block.
|
21 |
+
*
|
22 |
+
* @category Cardpay
|
23 |
+
* @package Cardpay_HighRisk
|
24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaymerchant.com>
|
25 |
+
*/
|
26 |
+
class Cardpay_HighRisk_Block_Info extends Mage_Payment_Block_Info
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Return credit card type
|
30 |
+
*
|
31 |
+
* @return string card type name
|
32 |
+
*/
|
33 |
+
public function getCcTypeName()
|
34 |
+
{
|
35 |
+
$types = Mage::getSingleton('payment/config')->getCcTypes();
|
36 |
+
$ccType = $this->getInfo()->getCcType();
|
37 |
+
if (isset($types[$ccType])) {
|
38 |
+
return $types[$ccType];
|
39 |
+
}
|
40 |
+
return (empty($ccType)) ? Mage::helper('highrisk')->__('Stored Card') : $ccType;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* If has expiration date
|
45 |
+
*
|
46 |
+
* @return bool if has expiration date
|
47 |
+
*/
|
48 |
+
public function hasCcExpDate()
|
49 |
+
{
|
50 |
+
return (int)$this->getInfo()->getCcExpMonth() || (int)$this->getInfo()->getCcExpYear();
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Return credit card expiration
|
55 |
+
*
|
56 |
+
* @return string formatted expiration date
|
57 |
+
*/
|
58 |
+
public function getCcExpDate()
|
59 |
+
{
|
60 |
+
$month = $this->getInfo()->getCcExpMonth();
|
61 |
+
$year = $this->getInfo()->getCcExpYear();
|
62 |
+
return sprintf('%s/%s', sprintf('%02d', $month), $year);
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Prepare information specific to current payment method
|
67 |
+
*
|
68 |
+
* @param null | array $transport
|
69 |
+
*
|
70 |
+
* @return Varien_Object specific information
|
71 |
+
*/
|
72 |
+
protected function _prepareSpecificInformation($transport = null)
|
73 |
+
{
|
74 |
+
if (null !== $this->_paymentSpecificInformation) {
|
75 |
+
return $this->_paymentSpecificInformation;
|
76 |
+
}
|
77 |
+
$transport = parent::_prepareSpecificInformation($transport);
|
78 |
+
$data = array();
|
79 |
+
if ($ccType = $this->getCcTypeName()) {
|
80 |
+
$data[Mage::helper('highrisk')->__('Credit Card Type')] = $ccType;
|
81 |
+
}
|
82 |
+
if ($ccLast = $this->getInfo()->getCcLast4()) {
|
83 |
+
$data[Mage::helper('highrisk')->__('Credit Card Number')] = sprintf('xxxx-%s', $ccLast);
|
84 |
+
}
|
85 |
+
if ($this->hasCcExpDate()) {
|
86 |
+
$data[Mage::helper('highrisk')->__('Expiration Date')] = $this->getCcExpDate();
|
87 |
+
}
|
88 |
+
if (Mage::app()->getStore()->isAdmin()) {
|
89 |
+
if ($this->getInfo()->getCcAvsStatus()) {
|
90 |
+
$data[Mage::helper('highrisk')->__('AVS Response')] = $this->getInfo()->getCcAvsStatus();
|
91 |
+
}
|
92 |
+
if ($this->getInfo()->getCcCidStatus()) {
|
93 |
+
$data[Mage::helper('highrisk')->__('CVV2 Response')] = $this->getInfo()->getCcCidStatus();
|
94 |
+
}
|
95 |
+
}
|
96 |
+
return $transport->setData(array_merge($data, $transport->getData()));
|
97 |
+
}
|
98 |
+
}
|
app/code/community/Cardpay/HighRisk/Helper/Data.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Cardpay Solutions HighRisk data helper.
|
21 |
+
*
|
22 |
+
* @category Cardpay
|
23 |
+
* @package Cardpay_HighRisk
|
24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaymerchant.com>
|
25 |
+
*/
|
26 |
+
class Cardpay_HighRisk_Helper_Data extends Mage_Core_Helper_Abstract
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Returns credit card name
|
30 |
+
*
|
31 |
+
* @param $code credit card type code
|
32 |
+
*
|
33 |
+
* @return string card type name
|
34 |
+
*/
|
35 |
+
public function getCcTypeName($code)
|
36 |
+
{
|
37 |
+
$ccTypes = array(
|
38 |
+
'VI' => 'Visa',
|
39 |
+
'MC' => 'MasterCard',
|
40 |
+
'AE' => 'American Express',
|
41 |
+
'DI' => 'Discover',
|
42 |
+
'JCB' => 'JCB'
|
43 |
+
);
|
44 |
+
return $ccTypes[$code];
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Returns avs response description
|
49 |
+
*
|
50 |
+
* @param $code avs response code
|
51 |
+
*
|
52 |
+
* @return string avs message
|
53 |
+
*/
|
54 |
+
public function getAvsResponse($code)
|
55 |
+
{
|
56 |
+
$avsResponses = array(
|
57 |
+
'X' => 'Exact match, 9-character numeric ZIP',
|
58 |
+
'Y' => 'Exact match, 5-character numeric ZIP',
|
59 |
+
'D' => 'Exact match, 5-character numeric ZIP',
|
60 |
+
'M' => 'Exact match, 5-character numeric ZIP',
|
61 |
+
'A' => 'Address match only',
|
62 |
+
'B' => 'Address match only',
|
63 |
+
'W' => '9-character numeric ZIP match only',
|
64 |
+
'Z' => '5-character ZIP match only',
|
65 |
+
'P' => '5-character ZIP match only',
|
66 |
+
'L' => '5-character ZIP match only',
|
67 |
+
'N' => 'No address or ZIP match only',
|
68 |
+
'C' => 'No address or ZIP match only',
|
69 |
+
'U' => 'Address unavailable',
|
70 |
+
'G' => 'Non-U.S. issuer does not participate',
|
71 |
+
'I' => 'Non-U.S. issuer does not participate',
|
72 |
+
'R' => 'Issuer system unavailable',
|
73 |
+
'E' => 'Not a mail/phone order',
|
74 |
+
'S' => 'Service not supported',
|
75 |
+
'O' => 'AVS not available'
|
76 |
+
);
|
77 |
+
if (array_key_exists($code, $avsResponses)) {
|
78 |
+
return $avsResponses[$code];
|
79 |
+
} else {
|
80 |
+
return '';
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Returns cvv response description
|
86 |
+
*
|
87 |
+
* @param $code cvv response code
|
88 |
+
*
|
89 |
+
* @return string cvv message
|
90 |
+
*/
|
91 |
+
public function getCvvResponse($code)
|
92 |
+
{
|
93 |
+
$cvvResponses = array(
|
94 |
+
'M' => 'CVV2/CVC2 match',
|
95 |
+
'N' => 'CVV2/CVC2 no match',
|
96 |
+
'P' => 'Not processed',
|
97 |
+
'S' => 'Merchant has indicated that CVV2/CVC2 is not present on card',
|
98 |
+
'U' => 'Issuer is not certified and/or has not provided Visa encryption keys'
|
99 |
+
);
|
100 |
+
if (array_key_exists($code, $cvvResponses)) {
|
101 |
+
return $cvvResponses[$code];
|
102 |
+
} else {
|
103 |
+
return '';
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
app/code/community/Cardpay/HighRisk/Model/Creditcard.php
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Cardpay Solutions HighRisk credit card model.
|
21 |
+
*
|
22 |
+
* @category Cardpay
|
23 |
+
* @package Cardpay_HighRisk
|
24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaymerchant.com>
|
25 |
+
*/
|
26 |
+
class Cardpay_HighRisk_Model_Creditcard extends Mage_Core_Model_Abstract
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Internal constructor.
|
30 |
+
*/
|
31 |
+
public function _construct()
|
32 |
+
{
|
33 |
+
parent::_construct();
|
34 |
+
$this->_init('highrisk/creditcard');
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Returns current customer credit cards
|
39 |
+
*
|
40 |
+
* @return array customer cards
|
41 |
+
*/
|
42 |
+
public function currentCustomerCards()
|
43 |
+
{
|
44 |
+
if ($this->useVault() && Mage::getSingleton('customer/session')->isLoggedIn()) {
|
45 |
+
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
|
46 |
+
$cards = $this->getCollection()->addFieldToFilter('customer_id', $customerId);
|
47 |
+
return $cards;
|
48 |
+
}
|
49 |
+
return array();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Returns current customer credit cards
|
54 |
+
*
|
55 |
+
* @return array customer cards
|
56 |
+
*/
|
57 |
+
public function adminCustomerCards()
|
58 |
+
{
|
59 |
+
if ($this->useVault()) {
|
60 |
+
$customerId = Mage::getSingleton('adminhtml/session_quote')->getCustomerId();
|
61 |
+
$cards = $this->getCollection()->addFieldToFilter('customer_id', $customerId);
|
62 |
+
return $cards;
|
63 |
+
}
|
64 |
+
return array();
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* If can use vault
|
69 |
+
*
|
70 |
+
* @return bool if can use vault
|
71 |
+
*/
|
72 |
+
public function useVault()
|
73 |
+
{
|
74 |
+
$highrisk = Mage::getModel('highrisk/paymentmethod');
|
75 |
+
return $highrisk->getConfigData('use_vault');
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Returns credit card type name
|
80 |
+
*
|
81 |
+
* @return string card type name
|
82 |
+
*/
|
83 |
+
public function getCardTypeName()
|
84 |
+
{
|
85 |
+
$highrisk = Mage::getModel('highrisk/paymentmethod');
|
86 |
+
return Mage::helper('highrisk')->getCcTypeName($this->getCcType());
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Returns masked credit card number
|
91 |
+
*
|
92 |
+
* @return string masked card number
|
93 |
+
*/
|
94 |
+
public function getMaskedCardNum()
|
95 |
+
{
|
96 |
+
return '************' . $this->getCcLast4();
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Returns cardholder name
|
101 |
+
*
|
102 |
+
* @return string cardholder name
|
103 |
+
*/
|
104 |
+
public function getCardholderName()
|
105 |
+
{
|
106 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
107 |
+
$cardholderName = $customer->getName();
|
108 |
+
return $cardholderName;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Returns cardholder first name
|
113 |
+
*
|
114 |
+
* @return string cardholder first name
|
115 |
+
*/
|
116 |
+
public function getCardholderFirstname()
|
117 |
+
{
|
118 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
119 |
+
$firstName = $customer->getFirstname();
|
120 |
+
return $firstName;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Returns cardholder last name
|
125 |
+
*
|
126 |
+
* @return string cardholder last name
|
127 |
+
*/
|
128 |
+
public function getCardholderLastname()
|
129 |
+
{
|
130 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
131 |
+
$lastName = $customer->getLastname();
|
132 |
+
return $lastName;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Clears the current defualt credit card
|
137 |
+
*/
|
138 |
+
public function clearDefault()
|
139 |
+
{
|
140 |
+
$cards = $this->currentCustomerCards();
|
141 |
+
foreach ($cards as $card) {
|
142 |
+
if ($card->getIsDefault()) {
|
143 |
+
$card->setIsDefault('0');
|
144 |
+
$card->save();
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
}
|
app/code/community/Cardpay/HighRisk/Model/PaymentMethod.php
ADDED
@@ -0,0 +1,473 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Cardpay Solutions HighRisk payment method model.
|
21 |
+
*
|
22 |
+
* @category Cardpay
|
23 |
+
* @package Cardpay_HighRisk
|
24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaymerchant.com>
|
25 |
+
*/
|
26 |
+
class Cardpay_HighRisk_Model_PaymentMethod extends Mage_Payment_Model_Method_Cc
|
27 |
+
{
|
28 |
+
protected $_code = 'highrisk';
|
29 |
+
protected $_isGateway = true;
|
30 |
+
protected $_canAuthorize = true;
|
31 |
+
protected $_canCapture = true;
|
32 |
+
protected $_canCapturePartial = true;
|
33 |
+
protected $_canRefund = true;
|
34 |
+
protected $_canVoid = true;
|
35 |
+
protected $_canUseInternal = true;
|
36 |
+
protected $_canUseCheckout = true;
|
37 |
+
protected $_canUseForMultishipping = true;
|
38 |
+
protected $_canSaveCc = false;
|
39 |
+
protected $_canRefundInvoicePartial = true;
|
40 |
+
|
41 |
+
protected $_formBlockType = 'highrisk/form';
|
42 |
+
protected $_infoBlockType = 'highrisk/info';
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Validate data
|
46 |
+
*
|
47 |
+
* @return bool true
|
48 |
+
*/
|
49 |
+
public function validate()
|
50 |
+
{
|
51 |
+
return true;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Authorizes specified amount
|
56 |
+
*
|
57 |
+
* @param Varien_Object $payment payment object
|
58 |
+
* @param decimal $amount amount in decimals
|
59 |
+
*
|
60 |
+
* @return Cardpay_HighRisk_Model_PaymentMethod payment method object
|
61 |
+
*/
|
62 |
+
public function authorize(Varien_Object $payment, $amount)
|
63 |
+
{
|
64 |
+
$post = Mage::app()->getRequest()->getPost();
|
65 |
+
$payload = $this->getPayload($payment, $amount, "auth");
|
66 |
+
$response = $this->postTransaction($payload);
|
67 |
+
if ($response['response'] == 1) {
|
68 |
+
$payment->setTransactionId($response['transactionid'])
|
69 |
+
->setCcApproval($response['authcode'])
|
70 |
+
->setCcTransId($response['transactionid'])
|
71 |
+
->setIsTransactionClosed(0)
|
72 |
+
->setParentTransactionId(null)
|
73 |
+
->setCcAvsStatus(Mage::helper('highrisk')->getAvsResponse($response['avsresponse']))
|
74 |
+
->setCcCidStatus(Mage::helper('highrisk')->getCvvResponse($response['cvvresponse']));
|
75 |
+
if (isset($post['payment']['save_card'])) {
|
76 |
+
$this->saveCard($payment, $response['customer_vault_id']);
|
77 |
+
}
|
78 |
+
return $this;
|
79 |
+
} else {
|
80 |
+
Mage::throwException('Transaction Failed: ' . $response['responsetext']);
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Captures specified amount
|
86 |
+
*
|
87 |
+
* @param Varien_Object $payment payment object
|
88 |
+
* @param decimal $amount amount in decimals
|
89 |
+
*
|
90 |
+
* @return Cardpay_HighRisk_Model_PaymentMethod payment method object
|
91 |
+
*/
|
92 |
+
public function capture(Varien_Object $payment, $amount)
|
93 |
+
{
|
94 |
+
if ($payment->getParentTransactionId()) {
|
95 |
+
$payload = $this->getPayload($payment, $amount, "capture");
|
96 |
+
$response = $this->postTransaction($payload);
|
97 |
+
if ($response['response'] == 1) {
|
98 |
+
$payment->setTransactionId($response['transactionid'])
|
99 |
+
->setCcApproval($response['authcode'])
|
100 |
+
->setCcTransId($response['transactionid'])
|
101 |
+
->setIsTransactionClosed(1)
|
102 |
+
->setParentTransactionId($payment->getParentTransactionId());
|
103 |
+
return $this;
|
104 |
+
} else {
|
105 |
+
Mage::throwException('Capture Failed: ' . $response['responsetext']);
|
106 |
+
}
|
107 |
+
} else {
|
108 |
+
return $this->purchase($payment, $amount);
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Authoirzes and captures specified amount
|
114 |
+
*
|
115 |
+
* @param Varien_Object $payment payment object
|
116 |
+
* @param decimal $amount amount in decimals
|
117 |
+
*
|
118 |
+
* @return Cardpay_HighRisk_Model_PaymentMethod payment method object
|
119 |
+
*/
|
120 |
+
public function purchase(Varien_Object $payment, $amount)
|
121 |
+
{
|
122 |
+
$post = Mage::app()->getRequest()->getPost();
|
123 |
+
$payload = $this->getPayload($payment, $amount, "sale");
|
124 |
+
$response = $this->postTransaction($payload);
|
125 |
+
if ($response['response'] == 1) {
|
126 |
+
$payment->setTransactionId($response['transactionid'])
|
127 |
+
->setCcApproval($response['authcode'])
|
128 |
+
->setCcTransId($response['transactionid'])
|
129 |
+
->setIsTransactionClosed(1)
|
130 |
+
->setParentTransactionId(null)
|
131 |
+
->setCcAvsStatus(Mage::helper('highrisk')->getAvsResponse($response['avsresponse']))
|
132 |
+
->setCcCidStatus(Mage::helper('highrisk')->getCvvResponse($response['cvvresponse']));
|
133 |
+
if (isset($post['payment']['save_card'])) {
|
134 |
+
$this->saveCard($payment, $response['customer_vault_id']);
|
135 |
+
}
|
136 |
+
return $this;
|
137 |
+
} else {
|
138 |
+
Mage::throwException('Transaction Failed: ' . $response['responsetext']);
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Refunds specified amount
|
144 |
+
*
|
145 |
+
* @param Varien_Object $payment payment object
|
146 |
+
* @param decimal $amount amount in decimals
|
147 |
+
*
|
148 |
+
* @return Cardpay_HighRisk_Model_PaymentMethod payment method object
|
149 |
+
*/
|
150 |
+
public function refund(Varien_Object $payment, $amount)
|
151 |
+
{
|
152 |
+
if ($payment->getParentTransactionId()) {
|
153 |
+
$payload = $this->getPayload($payment, $amount, "refund");
|
154 |
+
$response = $this->postTransaction($payload);
|
155 |
+
if ($response['response'] == 1) {
|
156 |
+
$payment->setTransactionId($response['transactionid'])
|
157 |
+
->setCcApproval($response['authcode'])
|
158 |
+
->setCcTransId($response['transactionid'])
|
159 |
+
->setIsTransactionClosed(1)
|
160 |
+
->setParentTransactionId($payment->getParentTransactionId());
|
161 |
+
return $this;
|
162 |
+
} else {
|
163 |
+
Mage::throwException('Refund Failed: ' . $response['responsetext']);
|
164 |
+
}
|
165 |
+
} else {
|
166 |
+
Mage::throwException('Refund Failed: Invalid parent transaction ID.');
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Voides authorized transaction
|
172 |
+
*
|
173 |
+
* @param Varien_Object $payment payment object
|
174 |
+
*
|
175 |
+
* @return Cardpay_HighRisk_Model_PaymentMethod payment method object
|
176 |
+
*/
|
177 |
+
public function void(Varien_Object $payment)
|
178 |
+
{
|
179 |
+
if ($payment->getParentTransactionId()) {
|
180 |
+
$amount = $payment->getBaseAmountAuthorized();
|
181 |
+
$payload = $this->getPayload($payment, $amount, "void");
|
182 |
+
$response = $this->postTransaction($payload);
|
183 |
+
if ($response['response'] == 1) {
|
184 |
+
$payment->setTransactionId($response['transactionid'])
|
185 |
+
->setCcApproval($response['authcode'])
|
186 |
+
->setCcTransId($response['transactionid'])
|
187 |
+
->setIsTransactionClosed(1)
|
188 |
+
->setParentTransactionId($payment->getParentTransactionId());
|
189 |
+
return $this;
|
190 |
+
} else {
|
191 |
+
Mage::throwException('Void Failed: ' . $response['responsetext']);
|
192 |
+
}
|
193 |
+
} else {
|
194 |
+
Mage::throwException('Void Failed: Invalid parent transaction ID.');
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Voides transaction on cancel action
|
200 |
+
*
|
201 |
+
* @param Varien_Object $payment payment object
|
202 |
+
*
|
203 |
+
* @return Cardpay_HighRisk_Model_PaymentMethod payment method object
|
204 |
+
*/
|
205 |
+
public function cancel(Varien_Object $payment)
|
206 |
+
{
|
207 |
+
return $this->void($payment);
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Requests token for card
|
212 |
+
*
|
213 |
+
* @param Cardpay_HighRisk_Model_Creditcard $card credit card object
|
214 |
+
*
|
215 |
+
* @return string token value
|
216 |
+
*/
|
217 |
+
public function verify($card)
|
218 |
+
{
|
219 |
+
$payload = $this->getTokenPayload($card);
|
220 |
+
$response = $this->postTransaction($payload);
|
221 |
+
if ($response['response'] == 1) {
|
222 |
+
return $response['customer_vault_id'];
|
223 |
+
} else {
|
224 |
+
Mage::throwException('Card Declined: ' . $response['responsetext']);
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Saves card and transarmor token
|
230 |
+
*
|
231 |
+
* @param Varien_Object $payment payment object
|
232 |
+
* @param string $token token value
|
233 |
+
*
|
234 |
+
* @return Cardpay_HighRisk_Model_Creditcard credit card object
|
235 |
+
*/
|
236 |
+
public function saveCard(Varien_Object $payment, $token)
|
237 |
+
{
|
238 |
+
if ($token) {
|
239 |
+
$customerId = $payment->getOrder()->getCustomerId();
|
240 |
+
$card = Mage::getModel('highrisk/creditcard');
|
241 |
+
$card->setData('customer_id', $customerId);
|
242 |
+
$card->setData('token', $token);
|
243 |
+
$card->setData('cc_last4', substr($payment->getCcNumber(), -4));
|
244 |
+
$card->setData('cc_exp_month', $payment->getCcExpMonth());
|
245 |
+
$card->setData('cc_exp_year', $payment->getCcExpYear());
|
246 |
+
$card->setData('cc_type', $payment->getCcType());
|
247 |
+
if (count($card->currentCustomerCards()) || count($card->adminCustomerCards())) {
|
248 |
+
$card->setData('is_default', '0');
|
249 |
+
} else {
|
250 |
+
$card->setData('is_default', '1');
|
251 |
+
}
|
252 |
+
$card->save();
|
253 |
+
}
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Returns a previously saved card
|
258 |
+
*
|
259 |
+
* @param string $token token value
|
260 |
+
*
|
261 |
+
* @return Cardpay_HighRisk_Model_Creditcard credit card object
|
262 |
+
*/
|
263 |
+
public function getSavedCard($token)
|
264 |
+
{
|
265 |
+
$card = Mage::getModel('highrisk/creditcard')->load($token);
|
266 |
+
return $card;
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Returns payload for transaction
|
271 |
+
*
|
272 |
+
* @param Varien_Object $payment payment object
|
273 |
+
* @param decimal $amount amount in decimals
|
274 |
+
* @param string $transaction_type transaction type string
|
275 |
+
*
|
276 |
+
* @return array payload
|
277 |
+
*/
|
278 |
+
public function getPayload(Varien_Object $payment, $amount, $transactionType)
|
279 |
+
{
|
280 |
+
$post = Mage::app()->getRequest()->getPost();
|
281 |
+
|
282 |
+
if (isset($post['payment']['token']) && !empty($post['payment']['token'])) {
|
283 |
+
$card = $this->getSavedCard($post['payment']['token']);
|
284 |
+
$payment->setCcExpYear($card->getCcExpYear())
|
285 |
+
->setCcExpMonth($card->getCcExpMonth())
|
286 |
+
->setCcType($card->getCcType())
|
287 |
+
->setCcLast4($card->getCcLast4());
|
288 |
+
}
|
289 |
+
$order = $payment->getOrder();
|
290 |
+
$orderId = $order->getIncrementId();
|
291 |
+
$billing = $order->getBillingAddress();
|
292 |
+
$yr = substr($payment->getCcExpYear(), -2);
|
293 |
+
$expDate = sprintf('%02d%02d', $payment->getCcExpMonth(), $yr);
|
294 |
+
$testMode = $this->getConfigData('test_mode');
|
295 |
+
$data = '';
|
296 |
+
|
297 |
+
if ($testMode) {
|
298 |
+
$username = 'demo';
|
299 |
+
$password = 'password';
|
300 |
+
} else {
|
301 |
+
$username = $this->getConfigData('username');
|
302 |
+
$password = $this->getConfigData('password');
|
303 |
+
}
|
304 |
+
|
305 |
+
if ($transactionType == "auth" || $transactionType == "sale") {
|
306 |
+
if (isset($card)) {
|
307 |
+
$data = array(
|
308 |
+
'username' => $this->processInput($username),
|
309 |
+
'password' => $this->processInput($password),
|
310 |
+
'type' => $this->processInput($transactionType),
|
311 |
+
'customer_vault_id' => $this->processInput($card->getToken()),
|
312 |
+
'amount' => number_format($amount, 2, '.', ''),
|
313 |
+
'currency' => 'USD',
|
314 |
+
'orderid' => $this->processInput($orderId),
|
315 |
+
'firstname' => $this->processInput($billing->getFirstname()),
|
316 |
+
'lastname' => $this->processInput($billing->getLastname()),
|
317 |
+
'address1' => $this->processInput($billing->getStreet(1)),
|
318 |
+
'zip' => $this->processInput($billing->getPostcode()),
|
319 |
+
'tax' => number_format($order->getTaxAmount(), '2', '.', ''),
|
320 |
+
'shipping' => number_format($order->getShippingAmount(), '2', '.', ''),
|
321 |
+
'ponumber' => $this->processInput($orderId)
|
322 |
+
);
|
323 |
+
} else {
|
324 |
+
$data = array(
|
325 |
+
'username' => $this->processInput($username),
|
326 |
+
'password' => $this->processInput($password),
|
327 |
+
'type' => $this->processInput($transactionType),
|
328 |
+
'ccnumber' => $this->processInput($payment->getCcNumber()),
|
329 |
+
'ccexp' => $this->processInput($expDate),
|
330 |
+
'amount' => number_format($amount, 2, '.', ''),
|
331 |
+
'currency' => 'USD',
|
332 |
+
'cvv' => $this->processInput($payment->getCcCid()),
|
333 |
+
'orderid' => $this->processInput($orderId),
|
334 |
+
'firstname' => $this->processInput($billing->getFirstname()),
|
335 |
+
'lastname' => $this->processInput($billing->getLastname()),
|
336 |
+
'address1' => $this->processInput($billing->getStreet(1)),
|
337 |
+
'zip' => $this->processInput($billing->getPostcode()),
|
338 |
+
'tax' => number_format($order->getTaxAmount(), '2', '.', ''),
|
339 |
+
'shipping' => number_format($order->getShippingAmount(), '2', '.', ''),
|
340 |
+
'ponumber' => $this->processInput($orderId)
|
341 |
+
);
|
342 |
+
if (isset($post['payment']['save_card'])) {
|
343 |
+
$data['customer_vault'] = 'add_customer';
|
344 |
+
}
|
345 |
+
}
|
346 |
+
} else {
|
347 |
+
$data = array(
|
348 |
+
'username' => $this->processInput($username),
|
349 |
+
'password' => $this->processInput($password),
|
350 |
+
'transactionid' => $this->processInput($payment->getParentTransactionId()),
|
351 |
+
'amount' => number_format($amount, 2, '.', ''),
|
352 |
+
'currency' => 'USD',
|
353 |
+
'type' => $this->processInput($transactionType)
|
354 |
+
);
|
355 |
+
}
|
356 |
+
$query = '';
|
357 |
+
foreach ($data as $key => $value) {
|
358 |
+
$query .= $key.'='.urlencode($value).'&';
|
359 |
+
}
|
360 |
+
$query = trim($query, '&');
|
361 |
+
return $query;
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
* Returns payload for token request
|
366 |
+
*
|
367 |
+
* @param Cardpay_HighRisk_Model_Creditcard $card credit card object
|
368 |
+
*
|
369 |
+
* @return array payload
|
370 |
+
*/
|
371 |
+
public function getTokenPayload($card)
|
372 |
+
{
|
373 |
+
$yr = substr($card->getCcExpYear(), -2);
|
374 |
+
$expDate = sprintf('%02d%02d', $card->getCcExpMonth(), $yr);
|
375 |
+
$testMode = $this->getConfigData('test_mode');
|
376 |
+
$data = '';
|
377 |
+
|
378 |
+
if ($testMode) {
|
379 |
+
$username = 'demo';
|
380 |
+
$password = 'password';
|
381 |
+
} else {
|
382 |
+
$username = $this->getConfigData('username');
|
383 |
+
$password = $this->getConfigData('password');
|
384 |
+
}
|
385 |
+
|
386 |
+
$data = array(
|
387 |
+
'username' => $this->processInput($username),
|
388 |
+
'password' => $this->processInput($password),
|
389 |
+
'type' => 'validate',
|
390 |
+
'ccnumber' => $this->processInput($card->getCcNumber()),
|
391 |
+
'ccexp' => $this->processInput($expDate),
|
392 |
+
'cvv' => $this->processInput($card->getCcCid()),
|
393 |
+
'firstname' => $this->processInput($card->getCardholderFirstname()),
|
394 |
+
'lastname' => $this->processInput($card->getCardholderLastname()),
|
395 |
+
'amount' => '0.00',
|
396 |
+
'customer_vault' => 'add_customer'
|
397 |
+
);
|
398 |
+
$query = '';
|
399 |
+
foreach ($data as $key => $value) {
|
400 |
+
$query .= $key.'='.urlencode($value).'&';
|
401 |
+
}
|
402 |
+
$query = trim($query, '&');
|
403 |
+
return $query;
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* Post transaction to gateway
|
408 |
+
*
|
409 |
+
* @param array $payload payload
|
410 |
+
* @param array $headers headers
|
411 |
+
*
|
412 |
+
* @return string json response
|
413 |
+
*/
|
414 |
+
public function postTransaction($payload)
|
415 |
+
{
|
416 |
+
$request = curl_init();
|
417 |
+
curl_setopt($request, CURLOPT_URL, 'https://cardpaysolutions.transactiongateway.com/api/transact.php');
|
418 |
+
curl_setopt($request, CURLOPT_POST, true);
|
419 |
+
curl_setopt($request, CURLOPT_POSTFIELDS, $payload);
|
420 |
+
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
|
421 |
+
curl_setopt($request, CURLOPT_HEADER, false);
|
422 |
+
curl_setopt($request, CURLOPT_CONNECTTIMEOUT, 15);
|
423 |
+
curl_setopt($request, CURLOPT_TIMEOUT, 15);
|
424 |
+
curl_setopt($request, CURLOPT_VERBOSE, 0);
|
425 |
+
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, 0);
|
426 |
+
curl_setopt($request, CURLOPT_NOPROGRESS, 1);
|
427 |
+
curl_setopt($request, CURLOPT_FOLLOWLOCATION, 0);
|
428 |
+
$data = curl_exec($request);
|
429 |
+
if (false === $data) {
|
430 |
+
Mage::throwException('Transaction Error: ' . curl_error($request));
|
431 |
+
}
|
432 |
+
curl_close($request);
|
433 |
+
unset($request);
|
434 |
+
$data = explode('&', $data);
|
435 |
+
$count = count($data);
|
436 |
+
$response = array();
|
437 |
+
for ($i = 0; $i < $count; $i++) {
|
438 |
+
$rdata = explode('=', $data[$i]);
|
439 |
+
$response[$rdata[0]] = $rdata[1];
|
440 |
+
}
|
441 |
+
return $response;
|
442 |
+
}
|
443 |
+
|
444 |
+
/**
|
445 |
+
* Returns processed input
|
446 |
+
*
|
447 |
+
* @param string $data input data
|
448 |
+
*
|
449 |
+
* @return string processed input
|
450 |
+
*/
|
451 |
+
public function processInput($data)
|
452 |
+
{
|
453 |
+
$data = trim($data);
|
454 |
+
$data = stripslashes($data);
|
455 |
+
$data = htmlspecialchars($data);
|
456 |
+
return strval($data);
|
457 |
+
}
|
458 |
+
|
459 |
+
/**
|
460 |
+
* If payment method is available for currency
|
461 |
+
*
|
462 |
+
* @param string $currencyCode order currency
|
463 |
+
*
|
464 |
+
* @return bool available for currency or not
|
465 |
+
*/
|
466 |
+
public function canUseForCurrency($currencyCode)
|
467 |
+
{
|
468 |
+
if ($currencyCode != 'USD') {
|
469 |
+
return false;
|
470 |
+
}
|
471 |
+
return true;
|
472 |
+
}
|
473 |
+
}
|
app/code/community/Cardpay/HighRisk/Model/Resource/Creditcard.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Cardpay Solutions HighRisk credit card resource model.
|
21 |
+
*
|
22 |
+
* @category Cardpay
|
23 |
+
* @package Cardpay_HighRisk
|
24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaymerchant.com>
|
25 |
+
*/
|
26 |
+
class Cardpay_HighRisk_Model_Resource_Creditcard extends Mage_Core_Model_Resource_Db_Abstract
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Internal constructor. Set template.
|
30 |
+
*/
|
31 |
+
public function _construct()
|
32 |
+
{
|
33 |
+
// Note that the <module>_id refers to the key field in your database table.
|
34 |
+
$this->_init('highrisk/creditcard', 'cardpay_id');
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Cardpay/HighRisk/Model/Resource/Creditcard/Collection.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Cardpay Solutions HighRisk credit card collection resource model.
|
21 |
+
*
|
22 |
+
* @category Cardpay
|
23 |
+
* @package Cardpay_HighRisk
|
24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaymerchant.com>
|
25 |
+
*/
|
26 |
+
class Cardpay_HighRisk_Model_Resource_Creditcard_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Internal constructor.
|
30 |
+
*/
|
31 |
+
public function _construct()
|
32 |
+
{
|
33 |
+
parent::_construct();
|
34 |
+
$this->_init('highrisk/creditcard');
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Cardpay/HighRisk/Model/Source/Cctype.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Cardpay Solutions HighRisk credit card type source model.
|
21 |
+
*
|
22 |
+
* @category Cardpay
|
23 |
+
* @package Cardpay_HighRisk
|
24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaymerchant.com>
|
25 |
+
*/
|
26 |
+
class Cardpay_HighRisk_Model_Source_Cctype extends Mage_Payment_Model_Source_Cctype
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Allowed credit card types
|
30 |
+
*
|
31 |
+
* @return array allowed card types
|
32 |
+
*/
|
33 |
+
public function getAllowedTypes()
|
34 |
+
{
|
35 |
+
return array('VI', 'MC', 'AE', 'DI', 'JCB');
|
36 |
+
}
|
37 |
+
}
|
app/code/community/Cardpay/HighRisk/Model/Source/PaymentAction.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Cardpay Solutions HighRisk payment action source model.
|
21 |
+
*
|
22 |
+
* @category Cardpay
|
23 |
+
* @package Cardpay_HighRisk
|
24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaymerchant.com>
|
25 |
+
*/
|
26 |
+
class Cardpay_HighRisk_Model_Source_PaymentAction
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Possible actions on order place
|
30 |
+
*
|
31 |
+
* @return array payment actions
|
32 |
+
*/
|
33 |
+
public function toOptionArray()
|
34 |
+
{
|
35 |
+
return array(
|
36 |
+
array(
|
37 |
+
'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE,
|
38 |
+
'label' => 'Authorize'
|
39 |
+
),
|
40 |
+
array(
|
41 |
+
'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE,
|
42 |
+
'label' => 'Authorize and Capture'
|
43 |
+
),
|
44 |
+
);
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Cardpay/HighRisk/controllers/CreditcardController.php
ADDED
@@ -0,0 +1,245 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
require_once 'Mage/Customer/controllers/AccountController.php';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Cardpay Solutions HighRisk credit card controller.
|
23 |
+
*
|
24 |
+
* @category Cardpay
|
25 |
+
* @package Cardpay_HighRisk
|
26 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaymerchant.com>
|
27 |
+
*/
|
28 |
+
class Cardpay_HighRisk_CreditCardController extends Mage_Customer_AccountController
|
29 |
+
{
|
30 |
+
/**
|
31 |
+
* Retrieve customer session object
|
32 |
+
*
|
33 |
+
* @return Mage_Customer_Model_Session
|
34 |
+
*/
|
35 |
+
protected function _getSession()
|
36 |
+
{
|
37 |
+
return Mage::getSingleton('customer/session');
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Action predispatch
|
42 |
+
*
|
43 |
+
* Check if extension and vault are enabled, otherwise no route
|
44 |
+
*/
|
45 |
+
public function preDispatch()
|
46 |
+
{
|
47 |
+
parent::preDispatch();
|
48 |
+
|
49 |
+
if (!Mage::getSingleton('customer/session')->authenticate($this)
|
50 |
+
|| !Mage::getStoreConfig('payment/highrisk/use_vault')
|
51 |
+
|| !Mage::getStoreConfig('payment/highrisk/active')
|
52 |
+
) {
|
53 |
+
$this->setFlag('', 'no-dispatch', true);
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Customer credit card list
|
59 |
+
*/
|
60 |
+
public function indexAction()
|
61 |
+
{
|
62 |
+
$this->loadLayout();
|
63 |
+
$this->_initMessages();
|
64 |
+
$this->renderLayout();
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Customer new credit card
|
69 |
+
*/
|
70 |
+
public function newAction()
|
71 |
+
{
|
72 |
+
$this->loadLayout();
|
73 |
+
$this->_initMessages();
|
74 |
+
$this->renderLayout();
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Customer save credit card
|
79 |
+
*/
|
80 |
+
public function saveAction()
|
81 |
+
{
|
82 |
+
if (!$this->_validateFormKey()) {
|
83 |
+
$this->_getSession()->addError($this->__('Error saving credit card'));
|
84 |
+
return $this->_redirect('customer/creditcard/index');
|
85 |
+
}
|
86 |
+
if ($this->getRequest()->isPost()) {
|
87 |
+
$customerId = $this->_getSession()->getCustomerId();
|
88 |
+
$cardholderFirstname = $this->_getSession()->getCustomer()->getFirstname();
|
89 |
+
$cardholderLastname = $this->_getSession()->getCustomer()->getLastname();
|
90 |
+
$data = $this->getRequest()->getPost();
|
91 |
+
|
92 |
+
$card = Mage::getModel('highrisk/creditcard');
|
93 |
+
$card->addData($data['payment']);
|
94 |
+
$card->setData('customer_id', $customerId);
|
95 |
+
$card->setData('cc_last4', substr($card->getCcNumber(), -4));
|
96 |
+
$card->setData('cardholder_firstname', $cardholderFirstname);
|
97 |
+
$card->setData('cardholder_lastname', $cardholderLastname);
|
98 |
+
$highrisk = Mage::getModel('highrisk/paymentmethod');
|
99 |
+
try {
|
100 |
+
$token = $highrisk->verify($card);
|
101 |
+
} catch (Exception $e) {
|
102 |
+
$this->_getSession()->addError($e->getMessage());
|
103 |
+
return $this->_redirect('customer/creditcard/new');
|
104 |
+
}
|
105 |
+
|
106 |
+
$card->setData('token', $token);
|
107 |
+
if ($card->getIsDefault()) {
|
108 |
+
$card->clearDefault();
|
109 |
+
}
|
110 |
+
$card->save();
|
111 |
+
$this->_getSession()->addSuccess($this->__('The credit card has been saved.'));
|
112 |
+
}
|
113 |
+
$this->_redirect('customer/creditcard/index');
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Customer update credit card
|
118 |
+
*/
|
119 |
+
public function updateAction()
|
120 |
+
{
|
121 |
+
if (!$this->_validateFormKey()) {
|
122 |
+
$this->_getSession()->addError($this->__('Error updating credit card'));
|
123 |
+
return $this->_redirect('customer/creditcard/index');
|
124 |
+
}
|
125 |
+
if ($this->getRequest()->isPost()) {
|
126 |
+
$cardId = $this->getRequest()->getParam('id');
|
127 |
+
$customerId = $this->_getSession()->getCustomerId();
|
128 |
+
$cardholderFirstname = $this->_getSession()->getCustomer()->getFirstname();
|
129 |
+
$cardholderLastname = $this->_getSession()->getCustomer()->getLastname();
|
130 |
+
$data = $this->getRequest()->getPost();
|
131 |
+
$card = Mage::getModel('highrisk/creditcard')->load($cardId);
|
132 |
+
|
133 |
+
// Validate that card belongs to customer
|
134 |
+
if ($card->getCustomerId() != $customerId) {
|
135 |
+
$this->_getSession()->addError($this->__('The credit card does not belong to this customer.'));
|
136 |
+
return $this->_redirect('customer/creditcard/index');
|
137 |
+
}
|
138 |
+
|
139 |
+
$card->addData($data['payment']);
|
140 |
+
$card->setData('customer_id', $customerId);
|
141 |
+
$card->setData('cc_last4', substr($card->getCcNumber(), -4));
|
142 |
+
$card->setData('cardholder_firstname', $cardholderFirstname);
|
143 |
+
$card->setData('cardholder_lastname', $cardholderLastname);
|
144 |
+
$highrisk = Mage::getModel('highrisk/paymentmethod');
|
145 |
+
try {
|
146 |
+
$token = $highrisk->verify($card);
|
147 |
+
} catch (Exception $e) {
|
148 |
+
$this->_getSession()->addError($e->getMessage());
|
149 |
+
return $this->_redirect('customer/creditcard/new');
|
150 |
+
}
|
151 |
+
|
152 |
+
$card->setData('token', $token);
|
153 |
+
if ($card->getIsDefault()) {
|
154 |
+
$card->clearDefault();
|
155 |
+
}
|
156 |
+
$card->save();
|
157 |
+
$this->_getSession()->addSuccess($this->__('The credit card has been updated.'));
|
158 |
+
}
|
159 |
+
$this->_redirect('customer/creditcard/index');
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Customer edit credit card
|
164 |
+
*/
|
165 |
+
public function editAction()
|
166 |
+
{
|
167 |
+
$cardId = $this->getRequest()->getParam('id');
|
168 |
+
if ($cardId) {
|
169 |
+
$card = Mage::getModel('highrisk/creditcard')->load($cardId);
|
170 |
+
|
171 |
+
// Validate that card belongs to customer
|
172 |
+
if ($card->getCustomerId() != $this->_getSession()->getCustomerId()) {
|
173 |
+
$this->_getSession()->addError($this->__('The credit card does not belong to this customer.'));
|
174 |
+
return $this->_redirect('customer/creditcard/index');
|
175 |
+
}
|
176 |
+
$this->loadLayout();
|
177 |
+
$this->_initMessages();
|
178 |
+
$this->renderLayout();
|
179 |
+
} else {
|
180 |
+
$this->_getSession()->addError($this->__('Invalid credit card id.'));
|
181 |
+
return $this->_redirect('customer/creditcard/index');
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Customer delete credit card
|
187 |
+
*/
|
188 |
+
public function deleteAction()
|
189 |
+
{
|
190 |
+
$cardId = $this->getRequest()->getParam('id');
|
191 |
+
if ($cardId) {
|
192 |
+
$card = Mage::getModel('highrisk/creditcard')->load($cardId);
|
193 |
+
|
194 |
+
// Validate that card belongs to customer
|
195 |
+
if ($card->getCustomerId() != $this->_getSession()->getCustomerId()) {
|
196 |
+
$this->_getSession()->addError($this->__('The credit card does not belong to this customer.'));
|
197 |
+
return $this->_redirect('customer/creditcard/index');
|
198 |
+
}
|
199 |
+
$this->loadLayout();
|
200 |
+
$this->_initMessages();
|
201 |
+
$this->renderLayout();
|
202 |
+
} else {
|
203 |
+
$this->_getSession()->addError($this->__('Invalid credit card id.'));
|
204 |
+
return $this->_redirect('customer/creditcard/index');
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Customer confirm delete credit card
|
210 |
+
*/
|
211 |
+
public function deleteConfirmAction()
|
212 |
+
{
|
213 |
+
$cardId = $this->getRequest()->getParam('id');
|
214 |
+
if ($cardId) {
|
215 |
+
$card = Mage::getModel('highrisk/creditcard')->load($cardId);
|
216 |
+
|
217 |
+
// Validate that card belongs to customer
|
218 |
+
if ($card->getCustomerId() != $this->_getSession()->getCustomerId()) {
|
219 |
+
$this->_getSession()->addError($this->__('The credit card does not belong to this customer.'));
|
220 |
+
return $this->_redirect('customer/creditcard/index');
|
221 |
+
}
|
222 |
+
|
223 |
+
try {
|
224 |
+
$card->delete();
|
225 |
+
$this->_getSession()->addSuccess($this->__('The credit card has been deleted.'));
|
226 |
+
return $this->_redirect('customer/creditcard/index');
|
227 |
+
} catch (Exception $e){
|
228 |
+
$this->_getSession()->addError($this->__('An error occurred while deleting the credit card.'));
|
229 |
+
return $this->_redirect('customer/creditcard/index');
|
230 |
+
}
|
231 |
+
} else {
|
232 |
+
$this->_getSession()->addError($this->__('Invalid credit card id.'));
|
233 |
+
return $this->_redirect('customer/creditcard/index');
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Init layout messages, add page title
|
239 |
+
*/
|
240 |
+
protected function _initMessages()
|
241 |
+
{
|
242 |
+
$this->_initLayoutMessages('customer/session');
|
243 |
+
$this->getLayout()->getBlock('head')->setTitle($this->__('My Credit Cards'));
|
244 |
+
}
|
245 |
+
}
|
app/code/community/Cardpay/HighRisk/etc/config.xml
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Cardpay Solutions, Inc.
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* PHP version 5
|
13 |
+
*
|
14 |
+
* @category Cardpay
|
15 |
+
* @package Cardpay_HighRisk
|
16 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
17 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
18 |
+
*/
|
19 |
+
-->
|
20 |
+
<congig>
|
21 |
+
<modules>
|
22 |
+
<Cardpay_HighRisk>
|
23 |
+
<version>1.0.0</version>
|
24 |
+
</Cardpay_HighRisk>
|
25 |
+
</modules>
|
26 |
+
<global>
|
27 |
+
<blocks>
|
28 |
+
<highrisk>
|
29 |
+
<class>Cardpay_HighRisk_Block</class>
|
30 |
+
</highrisk>
|
31 |
+
</blocks>
|
32 |
+
<models>
|
33 |
+
<highrisk>
|
34 |
+
<class>Cardpay_HighRisk_Model</class>
|
35 |
+
<resourceModel>highrisk_resource</resourceModel>
|
36 |
+
</highrisk>
|
37 |
+
<highrisk_resource>
|
38 |
+
<class>Cardpay_HighRisk_Model_Resource</class>
|
39 |
+
<entities>
|
40 |
+
<creditcard>
|
41 |
+
<table>cardpay_credit_card</table>
|
42 |
+
</creditcard>
|
43 |
+
</entities>
|
44 |
+
</highrisk_resource>
|
45 |
+
</models>
|
46 |
+
<resources>
|
47 |
+
<highrisk_setup>
|
48 |
+
<setup>
|
49 |
+
<module>Cardpay_HighRisk</module>
|
50 |
+
</setup>
|
51 |
+
<connection>
|
52 |
+
<use>core_setup</use>
|
53 |
+
</connection>
|
54 |
+
</highrisk_setup>
|
55 |
+
<highrisk_write>
|
56 |
+
<connection>
|
57 |
+
<use>core_write</use>
|
58 |
+
</connection>
|
59 |
+
</highrisk_write>
|
60 |
+
<highrisk_read>
|
61 |
+
<connection>
|
62 |
+
<use>core_read</use>
|
63 |
+
</connection>
|
64 |
+
</highrisk_read>
|
65 |
+
</resources>
|
66 |
+
<helpers>
|
67 |
+
<highrisk>
|
68 |
+
<class>Cardpay_HighRisk_Helper</class>
|
69 |
+
</highrisk>
|
70 |
+
</helpers>
|
71 |
+
</global>
|
72 |
+
<default>
|
73 |
+
<payment>
|
74 |
+
<highrisk>
|
75 |
+
<active>0</active>
|
76 |
+
<model>highrisk/paymentMethod</model>
|
77 |
+
<order_status>processing</order_status>
|
78 |
+
<title>Credit Card (Cardpay Solutions)</title>
|
79 |
+
<cctypes>VI,MC,AE,DI,JCB</cctypes>
|
80 |
+
<payment_action>authorize</payment_action>
|
81 |
+
<allowspecific>0</allowspecific>
|
82 |
+
<useccv>1</useccv>
|
83 |
+
<use_vault>1</use_vault>
|
84 |
+
</highrisk>
|
85 |
+
</payment>
|
86 |
+
</default>
|
87 |
+
<frontend>
|
88 |
+
<layout>
|
89 |
+
<updates>
|
90 |
+
<highrisk module="Cardpay_HighRisk">
|
91 |
+
<file>highrisk.xml</file>
|
92 |
+
</highrisk>
|
93 |
+
</updates>
|
94 |
+
</layout>
|
95 |
+
<routers>
|
96 |
+
<customer>
|
97 |
+
<args>
|
98 |
+
<modules>
|
99 |
+
<Cardpay_HighRisk after="Mage_Customer">Cardpay_HighRisk</Cardpay_HighRisk>
|
100 |
+
</modules>
|
101 |
+
</args>
|
102 |
+
</customer>
|
103 |
+
</routers>
|
104 |
+
<translate>
|
105 |
+
<modules>
|
106 |
+
<Cardpay_HighRisk>
|
107 |
+
<files>
|
108 |
+
<default>Cardpay_HighRisk.csv</default>
|
109 |
+
</files>
|
110 |
+
</Cardpay_HighRisk>
|
111 |
+
</modules>
|
112 |
+
</translate>
|
113 |
+
</frontend>
|
114 |
+
</congig>
|
app/code/community/Cardpay/HighRisk/etc/system.xml
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Cardpay Solutions, Inc.
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* PHP version 5
|
13 |
+
*
|
14 |
+
* @category Cardpay
|
15 |
+
* @package Cardpay_HighRisk
|
16 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
17 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
18 |
+
*/
|
19 |
+
-->
|
20 |
+
<config>
|
21 |
+
<sections>
|
22 |
+
<payment>
|
23 |
+
<groups>
|
24 |
+
<highrisk translate="label" module="paygate">
|
25 |
+
<label>Cardpay Solutions - High Risk</label>
|
26 |
+
<sort_order>680</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 |
+
<comment><![CDATA[<a href="http://www.cardpaymerchant.com/magento?pid=739e86fc169dcb78" target="_blank">Click here to sign up for a Cardpay Solutions merchant account</a>]]></comment>
|
31 |
+
<fields>
|
32 |
+
<active translate="label">
|
33 |
+
<label>Enabled</label>
|
34 |
+
<frontend_type>select</frontend_type>
|
35 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
36 |
+
<sort_order>1</sort_order>
|
37 |
+
<show_in_default>1</show_in_default>
|
38 |
+
<show_in_website>1</show_in_website>
|
39 |
+
<show_in_store>0</show_in_store>
|
40 |
+
</active>
|
41 |
+
<title translate="label">
|
42 |
+
<label>Title</label>
|
43 |
+
<frontend_type>text</frontend_type>
|
44 |
+
<sort_order>2</sort_order>
|
45 |
+
<show_in_default>1</show_in_default>
|
46 |
+
<show_in_website>1</show_in_website>
|
47 |
+
<show_in_store>1</show_in_store>
|
48 |
+
</title>
|
49 |
+
<test_mode translate="label">
|
50 |
+
<label>Test Mode</label>
|
51 |
+
<frontend_type>select</frontend_type>
|
52 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
53 |
+
<comment><![CDATA[If test mode is enabled, your transactions will be sent to a test merchant account.]]></comment>
|
54 |
+
<sort_order>3</sort_order>
|
55 |
+
<show_in_default>1</show_in_default>
|
56 |
+
<show_in_website>1</show_in_website>
|
57 |
+
<show_in_store>0</show_in_store>
|
58 |
+
</test_mode>
|
59 |
+
<username translate="label">
|
60 |
+
<label>Username</label>
|
61 |
+
<comment><![CDATA[Username provided by Cardpay Solutions after you establish your account. Contact sales at (866) 588-0503 to obtain your username.]]></comment>
|
62 |
+
<frontend_type>text</frontend_type>
|
63 |
+
<sort_order>4</sort_order>
|
64 |
+
<show_in_default>1</show_in_default>
|
65 |
+
<show_in_website>1</show_in_website>
|
66 |
+
<show_in_store>0</show_in_store>
|
67 |
+
</username>
|
68 |
+
<password translate="label">
|
69 |
+
<label>Password</label>
|
70 |
+
<comment><![CDATA[Password provided by Cardpay Solutions after you establish your account. Contact sales at (866) 588-0503 to obtain your password.]]></comment>
|
71 |
+
<frontend_type>obscure</frontend_type>
|
72 |
+
<sort_order>5</sort_order>
|
73 |
+
<show_in_default>1</show_in_default>
|
74 |
+
<show_in_website>1</show_in_website>
|
75 |
+
<show_in_store>0</show_in_store>
|
76 |
+
</password>
|
77 |
+
<order_status translate="label">
|
78 |
+
<label>New order status</label>
|
79 |
+
<comment><![CDATA[The status of the order after the payment is successful.]]></comment>
|
80 |
+
<frontend_type>select</frontend_type>
|
81 |
+
<source_model>adminhtml/system_config_source_order_status</source_model>
|
82 |
+
<sort_order>6</sort_order>
|
83 |
+
<show_in_default>1</show_in_default>
|
84 |
+
<show_in_website>1</show_in_website>
|
85 |
+
<show_in_store>0</show_in_store>
|
86 |
+
</order_status>
|
87 |
+
<payment_action translate="label">
|
88 |
+
<label>Payment Action</label>
|
89 |
+
<frontend_type>select</frontend_type>
|
90 |
+
<source_model>highrisk/source_paymentAction</source_model>
|
91 |
+
<sort_order>7</sort_order>
|
92 |
+
<show_in_default>1</show_in_default>
|
93 |
+
<show_in_website>1</show_in_website>
|
94 |
+
<show_in_store>0</show_in_store>
|
95 |
+
</payment_action>
|
96 |
+
<cctypes translate="label">
|
97 |
+
<label>Credit Card Types</label>
|
98 |
+
<comment><![CDATA[Select which credit card types are accepted.]]></comment>
|
99 |
+
<frontend_type>multiselect</frontend_type>
|
100 |
+
<source_model>highrisk/source_cctype</source_model>
|
101 |
+
<sort_order>8</sort_order>
|
102 |
+
<show_in_default>1</show_in_default>
|
103 |
+
<show_in_website>1</show_in_website>
|
104 |
+
<show_in_store>0</show_in_store>
|
105 |
+
</cctypes>
|
106 |
+
<useccv translate="label">
|
107 |
+
<label>Credit Card Verification</label>
|
108 |
+
<comment><![CDATA[Whether the 3 or 4 digit card security code is required.]]></comment>
|
109 |
+
<frontend_type>select</frontend_type>
|
110 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
111 |
+
<sort_order>9</sort_order>
|
112 |
+
<show_in_default>1</show_in_default>
|
113 |
+
<show_in_website>1</show_in_website>
|
114 |
+
<show_in_store>0</show_in_store>
|
115 |
+
</useccv>
|
116 |
+
<use_vault translate="label">
|
117 |
+
<label>Allow Stored Cards</label>
|
118 |
+
<comment><![CDATA[Allow a logged in customer to save credit cards for future use. PCI Compliant Customer Vault. You must enable Customer Vault in your gateway for this feature to work.]]></comment>
|
119 |
+
<frontend_type>select</frontend_type>
|
120 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
121 |
+
<sort_order>10</sort_order>
|
122 |
+
<show_in_default>1</show_in_default>
|
123 |
+
<show_in_website>1</show_in_website>
|
124 |
+
<show_in_store>0</show_in_store>
|
125 |
+
</use_vault>
|
126 |
+
<allowspecific translate="label">
|
127 |
+
<label><![CDATA[Payment from applicable countries:]]></label>
|
128 |
+
<comment><![CDATA[Set this to "Specific Countries" if you wish to limit what countries may place orders.]]></comment>
|
129 |
+
<frontend_type>allowspecific</frontend_type>
|
130 |
+
<sort_order>11</sort_order>
|
131 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
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 |
+
</allowspecific>
|
136 |
+
<specificcountry translate="label">
|
137 |
+
<label><![CDATA[Payment from Specific countries:]]></label>
|
138 |
+
<comment><![CDATA[Which countries this payment method is available to. This becomes active if the setting above is set to "Specific Countries".]]></comment>
|
139 |
+
<frontend_type>multiselect</frontend_type>
|
140 |
+
<sort_order>12</sort_order>
|
141 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
142 |
+
<show_in_default>1</show_in_default>
|
143 |
+
<show_in_website>1</show_in_website>
|
144 |
+
<show_in_store>0</show_in_store>
|
145 |
+
</specificcountry>
|
146 |
+
<sort_order translate="label">
|
147 |
+
<label>Sort Order</label>
|
148 |
+
<comment><![CDATA[In which order this payment method will appear on the checkout page.]]></comment>
|
149 |
+
<frontend_type>text</frontend_type>
|
150 |
+
<sort_order>13</sort_order>
|
151 |
+
<show_in_default>1</show_in_default>
|
152 |
+
<show_in_website>1</show_in_website>
|
153 |
+
<show_in_store>0</show_in_store>
|
154 |
+
<frontend_class>validate-number</frontend_class>
|
155 |
+
</sort_order>
|
156 |
+
</fields>
|
157 |
+
</highrisk>
|
158 |
+
</groups>
|
159 |
+
</payment>
|
160 |
+
</sections>
|
161 |
+
</config>
|
app/code/community/Cardpay/HighRisk/sql/highrisk_setup/install-1.0.0.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
|
20 |
+
/* @var $installer Cardpay_HighRisk_Model_Resource_Creditcard */
|
21 |
+
$installer = $this;
|
22 |
+
$installer->startSetup();
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Create table 'cardpay_credit_card'
|
26 |
+
*/
|
27 |
+
$table = $installer->getConnection()
|
28 |
+
->newTable($installer->getTable('cardpay_credit_card'))
|
29 |
+
->addColumn('cardpay_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
30 |
+
'unsigned' => true,
|
31 |
+
'identity' => true,
|
32 |
+
'nullable' => false,
|
33 |
+
'primary' => true,
|
34 |
+
), 'Cardpay Id')
|
35 |
+
->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
36 |
+
'unsigned' => true,
|
37 |
+
'nullable' => false,
|
38 |
+
), 'Customer Id')
|
39 |
+
->addColumn('token', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
40 |
+
'nullable' => true,
|
41 |
+
), 'Token')
|
42 |
+
->addColumn('cc_last4', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
43 |
+
'nullable' => true,
|
44 |
+
), 'Cc Last4')
|
45 |
+
->addColumn('cc_exp_month', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
46 |
+
'nullable' => true,
|
47 |
+
), 'Cc Exp Month')
|
48 |
+
->addColumn('cc_exp_year', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
49 |
+
'nullable' => true,
|
50 |
+
), 'Cc Exp Year')
|
51 |
+
->addColumn('cc_type', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
52 |
+
'nullable' => true,
|
53 |
+
), 'Cc Type')
|
54 |
+
->addColumn('is_default', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
55 |
+
'unsigned' => true,
|
56 |
+
'nullable' => false,
|
57 |
+
'default' => '0',
|
58 |
+
), 'Is Default')
|
59 |
+
->addIndex($installer->getIdxName('cardpay_credit_card', array('customer_id')),
|
60 |
+
array('customer_id'))
|
61 |
+
->setComment('Cardpay Credit Card');
|
62 |
+
|
63 |
+
$installer->getConnection()->createTable($table);
|
64 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/template/highrisk/form.phtml
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
?>
|
19 |
+
<?php
|
20 |
+
$_code = $this->getMethodCode();
|
21 |
+
$_model = Mage::getModel('highrisk/creditcard');
|
22 |
+
$_savedCards = $_model->adminCustomerCards();
|
23 |
+
$_useVault = $_model->useVault() && count($_savedCards);
|
24 |
+
?>
|
25 |
+
<ul id="payment_form_<?php echo $_code ?>" style="display:none">
|
26 |
+
<?php if ($_useVault): ?>
|
27 |
+
<li id="<?php echo $_code ?>_token_selector">
|
28 |
+
<label for="<?php echo $_code ?>_cc_token"><?php echo $this->__('Payment Information') ?></label>
|
29 |
+
<div class="input-box">
|
30 |
+
<select id="<?php echo $_code ?>_token" name="payment[token]">
|
31 |
+
<?php $_token = $this->getInfoData('token') ?>
|
32 |
+
<option value="">Select Saved Card</option>
|
33 |
+
<?php foreach ($_savedCards as $card): ?>
|
34 |
+
<option value="<?php echo $card->getId() ?>" <?php if($card->getId() == $_token): ?>selected="selected"<?php endif ?>>
|
35 |
+
<?php echo $card->getMaskedCardNum() . ' - ' . $card->getCardTypeName(); ?>
|
36 |
+
</option>
|
37 |
+
<?php endforeach; ?>
|
38 |
+
</select>
|
39 |
+
</div>
|
40 |
+
</li>
|
41 |
+
<li class="hide-if-token"><p>-- OR --</p></li>
|
42 |
+
<?php endif; ?>
|
43 |
+
<li class="hide-if-token">
|
44 |
+
<div class="input-box">
|
45 |
+
<label for="<?php echo $_code ?>_cc_type"><?php echo Mage::helper('payment')->__('Credit Card Type') ?> <span class="required">*</span></label><br/>
|
46 |
+
<select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
|
47 |
+
<?php $_ccType = $this->getInfoData('cc_type') ?>
|
48 |
+
<option value=""></option>
|
49 |
+
<?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
|
50 |
+
<option value="<?php echo $_typeCode ?>" <?php if($_typeCode==$_ccType): ?>selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
|
51 |
+
<?php endforeach ?>
|
52 |
+
</select>
|
53 |
+
</div>
|
54 |
+
</li>
|
55 |
+
<li class="hide-if-token">
|
56 |
+
<div class="input-box">
|
57 |
+
<label for="<?php echo $_code ?>_cc_number"><?php echo Mage::helper('payment')->__('Credit Card Number') ?> <span class="required">*</span></label><br/>
|
58 |
+
<input type="text" id="<?php echo $_code ?>_cc_number" name="payment[cc_number]" title="<?php echo Mage::helper('payment')->__('Credit Card Number') ?>" class="input-text validate-cc-number" value="<?php echo $this->getInfoData('cc_number')?>"/>
|
59 |
+
</div>
|
60 |
+
</li>
|
61 |
+
<li class="hide-if-token">
|
62 |
+
<div class="input-box">
|
63 |
+
<label for="<?php echo $_code ?>_expiration"><?php echo Mage::helper('payment')->__('Expiration Date') ?> <span class="required">*</span></label><br/>
|
64 |
+
<select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="validate-cc-exp required-entry">
|
65 |
+
<?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
|
66 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
67 |
+
<option value="<?php echo $k ?>" <?php if($k==$_ccExpMonth): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
|
68 |
+
<?php endforeach ?>
|
69 |
+
</select>
|
70 |
+
<?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
|
71 |
+
<select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="required-entry">
|
72 |
+
<?php foreach ($this->getCcYears() as $k=>$v): ?>
|
73 |
+
<option value="<?php echo $k ? $k : '' ?>" <?php if($k==$_ccExpYear): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
|
74 |
+
<?php endforeach ?>
|
75 |
+
</select>
|
76 |
+
</div>
|
77 |
+
</li>
|
78 |
+
<?php if($this->hasVerification()): ?>
|
79 |
+
<li class="hide-if-token">
|
80 |
+
<div class="input-box">
|
81 |
+
<label for="<?php echo $_code ?>_cc_cid"><?php echo Mage::helper('payment')->__('Card Verification Number') ?> <span class="required">*</span></label><br/>
|
82 |
+
<input type="text" title="<?php echo Mage::helper('payment')->__('Card Verification Number') ?>" class="required-entry input-text validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" style="width:3em;" value="<?php echo $this->getInfoData('cc_cid')?>"/>
|
83 |
+
</div>
|
84 |
+
</li>
|
85 |
+
<?php endif; ?>
|
86 |
+
<?php if($_model->useVault()): ?>
|
87 |
+
<li class="hide-if-token" id="<?php echo $_code ?>_store_in_vault_div">
|
88 |
+
<input type="checkbox" title="<?php echo $this->__('Save this card for future use') ?>" class="input-checkbox" id="<?php echo $_code ?>_save_card" name="payment[save_card]" value="1" <?php if($this->getInfoData('save_card')): ?>checked="checked"<?php endif ?> />
|
89 |
+
<label for="<?php echo $_code ?>_save_card" style="float:none;"><?php echo $this->__('Save this card for future use') ?></label>
|
90 |
+
</li>
|
91 |
+
<?php endif; ?>
|
92 |
+
</ul>
|
93 |
+
|
94 |
+
<script type="text/javascript">
|
95 |
+
//<![CDATA[
|
96 |
+
(function() {
|
97 |
+
<?php if ($_useVault): ?>
|
98 |
+
var enableDisableFields = function(disabled) {
|
99 |
+
var code = "<?php echo $_code ?>";
|
100 |
+
<?php if($this->hasVerification()): ?>
|
101 |
+
var fields = ["_cc_type", "_cc_number", "_expiration", "_expiration_yr", "_cc_cid", "_save_card"];
|
102 |
+
<?php else: ?>
|
103 |
+
var fields = ["_cc_type", "_cc_number", "_expiration", "_expiration_yr", "_save_card"];
|
104 |
+
<?php endif; ?>
|
105 |
+
var id;
|
106 |
+
for (id = 0; id < fields.length; id++) {
|
107 |
+
$(code + fields[id]).disabled = disabled;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
var selectBox = $('<?php echo $_code ?>_token');
|
112 |
+
var initToken = selectBox.getValue();
|
113 |
+
|
114 |
+
if (initToken)
|
115 |
+
{
|
116 |
+
$$('.hide-if-token').invoke('hide');
|
117 |
+
enableDisableFields("disabled");
|
118 |
+
}
|
119 |
+
$('<?php echo $_code ?>_token').observe('change', function (e) {
|
120 |
+
var selectBox = $(this);
|
121 |
+
var token = selectBox.getValue();
|
122 |
+
if (token)
|
123 |
+
{
|
124 |
+
$$('.hide-if-token').invoke('hide');
|
125 |
+
enableDisableFields("disabled");
|
126 |
+
}
|
127 |
+
else
|
128 |
+
{
|
129 |
+
$('<?php echo $_code ?>_cc_type').value = "";
|
130 |
+
$('<?php echo $_code ?>_cc_number').value = "";
|
131 |
+
$('<?php echo $_code ?>_expiration').value = "";
|
132 |
+
$('<?php echo $_code ?>_expiration_yr').value = "";
|
133 |
+
<?php if($this->hasVerification()): ?>
|
134 |
+
$('<?php echo $_code ?>_cc_cid').value = "";
|
135 |
+
<?php endif; ?>
|
136 |
+
$('<?php echo $_code ?>_save_card').checked = false;
|
137 |
+
$$('.hide-if-token').invoke('show');
|
138 |
+
enableDisableFields(false);
|
139 |
+
}
|
140 |
+
});
|
141 |
+
<?php endif; ?>
|
142 |
+
})();
|
143 |
+
//]]></script>
|
app/design/frontend/base/default/layout/highrisk.xml
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Cardpay Solutions, Inc.
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
*
|
12 |
+
* PHP version 5
|
13 |
+
*
|
14 |
+
* @category Cardpay
|
15 |
+
* @package Cardpay_HighRisk
|
16 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
17 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
18 |
+
*/
|
19 |
+
-->
|
20 |
+
<layout version="0.1.0">
|
21 |
+
<customer_account>
|
22 |
+
<reference name="customer_account_navigation">
|
23 |
+
<action method="addLink" translate="label" module="highrisk" ifconfig="payment/highrisk/use_vault">
|
24 |
+
<name>credit_card</name>
|
25 |
+
<path>customer/creditcard/</path>
|
26 |
+
<label>My Credit Cards</label>
|
27 |
+
</action>
|
28 |
+
</reference>
|
29 |
+
</customer_account>
|
30 |
+
<customer_creditcard_index>
|
31 |
+
<update handle="customer_account"/>
|
32 |
+
<reference name="my.account.wrapper">
|
33 |
+
<block type="highrisk/creditcard" name="customer_creditcard" template="highrisk/creditcard/index.phtml" />
|
34 |
+
</reference>
|
35 |
+
</customer_creditcard_index>
|
36 |
+
<customer_creditcard_new>
|
37 |
+
<update handle="customer_account"/>
|
38 |
+
<reference name="my.account.wrapper">
|
39 |
+
<block type="highrisk/creditcard" name="customer_creditcard" template="highrisk/creditcard/edit.phtml"/>
|
40 |
+
</reference>
|
41 |
+
</customer_creditcard_new>
|
42 |
+
<customer_creditcard_edit>
|
43 |
+
<update handle="customer_account"/>
|
44 |
+
<reference name="my.account.wrapper">
|
45 |
+
<block type="highrisk/creditcard" name="customer_creditcard" template="highrisk/creditcard/edit.phtml">
|
46 |
+
<action method="setType"><value>edit</value></action>
|
47 |
+
</block>
|
48 |
+
</reference>
|
49 |
+
</customer_creditcard_edit>
|
50 |
+
<customer_creditcard_delete>
|
51 |
+
<update handle="customer_account"/>
|
52 |
+
<reference name="my.account.wrapper">
|
53 |
+
<block type="highrisk/creditcard" name="customer_creditcard" template="highrisk/creditcard/delete.phtml" />
|
54 |
+
</reference>
|
55 |
+
</customer_creditcard_delete>
|
56 |
+
</layout>
|
app/design/frontend/base/default/template/highrisk/creditcard/delete.phtml
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
?>
|
19 |
+
<?php
|
20 |
+
$id = Mage::app()->getRequest()->getParam('id');
|
21 |
+
$card = Mage::getModel('highrisk/creditcard')->load($id);
|
22 |
+
?>
|
23 |
+
<div class="page-title">
|
24 |
+
<h1><?php echo $this->__('Delete Credit Card') ?></h1>
|
25 |
+
</div>
|
26 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
27 |
+
<form action="<?php echo $this->getDeleteConfirmUrl($card->getId()) ?>" method="post" id="delete-form">
|
28 |
+
<div class="fieldset">
|
29 |
+
<h2 class="legend"><?php echo $this->__('Please confirm that you want to delete this credit card') ?></h2>
|
30 |
+
<ul class="form-list">
|
31 |
+
<li>
|
32 |
+
<b><?php echo $this->__('Credit Card Type'); ?></b>
|
33 |
+
</li>
|
34 |
+
<li>
|
35 |
+
<?php echo $card->getCardTypeName(); ?>
|
36 |
+
</li>
|
37 |
+
<li>
|
38 |
+
<b><?php echo $this->__('Credit Card Number'); ?></b>
|
39 |
+
</li>
|
40 |
+
<li>
|
41 |
+
<?php echo $card->getMaskedCardNum(); ?>
|
42 |
+
</li>
|
43 |
+
<li>
|
44 |
+
<b><?php echo $this->__('Expiration Date'); ?></b>
|
45 |
+
</li>
|
46 |
+
<li>
|
47 |
+
<?php echo $card->getCcExpMonth() . '/' . $card->getCcExpYear(); ?>
|
48 |
+
</li>
|
49 |
+
<li>
|
50 |
+
<b><?php echo $this->__('Cardholder Name'); ?></b>
|
51 |
+
</li>
|
52 |
+
<li>
|
53 |
+
<?php echo $card->getCardholderName(); ?>
|
54 |
+
</li>
|
55 |
+
</ul>
|
56 |
+
</div>
|
57 |
+
<div class="buttons-set">
|
58 |
+
<button type="submit" class="button" title="<?php echo $this->__('Delete') ?>"><span><span><?php echo $this->__('Delete') ?></span></span></button>
|
59 |
+
<p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
60 |
+
</div>
|
61 |
+
</form>
|
app/design/frontend/base/default/template/highrisk/creditcard/edit.phtml
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
?>
|
19 |
+
<div class="page-title">
|
20 |
+
<h1><?php echo $this->getTitle() ?></h1>
|
21 |
+
</div>
|
22 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
23 |
+
<?php
|
24 |
+
if ($this->isEditMode()) {
|
25 |
+
$creditCard = $this->creditCard();
|
26 |
+
$currentCcType = $creditCard->getCcType();
|
27 |
+
$currentCcExpMonth = $creditCard->getCcExpMonth();
|
28 |
+
$currentCcExpYear = $creditCard->getCcExpYear();
|
29 |
+
$isCcDefault = $creditCard->getIsDefault();
|
30 |
+
} else {
|
31 |
+
$currentCcType = '';
|
32 |
+
$currentCcExpMonth = '';
|
33 |
+
$currentCcExpYear = '';
|
34 |
+
}
|
35 |
+
?>
|
36 |
+
<form action='<?php echo $this->getFormAction() ?>' method="post" id="cc-form-validate">
|
37 |
+
<div class="fieldset">
|
38 |
+
<?php echo $this->getBlockHtml('formkey')?>
|
39 |
+
<h2 class="legend"><?php echo $this->__('Credit Card') ?></h2>
|
40 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
41 |
+
|
42 |
+
<ul class="form-list" id="payment_form_highrisk">
|
43 |
+
<li>
|
44 |
+
<label for="highrisk_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
|
45 |
+
<div class="input-box">
|
46 |
+
<select id="highrisk_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
|
47 |
+
<option value=""><?php echo $this->__('--Please Select--')?></option>
|
48 |
+
<?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
|
49 |
+
<option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$currentCcType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
|
50 |
+
<?php endforeach ?>
|
51 |
+
</select>
|
52 |
+
</div>
|
53 |
+
</li>
|
54 |
+
<li>
|
55 |
+
<label for="highrisk_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
|
56 |
+
<div class="input-box">
|
57 |
+
<input type="text" id="highrisk_cc_number" name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value="" />
|
58 |
+
</div>
|
59 |
+
</li>
|
60 |
+
<li id="highrisk_cc_type_exp_div" class="sp-methods">
|
61 |
+
<label for="highrisk_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
|
62 |
+
<div class="input-box">
|
63 |
+
<div class="v-fix">
|
64 |
+
<select id="highrisk_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
|
65 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
66 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$currentCcExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
67 |
+
<?php endforeach ?>
|
68 |
+
</select>
|
69 |
+
</div>
|
70 |
+
<div class="v-fix">
|
71 |
+
<select id="highrisk_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
|
72 |
+
<?php foreach ($this->getCcYears() as $k=>$v): ?>
|
73 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$currentCcExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
74 |
+
<?php endforeach ?>
|
75 |
+
</select>
|
76 |
+
</div>
|
77 |
+
</div>
|
78 |
+
</li>
|
79 |
+
<?php if($this->hasVerification()): ?>
|
80 |
+
<li id="highrisk_cc_type_cvv_div" class="sp-methods">
|
81 |
+
<label for="highrisk_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
|
82 |
+
<div class="input-box">
|
83 |
+
<div class="v-fix">
|
84 |
+
<input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="highrisk_cc_cid" name="payment[cc_cid]" value="" />
|
85 |
+
</div>
|
86 |
+
<a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
|
87 |
+
</div>
|
88 |
+
</li>
|
89 |
+
<?php endif; ?>
|
90 |
+
<?php if ($this->canShowMakeDefault()): ?>
|
91 |
+
<li id="highrisk_cc_make_default_div">
|
92 |
+
<label for="highrisk_cc_make_default"><?php echo $this->__('Make Default') ?></label>
|
93 |
+
<div class="input-box">
|
94 |
+
<input type="checkbox" name="payment[is_default]" id="highrisk_cc_make_default" value="1" />
|
95 |
+
</div>
|
96 |
+
</li>
|
97 |
+
<?php else: ?>
|
98 |
+
<input type="hidden" name="payment[is_default]" id="highrisk_cc_make_default" value="1" />
|
99 |
+
<?php endif; ?>
|
100 |
+
</ul>
|
101 |
+
</div>
|
102 |
+
<div class="buttons-set">
|
103 |
+
<button type="submit" class="button" title="<?php echo $this->__('Submit') ?>"><span><span><?php echo $this->__('Submit') ?></span></span></button>
|
104 |
+
<p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
105 |
+
</div>
|
106 |
+
</form>
|
107 |
+
<div class="tool-tip" id="payment-tool-tip" style="display:none;">
|
108 |
+
<div class="btn-close"><a href="#" id="payment-tool-tip-close" title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
|
109 |
+
<div class="tool-tip-content"><img src="<?php echo $this->getSkinUrl('images/cvv.gif') ?>" alt="<?php echo $this->__('Card Verification Number Visual Reference') ?>" title="<?php echo $this->__('Card Verification Number Visual Reference') ?>" /></div>
|
110 |
+
</div>
|
111 |
+
<script type="text/javascript">
|
112 |
+
//< ![CDATA[
|
113 |
+
var dataForm = new VarienForm('cc-form-validate', true);
|
114 |
+
//]]>
|
115 |
+
</script>
|
116 |
+
<script type="text/javascript">
|
117 |
+
function toggleToolTip(event){
|
118 |
+
if($('payment-tool-tip')){
|
119 |
+
$('payment-tool-tip').setStyle({
|
120 |
+
left: (Event.pointerX(event)-100)+'px',
|
121 |
+
top: (Event.pointerY(event)-200)+'px'
|
122 |
+
});
|
123 |
+
$('payment-tool-tip').toggle();
|
124 |
+
}
|
125 |
+
Event.stop(event);
|
126 |
+
}
|
127 |
+
|
128 |
+
$$('.cvv-what-is-this').each(function(element){
|
129 |
+
Event.observe(element, 'click', toggleToolTip);
|
130 |
+
});
|
131 |
+
if($('payment-tool-tip-close')){
|
132 |
+
Event.observe($('payment-tool-tip-close'), 'click', toggleToolTip);
|
133 |
+
}
|
134 |
+
</script>
|
app/design/frontend/base/default/template/highrisk/creditcard/index.phtml
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
?>
|
19 |
+
<?php
|
20 |
+
$highrisk = Mage::getModel('highrisk/creditcard');
|
21 |
+
$_savedCards = $highrisk->currentCustomerCards();
|
22 |
+
?>
|
23 |
+
<div class="page-title title-buttons">
|
24 |
+
<h1><?php echo $this->__('My Credit Cards') ?></h1>
|
25 |
+
<?php if ($highrisk->useVault()): ?>
|
26 |
+
<button type="button" title="<?php echo $this->__('Add Credit Card') ?>" class="button" onclick="window.location='<?php echo $this->getAddUrl() ?>';"><span><span><?php echo $this->__('Add Credit Card') ?></span></span></button>
|
27 |
+
<?php endif ?>
|
28 |
+
</div>
|
29 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
30 |
+
<?php if (count($_savedCards)): ?>
|
31 |
+
<table class="data-table" id="my-cards-table">
|
32 |
+
<col width="1" />
|
33 |
+
<col width="1" />
|
34 |
+
<col width="1" />
|
35 |
+
<col width="1" />
|
36 |
+
<col width="1" />
|
37 |
+
<col width="1" />
|
38 |
+
<thead>
|
39 |
+
<tr>
|
40 |
+
<th><?php echo $this->__('Type') ?></th>
|
41 |
+
<th><?php echo $this->__('Card Number') ?></th>
|
42 |
+
<th><?php echo $this->__('Expire Date') ?></th>
|
43 |
+
<th><?php echo $this->__('Is Default') ?></th>
|
44 |
+
<th colspan="2"><?php echo $this->__('Actions') ?></th>
|
45 |
+
</tr>
|
46 |
+
</thead>
|
47 |
+
<tbody>
|
48 |
+
<?php foreach ($_savedCards as $card): ?>
|
49 |
+
<tr>
|
50 |
+
<td><?php echo $card->getCardTypeName() ?></td>
|
51 |
+
<td><?php echo $card->getMaskedCardNum() ?></td>
|
52 |
+
<td><?php echo $card->getCcExpMonth() . '/' . $card->getCcExpYear() ?></td>
|
53 |
+
<td><?php echo ($card->getIsDefault()) ? $this->__('Yes') : $this->__('No') ?></td>
|
54 |
+
<td>
|
55 |
+
<a href="<?php echo $this->getEditUrl($card->getId()) ?>"><?php echo $this->__('Edit')?></a>
|
56 |
+
</td>
|
57 |
+
<td>
|
58 |
+
<a href="<?php echo $this->getDeleteUrl($card->getId()) ?>"><?php echo $this->__('Delete')?></a>
|
59 |
+
</td>
|
60 |
+
</tr>
|
61 |
+
<?php endforeach; ?>
|
62 |
+
</tbody>
|
63 |
+
</table>
|
64 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/highrisk/form.phtml
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cardpay Solutions, Inc.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is available through the world-wide-web at this URL:
|
9 |
+
* http://opensource.org/licenses/osl-3.0.php
|
10 |
+
*
|
11 |
+
* PHP version 5
|
12 |
+
*
|
13 |
+
* @category Cardpay
|
14 |
+
* @package Cardpay_HighRisk
|
15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaymerchant.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
?>
|
19 |
+
<?php
|
20 |
+
$_code = $this->getMethodCode();
|
21 |
+
$_model = Mage::getModel('highrisk/creditcard');
|
22 |
+
$_loggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
|
23 |
+
$_savedCards = $_model->currentCustomerCards();
|
24 |
+
$_useVault = $_loggedIn && $_model->useVault() && count($_savedCards);
|
25 |
+
?>
|
26 |
+
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
|
27 |
+
<?php if ($_useVault): ?>
|
28 |
+
<li id="<?php echo $_code ?>_token_selector">
|
29 |
+
<label for="<?php echo $_code ?>_cc_token"><?php echo $this->__('Payment Information') ?></label>
|
30 |
+
<div class="input-box">
|
31 |
+
<select id="<?php echo $_code ?>_token" name="payment[token]">
|
32 |
+
<?php foreach ($_savedCards as $card): ?>
|
33 |
+
<option value="<?php echo $card->getId() ?>" <?php echo $card->getIsDefault() ? 'selected="selected"' : '' ?>>
|
34 |
+
<?php echo $card->getMaskedCardNum() . ' - ' . $card->getCardTypeName(); ?>
|
35 |
+
</option>
|
36 |
+
<?php endforeach; ?>
|
37 |
+
<option value=''><?php echo $this->__('Add new card') ?></option>
|
38 |
+
</select>
|
39 |
+
</div>
|
40 |
+
</li>
|
41 |
+
<?php endif; ?>
|
42 |
+
<li class="hide-if-token">
|
43 |
+
<label for="<?php echo $_code ?>_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
|
44 |
+
<div class="input-box">
|
45 |
+
<select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
|
46 |
+
<option value=""><?php echo $this->__('--Please Select--')?></option>
|
47 |
+
<?php $_ccType = $this->getInfoData('cc_type') ?>
|
48 |
+
<?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
|
49 |
+
<option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
|
50 |
+
<?php endforeach ?>
|
51 |
+
</select>
|
52 |
+
</div>
|
53 |
+
</li>
|
54 |
+
<li class="hide-if-token">
|
55 |
+
<label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
|
56 |
+
<div class="input-box">
|
57 |
+
<input type="text" id="<?php echo $_code ?>_cc_number" name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value="" />
|
58 |
+
</div>
|
59 |
+
</li>
|
60 |
+
<li class="hide-if-token" id="<?php echo $_code ?>_cc_type_exp_div">
|
61 |
+
<label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
|
62 |
+
<div class="input-box">
|
63 |
+
<div class="v-fix">
|
64 |
+
<select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
|
65 |
+
<?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
|
66 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
67 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
68 |
+
<?php endforeach ?>
|
69 |
+
</select>
|
70 |
+
</div>
|
71 |
+
<div class="v-fix">
|
72 |
+
<?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
|
73 |
+
<select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
|
74 |
+
<?php foreach ($this->getCcYears() as $k=>$v): ?>
|
75 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
76 |
+
<?php endforeach ?>
|
77 |
+
</select>
|
78 |
+
</div>
|
79 |
+
</div>
|
80 |
+
</li>
|
81 |
+
<?php echo $this->getChildHtml() ?>
|
82 |
+
<?php if($this->hasVerification()): ?>
|
83 |
+
<li class="hide-if-token" id="<?php echo $_code ?>_cc_type_cvv_div">
|
84 |
+
<label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
|
85 |
+
<div class="input-box">
|
86 |
+
<div class="v-fix">
|
87 |
+
<input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" value="" />
|
88 |
+
</div>
|
89 |
+
<a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
|
90 |
+
</div>
|
91 |
+
</li>
|
92 |
+
<?php endif; ?>
|
93 |
+
<?php if($this->canSaveCard()): ?>
|
94 |
+
<li class="hide-if-token" id="<?php echo $_code ?>_store_in_vault_div">
|
95 |
+
<input type="checkbox" title="<?php echo $this->__('Save this card for future use') ?>" class="input-checkbox" id="<?php echo $_code ?>_save_card" name="payment[save_card]" value="1" />
|
96 |
+
<label for="<?php echo $_code ?>_save_card" class="required" style="float:none;"><?php echo $this->__('Save this card for future use') ?></label>
|
97 |
+
</li>
|
98 |
+
<?php endif; ?>
|
99 |
+
</ul>
|
100 |
+
|
101 |
+
<script type="text/javascript">
|
102 |
+
//<![CDATA[
|
103 |
+
(function() {
|
104 |
+
<?php if ($_useVault): ?>
|
105 |
+
var selectBox = $('<?php echo $_code ?>_token');
|
106 |
+
var initToken = selectBox.getValue();
|
107 |
+
var cardsJson = [
|
108 |
+
<?php foreach ($_savedCards as $card): ?>
|
109 |
+
<?php echo Mage::helper('core')->jsonEncode($card->getData()) ?>,
|
110 |
+
<?php endforeach; ?>
|
111 |
+
];
|
112 |
+
|
113 |
+
if (initToken)
|
114 |
+
{
|
115 |
+
var initialCard = objectFindByKey(cardsJson, 'cardpay_id', initToken);
|
116 |
+
$('<?php echo $_code ?>_cc_type').value = initialCard.cc_type;
|
117 |
+
$('<?php echo $_code ?>_cc_number').value = initialCard.cc_last4;
|
118 |
+
$('<?php echo $_code ?>_expiration').value = initialCard.cc_exp_month;
|
119 |
+
$('<?php echo $_code ?>_expiration_yr').value = initialCard.cc_exp_year;
|
120 |
+
<?php if($this->hasVerification()): ?>
|
121 |
+
$('<?php echo $_code ?>_cc_cid').value = "";
|
122 |
+
<?php endif; ?>
|
123 |
+
$('<?php echo $_code ?>_save_card').checked = false;
|
124 |
+
$$('.hide-if-token').invoke('hide');
|
125 |
+
}
|
126 |
+
$('<?php echo $_code ?>_token').observe('change', function (e) {
|
127 |
+
var selectBox = $(this);
|
128 |
+
var token = selectBox.getValue();
|
129 |
+
if (token)
|
130 |
+
{
|
131 |
+
var selectedCard = objectFindByKey(cardsJson, 'cardpay_id', token);
|
132 |
+
$('<?php echo $_code ?>_cc_type').value = selectedCard.cc_type;
|
133 |
+
$('<?php echo $_code ?>_cc_number').value = selectedCard.cc_last4;
|
134 |
+
$('<?php echo $_code ?>_expiration').value = selectedCard.cc_exp_month;
|
135 |
+
$('<?php echo $_code ?>_expiration_yr').value = selectedCard.cc_exp_year;
|
136 |
+
<?php if($this->hasVerification()): ?>
|
137 |
+
$('<?php echo $_code ?>_cc_cid').value = "";
|
138 |
+
<?php endif; ?>
|
139 |
+
$('<?php echo $_code ?>_save_card').checked = false;
|
140 |
+
$$('.hide-if-token').invoke('hide');
|
141 |
+
}
|
142 |
+
else
|
143 |
+
{
|
144 |
+
$('<?php echo $_code ?>_cc_type').value = "";
|
145 |
+
$('<?php echo $_code ?>_cc_number').value = "";
|
146 |
+
$('<?php echo $_code ?>_expiration').value = "";
|
147 |
+
$('<?php echo $_code ?>_expiration_yr').value = "";
|
148 |
+
<?php if($this->hasVerification()): ?>
|
149 |
+
$('<?php echo $_code ?>_cc_cid').value = "";
|
150 |
+
<?php endif; ?>
|
151 |
+
$('<?php echo $_code ?>_save_card').checked = false;
|
152 |
+
$$('.hide-if-token').invoke('show');
|
153 |
+
}
|
154 |
+
});
|
155 |
+
|
156 |
+
function objectFindByKey(array, key, value) {
|
157 |
+
for (var i = 0; i < array.length; i++) {
|
158 |
+
if (array[i][key] === value) {
|
159 |
+
return array[i];
|
160 |
+
}
|
161 |
+
}
|
162 |
+
return null;
|
163 |
+
}
|
164 |
+
|
165 |
+
<?php endif; ?>
|
166 |
+
})();
|
167 |
+
//]]></script>
|
app/etc/modules/Cardpay_HighRisk.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Cardpay_HighRisk>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Payment />
|
9 |
+
</depends>
|
10 |
+
</Cardpay_HighRisk>
|
11 |
+
</modules>
|
12 |
+
</config>
|
app/locale/en_US/Cardpay_HighRisk.csv
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
"""Save this card for future use""","""Save this card for future use"""
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Cardpay_HighRisk</name>
|
4 |
+
<version>1.0.0</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>
|
8 |
+
<extends/>
|
9 |
+
<summary>Cardpay Solutions payment extension for high risk merchant categories.</summary>
|
10 |
+
<description>The Cardpay Solutions payment extension allows you to securely accept credit cards through your Magento store. In addition to processing one-time transactions, the extension also utilizes our PCI Compliant Customer Vault to allow customers to securely store and manage credit card profiles for future use.</description>
|
11 |
+
<notes>Initial stable release</notes>
|
12 |
+
<authors><author><name>Brian McGowan</name><user>bmcgowan</user><email>bmcgowan@cardpaysolutions.com</email></author></authors>
|
13 |
+
<date>2015-09-24</date>
|
14 |
+
<time>23:24:36</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Cardpay"><dir name="HighRisk"><dir name="Block"><file name="Creditcard.php" hash="d87286ee278bf81a571edc6411a4a321"/><file name="Form.php" hash="089092e8d5300b7f6891ccb185fc3a8a"/><file name="Info.php" hash="c027f81c9e2b8b2611992e3c581ec29f"/></dir><dir name="Helper"><file name="Data.php" hash="502e0cecba86570654c013c5b792b501"/></dir><dir name="Model"><file name="Creditcard.php" hash="b506d622c60108abadc0957d216975ef"/><file name="PaymentMethod.php" hash="d5133d306da8d36f964767dd59683a5e"/><dir name="Resource"><dir name="Creditcard"><file name="Collection.php" hash="68172bf077bcc27b4db8564dc7c52b8a"/></dir><file name="Creditcard.php" hash="d56cb61ae5278d7175e3e8054ae10b63"/></dir><dir name="Source"><file name="Cctype.php" hash="7671061ef1acb22e1caa83c334352025"/><file name="PaymentAction.php" hash="18d2e13fd5ff87743cedf8de27e3f05a"/></dir></dir><dir name="controllers"><file name="CreditcardController.php" hash="12a3a4710502297c89f1c56b85f73334"/></dir><dir name="etc"><file name="config.xml" hash="d5a07b6cc007783465025df039722353"/><file name="system.xml" hash="4bdc2e2a7e91996cde5545a9bfc6ce66"/></dir><dir name="sql"><dir name="highrisk_setup"><file name="install-1.0.0.php" hash="6d3767d7c5f67c6859e3115109a00c76"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="highrisk"><file name="form.phtml" hash="305927d6d511843120fe6bc37090d7d2"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="highrisk.xml" hash="ec4a4d4adea468819869c734cb557691"/></dir><dir name="template"><dir name="highrisk"><dir name="creditcard"><file name="delete.phtml" hash="c30e86312e41272b937586a7b50d9fdb"/><file name="edit.phtml" hash="8deba8b8d7c960abe2f5fc1c20056caf"/><file name="index.phtml" hash="245bca436d6fc0789833cadaad004188"/></dir><file name="form.phtml" hash="b6af5458a74f8c28373b5b9bfd756a00"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cardpay_HighRisk.xml" hash="f7c58cf24a240615c95b44c4abbd0cbb"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Cardpay_HighRisk.csv" hash="1dad15e42befedbf24800f845bebb60c"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.3.29</min><max>5.6.10</max></php></required></dependencies>
|
18 |
+
</package>
|