Version Notes
Initial stable release
Download this release
Release Info
| Developer | Brian McGowan |
| Extension | Cardpay_Payeezy |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/community/Cardpay/.DS_Store +0 -0
- app/code/community/Cardpay/Payeezy/Block/Creditcard.php +236 -0
- app/code/community/Cardpay/Payeezy/Block/Form.php +53 -0
- app/code/community/Cardpay/Payeezy/Block/Info.php +98 -0
- app/code/community/Cardpay/Payeezy/Helper/Data.php +105 -0
- app/code/community/Cardpay/Payeezy/Model/Creditcard.php +124 -0
- app/code/community/Cardpay/Payeezy/Model/PaymentMethod.php +538 -0
- app/code/community/Cardpay/Payeezy/Model/Resource/Creditcard.php +36 -0
- app/code/community/Cardpay/Payeezy/Model/Resource/Creditcard/Collection.php +36 -0
- app/code/community/Cardpay/Payeezy/Model/Source/Cctype.php +37 -0
- app/code/community/Cardpay/Payeezy/Model/Source/PaymentAction.php +46 -0
- app/code/community/Cardpay/Payeezy/controllers/CreditcardController.php +239 -0
- app/code/community/Cardpay/Payeezy/etc/config.xml +115 -0
- app/code/community/Cardpay/Payeezy/etc/system.xml +171 -0
- app/code/community/Cardpay/Payeezy/sql/payeezy_setup/install-0.1.0.php +61 -0
- app/design/adminhtml/default/default/template/payeezy/form.phtml +143 -0
- app/design/frontend/base/default/layout/payeezy.xml +56 -0
- app/design/frontend/base/default/template/payeezy/creditcard/delete.phtml +61 -0
- app/design/frontend/base/default/template/payeezy/creditcard/edit.phtml +112 -0
- app/design/frontend/base/default/template/payeezy/creditcard/index.phtml +64 -0
- app/design/frontend/base/default/template/payeezy/form.phtml +167 -0
- app/etc/modules/Cardpay_Payeezy.xml +12 -0
- app/locale/en_US/Cardpay_Payeezy.csv +1 -0
- package.xml +18 -0
app/code/community/Cardpay/.DS_Store
ADDED
|
Binary file
|
app/code/community/Cardpay/Payeezy/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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* First Data Payeezy credit card block.
|
| 21 |
+
*
|
| 22 |
+
* @category Cardpay
|
| 23 |
+
* @package Cardpay_Payeezy
|
| 24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
|
| 25 |
+
*/
|
| 26 |
+
class Cardpay_Payeezy_Block_Creditcard extends Mage_Core_Block_Template
|
| 27 |
+
{
|
| 28 |
+
const TYPE_EDIT = 'edit';
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Returns credit card
|
| 32 |
+
*
|
| 33 |
+
* @return Cardpay_Payeezy_Model_Creditcard credit card object
|
| 34 |
+
*/
|
| 35 |
+
public function creditCard()
|
| 36 |
+
{
|
| 37 |
+
$id = Mage::app()->getRequest()->getParam('id');
|
| 38 |
+
$card = Mage::getModel('payeezy/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('payeezy/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('payeezy/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('payeezy/paymentmethod');
|
| 234 |
+
return $method->getConfigData('useccv');
|
| 235 |
+
}
|
| 236 |
+
}
|
app/code/community/Cardpay/Payeezy/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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* First Data Payeezy form block.
|
| 21 |
+
*
|
| 22 |
+
* @category Cardpay
|
| 23 |
+
* @package Cardpay_Payeezy
|
| 24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
|
| 25 |
+
*/
|
| 26 |
+
class Cardpay_Payeezy_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('payeezy/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('payeezy/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/Payeezy/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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* First Data Payeezy info block.
|
| 21 |
+
*
|
| 22 |
+
* @category Cardpay
|
| 23 |
+
* @package Cardpay_Payeezy
|
| 24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
|
| 25 |
+
*/
|
| 26 |
+
class Cardpay_Payeezy_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('payeezy')->__('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('payeezy')->__('Credit Card Type')] = $ccType;
|
| 81 |
+
}
|
| 82 |
+
if ($ccLast = $this->getInfo()->getCcLast4()) {
|
| 83 |
+
$data[Mage::helper('payeezy')->__('Credit Card Number')] = sprintf('xxxx-%s', $ccLast);
|
| 84 |
+
}
|
| 85 |
+
if ($this->hasCcExpDate()) {
|
| 86 |
+
$data[Mage::helper('payeezy')->__('Expiration Date')] = $this->getCcExpDate();
|
| 87 |
+
}
|
| 88 |
+
if (Mage::app()->getStore()->isAdmin()) {
|
| 89 |
+
if ($this->getInfo()->getCcAvsStatus()) {
|
| 90 |
+
$data[Mage::helper('payeezy')->__('AVS Response')] = $this->getInfo()->getCcAvsStatus();
|
| 91 |
+
}
|
| 92 |
+
if ($this->getInfo()->getCcCidStatus()) {
|
| 93 |
+
$data[Mage::helper('payeezy')->__('CVV2 Response')] = $this->getInfo()->getCcCidStatus();
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
return $transport->setData(array_merge($data, $transport->getData()));
|
| 97 |
+
}
|
| 98 |
+
}
|
app/code/community/Cardpay/Payeezy/Helper/Data.php
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* First Data Payeezy data helper.
|
| 21 |
+
*
|
| 22 |
+
* @category Cardpay
|
| 23 |
+
* @package Cardpay_Payeezy
|
| 24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
|
| 25 |
+
*/
|
| 26 |
+
class Cardpay_Payeezy_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 digit zip - Street Address, and 9 digit ZIP Code match',
|
| 58 |
+
'Y' => 'Exact match, 5 digit zip - Street Address, and 5 digit ZIP Code match',
|
| 59 |
+
'A' => 'Partial match - Street Address matches, ZIP Code does not',
|
| 60 |
+
'W' => 'Partial match - ZIP Code matches, Street Address does not',
|
| 61 |
+
'Z' => 'Partial match - 5 digit ZIP Code match only',
|
| 62 |
+
'N' => 'No match - No Address or ZIP Code match',
|
| 63 |
+
'U' => 'Unavailable - Address information is unavailable for that account number,
|
| 64 |
+
or the card issuer does not support',
|
| 65 |
+
'G' => 'Service Not supported, non-US Issuer does not participate',
|
| 66 |
+
'R' => 'Retry - Issuer system unavailable, retry later',
|
| 67 |
+
'E' => 'Not a mail or phone order',
|
| 68 |
+
'S' => 'Service not supported',
|
| 69 |
+
'Q' => 'Bill to address did not pass edit checks',
|
| 70 |
+
'D' => 'International street address and postal code match',
|
| 71 |
+
'B' => 'International street address match',
|
| 72 |
+
'C' => 'International street address and postal code not verified due to incompatable formats',
|
| 73 |
+
'P' => 'International postal code match, street address not verified due to incompatable format',
|
| 74 |
+
'1' => 'Cardholder name matches',
|
| 75 |
+
'2' => 'Cardholder name, billing address, and postal code match',
|
| 76 |
+
'3' => 'Cardholder name and billing postal code match',
|
| 77 |
+
'4' => 'Cardholder name and billing address match',
|
| 78 |
+
'5' => 'Cardholder name incorrect, billing address and postal code match',
|
| 79 |
+
'6' => 'Cardholder name incorrect, billing postal code matches',
|
| 80 |
+
'7' => 'Cardholder name incorrect, billing address matches',
|
| 81 |
+
'8' => 'Cardholder name, billing address, and postal code are all incorrect'
|
| 82 |
+
);
|
| 83 |
+
return $avsResponses[$code];
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* Returns cvv response description
|
| 88 |
+
*
|
| 89 |
+
* @param $code cvv response code
|
| 90 |
+
*
|
| 91 |
+
* @return string cvv message
|
| 92 |
+
*/
|
| 93 |
+
public function getCvvResponse($code)
|
| 94 |
+
{
|
| 95 |
+
$cvvResponses = array(
|
| 96 |
+
'M' => 'CVV2/CVC2 Match',
|
| 97 |
+
'N' => 'CVV2 / CVC2 No Match',
|
| 98 |
+
'P' => 'Not Processed',
|
| 99 |
+
'S' => 'Merchant Has Indicated that CVV2 / CVC2 is not present on card',
|
| 100 |
+
'U' => 'Issuer is not certified and/or has not provided visa encryption keys',
|
| 101 |
+
'I' => 'CVV2 code is invalid or empty'
|
| 102 |
+
);
|
| 103 |
+
return $cvvResponses[$code];
|
| 104 |
+
}
|
| 105 |
+
}
|
app/code/community/Cardpay/Payeezy/Model/Creditcard.php
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* First Data Payeezy credit card model.
|
| 21 |
+
*
|
| 22 |
+
* @category Cardpay
|
| 23 |
+
* @package Cardpay_Payeezy
|
| 24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
|
| 25 |
+
*/
|
| 26 |
+
class Cardpay_Payeezy_Model_Creditcard extends Mage_Core_Model_Abstract
|
| 27 |
+
{
|
| 28 |
+
/**
|
| 29 |
+
* Internal constructor.
|
| 30 |
+
*/
|
| 31 |
+
public function _construct()
|
| 32 |
+
{
|
| 33 |
+
parent::_construct();
|
| 34 |
+
$this->_init('payeezy/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 |
+
$payeezy = Mage::getModel('payeezy/paymentmethod');
|
| 75 |
+
return $payeezy->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 |
+
$payeezy = Mage::getModel('payeezy/paymentmethod');
|
| 86 |
+
return Mage::helper('payeezy')->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 '************' . substr($this->getToken(), -4);
|
| 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 |
+
* Clears the current defualt credit card
|
| 113 |
+
*/
|
| 114 |
+
public function clearDefault()
|
| 115 |
+
{
|
| 116 |
+
$cards = $this->currentCustomerCards();
|
| 117 |
+
foreach ($cards as $card) {
|
| 118 |
+
if ($card->getIsDefault()) {
|
| 119 |
+
$card->setIsDefault('0');
|
| 120 |
+
$card->save();
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
}
|
app/code/community/Cardpay/Payeezy/Model/PaymentMethod.php
ADDED
|
@@ -0,0 +1,538 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* First Data Payeezy payment method model.
|
| 21 |
+
*
|
| 22 |
+
* @category Cardpay
|
| 23 |
+
* @package Cardpay_Payeezy
|
| 24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
|
| 25 |
+
*/
|
| 26 |
+
class Cardpay_Payeezy_Model_PaymentMethod extends Mage_Payment_Model_Method_Cc
|
| 27 |
+
{
|
| 28 |
+
protected $_code = 'payeezy';
|
| 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 = 'payeezy/form';
|
| 42 |
+
protected $_infoBlockType = 'payeezy/info';
|
| 43 |
+
|
| 44 |
+
private $_baseURL;
|
| 45 |
+
private $_url;
|
| 46 |
+
private $_merchantToken;
|
| 47 |
+
|
| 48 |
+
const API_KEY = 'tF92QqXikGklcppFBAfzZnDFghkjBXrN';
|
| 49 |
+
const API_SECRET = 'ab66d97bab5a4781c50fff107a1eb10e0bb40258385fb7a4da2fa5b320d128ec';
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Validate data
|
| 53 |
+
*
|
| 54 |
+
* @return bool true
|
| 55 |
+
*/
|
| 56 |
+
public function validate()
|
| 57 |
+
{
|
| 58 |
+
return true;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* Authorizes specified amount
|
| 63 |
+
*
|
| 64 |
+
* @param Varien_Object $payment payment object
|
| 65 |
+
* @param decimal $amount amount in decimals
|
| 66 |
+
*
|
| 67 |
+
* @return Cardpay_Payeezy_Model_PaymentMethod payment method object
|
| 68 |
+
*/
|
| 69 |
+
public function authorize(Varien_Object $payment, $amount)
|
| 70 |
+
{
|
| 71 |
+
$post = Mage::app()->getRequest()->getPost();
|
| 72 |
+
$saveCard = $post['payment']['save_card'];
|
| 73 |
+
$payload = $this->getPayload($payment, $amount, "authorize");
|
| 74 |
+
$headerArray = $this->hmacAuthorizationToken($payload);
|
| 75 |
+
$response = json_decode($this->postTransaction($payload, $headerArray));
|
| 76 |
+
if ($response->transaction_status == "approved") {
|
| 77 |
+
$payment->setTransactionId($response->transaction_id)
|
| 78 |
+
->setCcApproval($response->transaction_tag)
|
| 79 |
+
->setCcTransId($response->transaction_id)
|
| 80 |
+
->setIsTransactionClosed(0)
|
| 81 |
+
->setParentTransactionId(null)
|
| 82 |
+
->setCcAvsStatus(Mage::helper('payeezy')->getAvsResponse($response->avs))
|
| 83 |
+
->setCcCidStatus(Mage::helper('payeezy')->getCvvResponse($response->cvv2));
|
| 84 |
+
if ($saveCard) {
|
| 85 |
+
$this->saveCard($payment, $response->token->token_data->value);
|
| 86 |
+
}
|
| 87 |
+
return $this;
|
| 88 |
+
} else {
|
| 89 |
+
if ($response->bank_message) {
|
| 90 |
+
Mage::throwException('Transaction Declined: ' . $response->bank_message);
|
| 91 |
+
} else {
|
| 92 |
+
Mage::throwException('Transaction Error: ' . $response->Error->messages[0]->description);
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* Captures specified amount
|
| 100 |
+
*
|
| 101 |
+
* @param Varien_Object $payment payment object
|
| 102 |
+
* @param decimal $amount amount in decimals
|
| 103 |
+
*
|
| 104 |
+
* @return Cardpay_Payeezy_Model_PaymentMethod payment method object
|
| 105 |
+
*/
|
| 106 |
+
public function capture(Varien_Object $payment, $amount)
|
| 107 |
+
{
|
| 108 |
+
if ($payment->getParentTransactionId()) {
|
| 109 |
+
$payload = $this->getPayload($payment, $amount, "capture");
|
| 110 |
+
$headerArray = $this->hmacAuthorizationToken($payload);
|
| 111 |
+
$response = json_decode($this->postTransaction($payload, $headerArray));
|
| 112 |
+
if ($response->transaction_status == "approved") {
|
| 113 |
+
$payment->setTransactionId($response->transaction_id)
|
| 114 |
+
->setCcApproval($response->transaction_tag)
|
| 115 |
+
->setCcTransId($response->transaction_id)
|
| 116 |
+
->setIsTransactionClosed(1)
|
| 117 |
+
->setParentTransactionId($payment->getParentTransactionId());
|
| 118 |
+
return $this;
|
| 119 |
+
} else {
|
| 120 |
+
if ($response->bank_message) {
|
| 121 |
+
Mage::throwException('Capture Failed: ' . $response->bank_message);
|
| 122 |
+
} else {
|
| 123 |
+
Mage::throwException('Capture Error: ' . $response->Error->messages[0]->description);
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
} else {
|
| 127 |
+
return $this->purchase($payment, $amount);
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
/**
|
| 132 |
+
* Authoirzes and captures specified amount
|
| 133 |
+
*
|
| 134 |
+
* @param Varien_Object $payment payment object
|
| 135 |
+
* @param decimal $amount amount in decimals
|
| 136 |
+
*
|
| 137 |
+
* @return Cardpay_Payeezy_Model_PaymentMethod payment method object
|
| 138 |
+
*/
|
| 139 |
+
public function purchase(Varien_Object $payment, $amount)
|
| 140 |
+
{
|
| 141 |
+
$post = Mage::app()->getRequest()->getPost();
|
| 142 |
+
$saveCard = $post['payment']['save_card'];
|
| 143 |
+
$payload = $this->getPayload($payment, $amount, "purchase");
|
| 144 |
+
$headerArray = $this->hmacAuthorizationToken($payload);
|
| 145 |
+
$response = json_decode($this->postTransaction($payload, $headerArray));
|
| 146 |
+
if ($response->transaction_status == "approved") {
|
| 147 |
+
$payment->setTransactionId($response->transaction_id)
|
| 148 |
+
->setCcApproval($response->transaction_tag)
|
| 149 |
+
->setCcTransId($response->transaction_id)
|
| 150 |
+
->setIsTransactionClosed(1)
|
| 151 |
+
->setParentTransactionId(null)
|
| 152 |
+
->setCcAvsStatus(Mage::helper('payeezy')->getAvsResponse($response->avs))
|
| 153 |
+
->setCcCidStatus(Mage::helper('payeezy')->getCvvResponse($response->cvv2));
|
| 154 |
+
if ($saveCard) {
|
| 155 |
+
$this->saveCard($payment, $response->token->token_data->value);
|
| 156 |
+
}
|
| 157 |
+
return $this;
|
| 158 |
+
} else {
|
| 159 |
+
if ($response->bank_message) {
|
| 160 |
+
Mage::throwException('Transaction Declined: ' . $response->bank_message);
|
| 161 |
+
} else {
|
| 162 |
+
Mage::throwException('Transaction Error: ' . $response->Error->messages[0]->description);
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* Refunds specified amount
|
| 169 |
+
*
|
| 170 |
+
* @param Varien_Object $payment payment object
|
| 171 |
+
* @param decimal $amount amount in decimals
|
| 172 |
+
*
|
| 173 |
+
* @return Cardpay_Payeezy_Model_PaymentMethod payment method object
|
| 174 |
+
*/
|
| 175 |
+
public function refund(Varien_Object $payment, $amount)
|
| 176 |
+
{
|
| 177 |
+
if ($payment->getParentTransactionId()) {
|
| 178 |
+
$payload = $this->getPayload($payment, $amount, "refund");
|
| 179 |
+
$headerArray = $this->hmacAuthorizationToken($payload);
|
| 180 |
+
$response = json_decode($this->postTransaction($payload, $headerArray));
|
| 181 |
+
if ($response->transaction_status == "approved") {
|
| 182 |
+
$payment->setTransactionId($response->transaction_id)
|
| 183 |
+
->setCcApproval($response->transaction_tag)
|
| 184 |
+
->setCcTransId($response->transaction_id)
|
| 185 |
+
->setIsTransactionClosed(1)
|
| 186 |
+
->setParentTransactionId($payment->getParentTransactionId());
|
| 187 |
+
return $this;
|
| 188 |
+
} else {
|
| 189 |
+
if ($response->bank_message) {
|
| 190 |
+
Mage::throwException('Refund Failed: ' . $response->bank_message);
|
| 191 |
+
} else {
|
| 192 |
+
Mage::throwException('Refund Error: ' . $response->Error->messages[0]->description);
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
} else {
|
| 196 |
+
Mage::throwException('Refund Failed: Invalid parent transaction ID.');
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
/**
|
| 201 |
+
* Voides authorized transaction
|
| 202 |
+
*
|
| 203 |
+
* @param Varien_Object $payment payment object
|
| 204 |
+
*
|
| 205 |
+
* @return Cardpay_Payeezy_Model_PaymentMethod payment method object
|
| 206 |
+
*/
|
| 207 |
+
public function void(Varien_Object $payment)
|
| 208 |
+
{
|
| 209 |
+
if ($payment->getParentTransactionId()) {
|
| 210 |
+
$amount = $payment->getBaseAmountAuthorized();
|
| 211 |
+
$payload = $this->getPayload($payment, $amount, "void");
|
| 212 |
+
$headerArray = $this->hmacAuthorizationToken($payload);
|
| 213 |
+
$response = json_decode($this->postTransaction($payload, $headerArray));
|
| 214 |
+
if ($response->transaction_status == "approved") {
|
| 215 |
+
$payment->setTransactionId($response->transaction_id)
|
| 216 |
+
->setCcApproval($response->transaction_tag)
|
| 217 |
+
->setCcTransId($response->transaction_id)
|
| 218 |
+
->setIsTransactionClosed(1)
|
| 219 |
+
->setParentTransactionId($payment->getParentTransactionId());
|
| 220 |
+
return $this;
|
| 221 |
+
} else {
|
| 222 |
+
if ($response->bank_message) {
|
| 223 |
+
Mage::throwException('Void Failed: ' . $response->bank_message);
|
| 224 |
+
} else {
|
| 225 |
+
Mage::throwException('Void Error: ' . $response->Error->messages[0]->description);
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
} else {
|
| 229 |
+
Mage::throwException('Void Failed: Invalid parent transaction ID.');
|
| 230 |
+
}
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
/**
|
| 234 |
+
* Voides transaction on cancel action
|
| 235 |
+
*
|
| 236 |
+
* @param Varien_Object $payment payment object
|
| 237 |
+
*
|
| 238 |
+
* @return Cardpay_Payeezy_Model_PaymentMethod payment method object
|
| 239 |
+
*/
|
| 240 |
+
public function cancel(Varien_Object $payment)
|
| 241 |
+
{
|
| 242 |
+
return $this->void($payment);
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
/**
|
| 246 |
+
* Requests token for card
|
| 247 |
+
*
|
| 248 |
+
* @param Cardpay_Payeezy_Model_Creditcard $card credit card object
|
| 249 |
+
*
|
| 250 |
+
* @return string token value
|
| 251 |
+
*/
|
| 252 |
+
public function verify($card)
|
| 253 |
+
{
|
| 254 |
+
$payload = $this->getTokenPayload($card);
|
| 255 |
+
$headerArray = $this->hmacAuthorizationToken($payload);
|
| 256 |
+
$response = json_decode($this->postTransaction($payload, $headerArray));
|
| 257 |
+
if ($response->status == "success") {
|
| 258 |
+
return $response->token->value;
|
| 259 |
+
} else {
|
| 260 |
+
if ($response->status) {
|
| 261 |
+
Mage::throwException('Card Declined');
|
| 262 |
+
} else {
|
| 263 |
+
Mage::throwException($response->Error->messages[0]->description);
|
| 264 |
+
}
|
| 265 |
+
}
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
/**
|
| 269 |
+
* Saves card and transarmor token
|
| 270 |
+
*
|
| 271 |
+
* @param Varien_Object $payment payment object
|
| 272 |
+
* @param string $token token value
|
| 273 |
+
*
|
| 274 |
+
* @return Cardpay_Payeezy_Model_Creditcard credit card object
|
| 275 |
+
*/
|
| 276 |
+
public function saveCard(Varien_Object $payment, $token)
|
| 277 |
+
{
|
| 278 |
+
if ($token) {
|
| 279 |
+
$customerId = $payment->getOrder()->getCustomerId();
|
| 280 |
+
$card = Mage::getModel('payeezy/creditcard');
|
| 281 |
+
$card->setData('customer_id', $customerId);
|
| 282 |
+
$card->setData('token', $token);
|
| 283 |
+
$card->setData('cc_exp_month', $payment->getCcExpMonth());
|
| 284 |
+
$card->setData('cc_exp_year', $payment->getCcExpYear());
|
| 285 |
+
$card->setData('cc_type', $payment->getCcType());
|
| 286 |
+
if (count($card->currentCustomerCards()) || count($card->adminCustomerCards())) {
|
| 287 |
+
$card->setData('is_default', '0');
|
| 288 |
+
} else {
|
| 289 |
+
$card->setData('is_default', '1');
|
| 290 |
+
}
|
| 291 |
+
$card->save();
|
| 292 |
+
}
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
/**
|
| 296 |
+
* Returns a previously saved card
|
| 297 |
+
*
|
| 298 |
+
* @param string $token token value
|
| 299 |
+
*
|
| 300 |
+
* @return Cardpay_Payeezy_Model_Creditcard credit card object
|
| 301 |
+
*/
|
| 302 |
+
public function getSavedCard($token)
|
| 303 |
+
{
|
| 304 |
+
$card = Mage::getModel('payeezy/creditcard')->load($token);
|
| 305 |
+
return $card;
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
/**
|
| 309 |
+
* Returns payload for transaction
|
| 310 |
+
*
|
| 311 |
+
* @param Varien_Object $payment payment object
|
| 312 |
+
* @param decimal $amount amount in decimals
|
| 313 |
+
* @param string $transaction_type transaction type string
|
| 314 |
+
*
|
| 315 |
+
* @return array payload
|
| 316 |
+
*/
|
| 317 |
+
public function getPayload(Varien_Object $payment, $amount, $transactionType)
|
| 318 |
+
{
|
| 319 |
+
$post = Mage::app()->getRequest()->getPost();
|
| 320 |
+
$token = $post['payment']['token'];
|
| 321 |
+
if ($token) {
|
| 322 |
+
$card = $this->getSavedCard($token);
|
| 323 |
+
$payment->setCcExpYear($card->getCcExpYear())
|
| 324 |
+
->setCcExpMonth($card->getCcExpMonth())
|
| 325 |
+
->setCcType($card->getCcType())
|
| 326 |
+
->setCcLast4(substr($card->getToken(), -4));
|
| 327 |
+
}
|
| 328 |
+
$order = $payment->getOrder();
|
| 329 |
+
$orderId = $order->getIncrementId();
|
| 330 |
+
$billing = $order->getBillingAddress();
|
| 331 |
+
$amountInCents = $amount * 100;
|
| 332 |
+
$yr = substr($payment->getCcExpYear(), -2);
|
| 333 |
+
$expDate = sprintf('%02d%02d', $payment->getCcExpMonth(), $yr);
|
| 334 |
+
$testMode = $this->getConfigData('test_mode');
|
| 335 |
+
$currency = $this->getConfigData('currency');
|
| 336 |
+
$ccType = Mage::helper('payeezy')->getCcTypeName($payment->getCcType());
|
| 337 |
+
$data = '';
|
| 338 |
+
|
| 339 |
+
if ($testMode) {
|
| 340 |
+
$this->_baseURL = 'https://api-cert.payeezy.com/v1/transactions';
|
| 341 |
+
$this->_merchantToken = 'fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6';
|
| 342 |
+
} else {
|
| 343 |
+
$this->_baseURL = 'https://api.payeezy.com/v1/transactions';
|
| 344 |
+
$this->_merchantToken = $this->getConfigData('merchant_token');
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
if ($transactionType == "authorize" || $transactionType == "purchase") {
|
| 348 |
+
if ($token) {
|
| 349 |
+
$data = array(
|
| 350 |
+
'merchant_ref' => $this->processInput($orderId),
|
| 351 |
+
'transaction_type' => $this->processInput($transactionType),
|
| 352 |
+
'method' => 'token',
|
| 353 |
+
'amount' => $this->processInput($amountInCents),
|
| 354 |
+
'currency_code' => $this->processInput($currency),
|
| 355 |
+
'token' => array(
|
| 356 |
+
'token_type' => 'FDToken',
|
| 357 |
+
'token_data' => array(
|
| 358 |
+
'type' => $this->processInput($ccType),
|
| 359 |
+
'value' => $this->processInput($card->getToken()),
|
| 360 |
+
'cardholder_name' => $this->processInput($billing->getName()),
|
| 361 |
+
'exp_date' => $this->processInput($expDate)
|
| 362 |
+
)
|
| 363 |
+
),
|
| 364 |
+
'billing_address' => array(
|
| 365 |
+
'street' => $this->processInput($billing->getStreet(1)),
|
| 366 |
+
'zip_postal_code' => $this->processInput($billing->getPostcode())
|
| 367 |
+
),
|
| 368 |
+
'level2' => array(
|
| 369 |
+
'tax1_amount' => $this->processInput($order->getTaxAmount()),
|
| 370 |
+
'customer_ref' => $this->processInput($orderId)
|
| 371 |
+
)
|
| 372 |
+
);
|
| 373 |
+
} else {
|
| 374 |
+
$data = array(
|
| 375 |
+
'merchant_ref' => $this->processInput($orderId),
|
| 376 |
+
'transaction_type' => $this->processInput($transactionType),
|
| 377 |
+
'method' => 'credit_card',
|
| 378 |
+
'amount' => $this->processInput($amountInCents),
|
| 379 |
+
'currency_code' => $this->processInput($currency),
|
| 380 |
+
'credit_card' => array(
|
| 381 |
+
'type' => $this->processInput(Mage::helper('payeezy')->getCcTypeName($payment->getCcType())),
|
| 382 |
+
'cardholder_name' => $this->processInput($billing->getName()),
|
| 383 |
+
'card_number' => $this->processInput($payment->getCcNumber()),
|
| 384 |
+
'exp_date' => $this->processInput($expDate),
|
| 385 |
+
'cvv' => $this->processInput($payment->getCcCid())
|
| 386 |
+
),
|
| 387 |
+
'billing_address' => array(
|
| 388 |
+
'street' => $this->processInput($billing->getStreet(1)),
|
| 389 |
+
'zip_postal_code' => $this->processInput($billing->getPostcode())
|
| 390 |
+
),
|
| 391 |
+
'level2' => array(
|
| 392 |
+
'tax1_amount' => $this->processInput($order->getTaxAmount()),
|
| 393 |
+
'customer_ref' => $this->processInput($orderId)
|
| 394 |
+
)
|
| 395 |
+
);
|
| 396 |
+
}
|
| 397 |
+
$this->_url = $this->_baseURL;
|
| 398 |
+
} else {
|
| 399 |
+
$this->_url = $this->_baseURL . '/' . $payment->getParentTransactionId();
|
| 400 |
+
$data = array(
|
| 401 |
+
'merchant_ref' => $this->processInput($orderId),
|
| 402 |
+
'transaction_type' => $this->processInput($transactionType),
|
| 403 |
+
'method' => $this->processInput('credit_card'),
|
| 404 |
+
'amount' => $this->processInput($amountInCents),
|
| 405 |
+
'currency_code' => $this->processInput($currency),
|
| 406 |
+
'transaction_tag' => $this->processInput($payment->getCcApproval())
|
| 407 |
+
);
|
| 408 |
+
}
|
| 409 |
+
return json_encode($data, JSON_FORCE_OBJECT);
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
/**
|
| 413 |
+
* Returns payload for token request
|
| 414 |
+
*
|
| 415 |
+
* @param Cardpay_Payeezy_Model_Creditcard $card credit card object
|
| 416 |
+
*
|
| 417 |
+
* @return array payload
|
| 418 |
+
*/
|
| 419 |
+
public function getTokenPayload($card)
|
| 420 |
+
{
|
| 421 |
+
$yr = substr($card->getCcExpYear(), -2);
|
| 422 |
+
$expDate = sprintf('%02d%02d', $card->getCcExpMonth, $yr);
|
| 423 |
+
$testMode = $this->getConfigData('test_mode');
|
| 424 |
+
$data = '';
|
| 425 |
+
|
| 426 |
+
if ($testMode) {
|
| 427 |
+
$this->_baseURL = 'https://api-cert.payeezy.com/v1/transactions';
|
| 428 |
+
$this->_merchantToken = 'fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6';
|
| 429 |
+
$taToken = 'NOIW';
|
| 430 |
+
} else {
|
| 431 |
+
$this->_baseURL = 'https://api.payeezy.com/v1/transactions';
|
| 432 |
+
$this->_merchantToken = $this->getConfigData('merchant_token');
|
| 433 |
+
$taToken = $this->getConfigData('ta_token');
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
$data = array(
|
| 437 |
+
'type' => 'FDToken',
|
| 438 |
+
'auth' => 'false',
|
| 439 |
+
'ta_token' => $this->processInput($taToken),
|
| 440 |
+
'credit_card' => array(
|
| 441 |
+
'type' => $this->processInput(Mage::helper('payeezy')->getCcTypeName($card->getCcType())),
|
| 442 |
+
'cardholder_name' => $this->processInput($card->getCardholderName()),
|
| 443 |
+
'card_number' => $this->processInput($card->getCcNumber()),
|
| 444 |
+
'exp_date' => $this->processInput($expDate),
|
| 445 |
+
'cvv' => $this->processInput($card->getCcCid())
|
| 446 |
+
)
|
| 447 |
+
);
|
| 448 |
+
$this->_url = $this->_baseURL . '/tokens';
|
| 449 |
+
return json_encode($data, JSON_FORCE_OBJECT);
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
/**
|
| 453 |
+
* Returns HMAC authorization values
|
| 454 |
+
*
|
| 455 |
+
* @param array $payload payload
|
| 456 |
+
*
|
| 457 |
+
* @return array hmac values
|
| 458 |
+
*/
|
| 459 |
+
public function hmacAuthorizationToken($payload)
|
| 460 |
+
{
|
| 461 |
+
$nonce = strval(hexdec(bin2hex(openssl_random_pseudo_bytes(4, $cstrong))));
|
| 462 |
+
$timestamp = strval(time() * 1000); //time stamp in milli seconds
|
| 463 |
+
$data = self::API_KEY . $nonce . $timestamp . $this->_merchantToken . $payload;
|
| 464 |
+
$hashAlgorithm = "sha256";
|
| 465 |
+
$hmac = hash_hmac($hashAlgorithm, $data, self::API_SECRET, false); // HMAC Hash in hex
|
| 466 |
+
$authorization = base64_encode($hmac);
|
| 467 |
+
return array(
|
| 468 |
+
'authorization' => $authorization,
|
| 469 |
+
'nonce' => $nonce,
|
| 470 |
+
'timestamp' => $timestamp
|
| 471 |
+
);
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
/**
|
| 475 |
+
* Post transaction to gateway
|
| 476 |
+
*
|
| 477 |
+
* @param array $payload payload
|
| 478 |
+
* @param array $headers headers
|
| 479 |
+
*
|
| 480 |
+
* @return string json response
|
| 481 |
+
*/
|
| 482 |
+
public function postTransaction($payload, $headers)
|
| 483 |
+
{
|
| 484 |
+
$request = curl_init();
|
| 485 |
+
curl_setopt($request, CURLOPT_URL, $this->_url);
|
| 486 |
+
curl_setopt($request, CURLOPT_POST, true);
|
| 487 |
+
curl_setopt($request, CURLOPT_POSTFIELDS, $payload);
|
| 488 |
+
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
|
| 489 |
+
curl_setopt($request, CURLOPT_HEADER, false);
|
| 490 |
+
//curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false);
|
| 491 |
+
curl_setopt(
|
| 492 |
+
$request, CURLOPT_HTTPHEADER, array(
|
| 493 |
+
'Content-Type: application/json',
|
| 494 |
+
'apikey:' . strval(self::API_KEY),
|
| 495 |
+
'token:' . strval($this->_merchantToken),
|
| 496 |
+
'Authorization:' . $headers['authorization'],
|
| 497 |
+
'nonce:' . $headers['nonce'],
|
| 498 |
+
'timestamp:' . $headers['timestamp']
|
| 499 |
+
)
|
| 500 |
+
);
|
| 501 |
+
$response = curl_exec($request);
|
| 502 |
+
if (false === $response) {
|
| 503 |
+
Mage::throwException('Transaction Error: ' . curl_error($request));
|
| 504 |
+
}
|
| 505 |
+
curl_close($request);
|
| 506 |
+
return $response;
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
/**
|
| 510 |
+
* Returns processed input
|
| 511 |
+
*
|
| 512 |
+
* @param string $data input data
|
| 513 |
+
*
|
| 514 |
+
* @return string processed input
|
| 515 |
+
*/
|
| 516 |
+
public function processInput($data)
|
| 517 |
+
{
|
| 518 |
+
$data = trim($data);
|
| 519 |
+
$data = stripslashes($data);
|
| 520 |
+
$data = htmlspecialchars($data);
|
| 521 |
+
return strval($data);
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
/**
|
| 525 |
+
* If payment method is available for currency
|
| 526 |
+
*
|
| 527 |
+
* @param string $currencyCode order currency
|
| 528 |
+
*
|
| 529 |
+
* @return bool available for currency or not
|
| 530 |
+
*/
|
| 531 |
+
public function canUseForCurrency($currencyCode)
|
| 532 |
+
{
|
| 533 |
+
if ($currencyCode != $this->getConfigData('currency')) {
|
| 534 |
+
return false;
|
| 535 |
+
}
|
| 536 |
+
return true;
|
| 537 |
+
}
|
| 538 |
+
}
|
app/code/community/Cardpay/Payeezy/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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* First Data Payeezy credit card resource model.
|
| 21 |
+
*
|
| 22 |
+
* @category Cardpay
|
| 23 |
+
* @package Cardpay_Payeezy
|
| 24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
|
| 25 |
+
*/
|
| 26 |
+
class Cardpay_Payeezy_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('payeezy/creditcard', 'payeezy_id');
|
| 35 |
+
}
|
| 36 |
+
}
|
app/code/community/Cardpay/Payeezy/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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* First Data Payeezy credit card collection resource model.
|
| 21 |
+
*
|
| 22 |
+
* @category Cardpay
|
| 23 |
+
* @package Cardpay_Payeezy
|
| 24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
|
| 25 |
+
*/
|
| 26 |
+
class Cardpay_Payeezy_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('payeezy/creditcard');
|
| 35 |
+
}
|
| 36 |
+
}
|
app/code/community/Cardpay/Payeezy/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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* First Data Payeezy credit card type source model.
|
| 21 |
+
*
|
| 22 |
+
* @category Cardpay
|
| 23 |
+
* @package Cardpay_Payeezy
|
| 24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
|
| 25 |
+
*/
|
| 26 |
+
class Cardpay_Payeezy_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/Payeezy/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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* First Data Payeezy payment action source model.
|
| 21 |
+
*
|
| 22 |
+
* @category Cardpay
|
| 23 |
+
* @package Cardpay_Payeezy
|
| 24 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
|
| 25 |
+
*/
|
| 26 |
+
class Cardpay_Payeezy_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/Payeezy/controllers/CreditcardController.php
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.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 |
+
* First Data Payeezy credit card controller.
|
| 23 |
+
*
|
| 24 |
+
* @category Cardpay
|
| 25 |
+
* @package Cardpay_Payeezy
|
| 26 |
+
* @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
|
| 27 |
+
*/
|
| 28 |
+
class Cardpay_Payeezy_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/payeezy/use_vault')
|
| 51 |
+
|| !Mage::getStoreConfig('payment/payeezy/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 |
+
$cardholderName = $this->_getSession()->getCustomer()->getName();
|
| 89 |
+
$data = $this->getRequest()->getPost();
|
| 90 |
+
|
| 91 |
+
$card = Mage::getModel('payeezy/creditcard');
|
| 92 |
+
$card->addData($data['payment']);
|
| 93 |
+
$card->setData('customer_id', $customerId);
|
| 94 |
+
$card->setData('cardholder_name', $cardholderName);
|
| 95 |
+
$payeezy = Mage::getModel('payeezy/paymentmethod');
|
| 96 |
+
try {
|
| 97 |
+
$token = $payeezy->verify($card);
|
| 98 |
+
} catch (Exception $e) {
|
| 99 |
+
$this->_getSession()->addError($e->getMessage());
|
| 100 |
+
return $this->_redirect('customer/creditcard/new');
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
$card->setData('token', $token);
|
| 104 |
+
if ($card->getIsDefault()) {
|
| 105 |
+
$card->clearDefault();
|
| 106 |
+
}
|
| 107 |
+
$card->save();
|
| 108 |
+
$this->_getSession()->addSuccess($this->__('The credit card has been saved.'));
|
| 109 |
+
}
|
| 110 |
+
$this->_redirect('customer/creditcard/index');
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* Customer update credit card
|
| 115 |
+
*/
|
| 116 |
+
public function updateAction()
|
| 117 |
+
{
|
| 118 |
+
if (!$this->_validateFormKey()) {
|
| 119 |
+
$this->_getSession()->addError($this->__('Error updating credit card'));
|
| 120 |
+
return $this->_redirect('customer/creditcard/index');
|
| 121 |
+
}
|
| 122 |
+
if ($this->getRequest()->isPost()) {
|
| 123 |
+
$cardId = $this->getRequest()->getParam('id');
|
| 124 |
+
$customerId = $this->_getSession()->getCustomerId();
|
| 125 |
+
$cardholderName = $this->_getSession()->getCustomer()->getName();
|
| 126 |
+
$data = $this->getRequest()->getPost();
|
| 127 |
+
$card = Mage::getModel('payeezy/creditcard')->load($cardId);
|
| 128 |
+
|
| 129 |
+
// Validate that card belongs to customer
|
| 130 |
+
if ($card->getCustomerId() != $customerId) {
|
| 131 |
+
$this->_getSession()->addError($this->__('The credit card does not belong to this customer.'));
|
| 132 |
+
return $this->_redirect('customer/creditcard/index');
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
$card->addData($data['payment']);
|
| 136 |
+
$card->setData('customer_id', $customerId);
|
| 137 |
+
$card->setData('cardholder_name', $cardholderName);
|
| 138 |
+
$payeezy = Mage::getModel('payeezy/paymentmethod');
|
| 139 |
+
try {
|
| 140 |
+
$token = $payeezy->verify($card);
|
| 141 |
+
} catch (Exception $e) {
|
| 142 |
+
$this->_getSession()->addError($e->getMessage());
|
| 143 |
+
return $this->_redirect('customer/creditcard/new');
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
$card->setData('token', $token);
|
| 147 |
+
if ($card->getIsDefault()) {
|
| 148 |
+
$card->clearDefault();
|
| 149 |
+
}
|
| 150 |
+
$card->save();
|
| 151 |
+
$this->_getSession()->addSuccess($this->__('The credit card has been updated.'));
|
| 152 |
+
}
|
| 153 |
+
$this->_redirect('customer/creditcard/index');
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
/**
|
| 157 |
+
* Customer edit credit card
|
| 158 |
+
*/
|
| 159 |
+
public function editAction()
|
| 160 |
+
{
|
| 161 |
+
$cardId = $this->getRequest()->getParam('id');
|
| 162 |
+
if ($cardId) {
|
| 163 |
+
$card = Mage::getModel('payeezy/creditcard')->load($cardId);
|
| 164 |
+
|
| 165 |
+
// Validate that card belongs to customer
|
| 166 |
+
if ($card->getCustomerId() != $this->_getSession()->getCustomerId()) {
|
| 167 |
+
$this->_getSession()->addError($this->__('The credit card does not belong to this customer.'));
|
| 168 |
+
return $this->_redirect('customer/creditcard/index');
|
| 169 |
+
}
|
| 170 |
+
$this->loadLayout();
|
| 171 |
+
$this->_initMessages();
|
| 172 |
+
$this->renderLayout();
|
| 173 |
+
} else {
|
| 174 |
+
$this->_getSession()->addError($this->__('Invalid credit card id.'));
|
| 175 |
+
return $this->_redirect('customer/creditcard/index');
|
| 176 |
+
}
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
/**
|
| 180 |
+
* Customer delete credit card
|
| 181 |
+
*/
|
| 182 |
+
public function deleteAction()
|
| 183 |
+
{
|
| 184 |
+
$cardId = $this->getRequest()->getParam('id');
|
| 185 |
+
if ($cardId) {
|
| 186 |
+
$card = Mage::getModel('payeezy/creditcard')->load($cardId);
|
| 187 |
+
|
| 188 |
+
// Validate that card belongs to customer
|
| 189 |
+
if ($card->getCustomerId() != $this->_getSession()->getCustomerId()) {
|
| 190 |
+
$this->_getSession()->addError($this->__('The credit card does not belong to this customer.'));
|
| 191 |
+
return $this->_redirect('customer/creditcard/index');
|
| 192 |
+
}
|
| 193 |
+
$this->loadLayout();
|
| 194 |
+
$this->_initMessages();
|
| 195 |
+
$this->renderLayout();
|
| 196 |
+
} else {
|
| 197 |
+
$this->_getSession()->addError($this->__('Invalid credit card id.'));
|
| 198 |
+
return $this->_redirect('customer/creditcard/index');
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
/**
|
| 203 |
+
* Customer confirm delete credit card
|
| 204 |
+
*/
|
| 205 |
+
public function deleteConfirmAction()
|
| 206 |
+
{
|
| 207 |
+
$cardId = $this->getRequest()->getParam('id');
|
| 208 |
+
if ($cardId) {
|
| 209 |
+
$card = Mage::getModel('payeezy/creditcard')->load($cardId);
|
| 210 |
+
|
| 211 |
+
// Validate that card belongs to customer
|
| 212 |
+
if ($card->getCustomerId() != $this->_getSession()->getCustomerId()) {
|
| 213 |
+
$this->_getSession()->addError($this->__('The credit card does not belong to this customer.'));
|
| 214 |
+
return $this->_redirect('customer/creditcard/index');
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
try {
|
| 218 |
+
$card->delete();
|
| 219 |
+
$this->_getSession()->addSuccess($this->__('The credit card has been deleted.'));
|
| 220 |
+
return $this->_redirect('customer/creditcard/index');
|
| 221 |
+
} catch (Exception $e){
|
| 222 |
+
$this->_getSession()->addError($this->__('An error occurred while deleting the credit card.'));
|
| 223 |
+
return $this->_redirect('customer/creditcard/index');
|
| 224 |
+
}
|
| 225 |
+
} else {
|
| 226 |
+
$this->_getSession()->addError($this->__('Invalid credit card id.'));
|
| 227 |
+
return $this->_redirect('customer/creditcard/index');
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
/**
|
| 232 |
+
* Init layout messages, add page title
|
| 233 |
+
*/
|
| 234 |
+
protected function _initMessages()
|
| 235 |
+
{
|
| 236 |
+
$this->_initLayoutMessages('customer/session');
|
| 237 |
+
$this->getLayout()->getBlock('head')->setTitle($this->__('My Credit Cards'));
|
| 238 |
+
}
|
| 239 |
+
}
|
app/code/community/Cardpay/Payeezy/etc/config.xml
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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_Payeezy
|
| 16 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.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_Payeezy>
|
| 23 |
+
<version>1.0.0</version>
|
| 24 |
+
</Cardpay_Payeezy>
|
| 25 |
+
</modules>
|
| 26 |
+
<global>
|
| 27 |
+
<blocks>
|
| 28 |
+
<payeezy>
|
| 29 |
+
<class>Cardpay_Payeezy_Block</class>
|
| 30 |
+
</payeezy>
|
| 31 |
+
</blocks>
|
| 32 |
+
<models>
|
| 33 |
+
<payeezy>
|
| 34 |
+
<class>Cardpay_Payeezy_Model</class>
|
| 35 |
+
<resourceModel>payeezy_resource</resourceModel>
|
| 36 |
+
</payeezy>
|
| 37 |
+
<payeezy_resource>
|
| 38 |
+
<class>Cardpay_Payeezy_Model_Resource</class>
|
| 39 |
+
<entities>
|
| 40 |
+
<creditcard>
|
| 41 |
+
<table>payeezy_credit_card</table>
|
| 42 |
+
</creditcard>
|
| 43 |
+
</entities>
|
| 44 |
+
</payeezy_resource>
|
| 45 |
+
</models>
|
| 46 |
+
<resources>
|
| 47 |
+
<payeezy_setup>
|
| 48 |
+
<setup>
|
| 49 |
+
<module>Cardpay_Payeezy</module>
|
| 50 |
+
</setup>
|
| 51 |
+
<connection>
|
| 52 |
+
<use>core_setup</use>
|
| 53 |
+
</connection>
|
| 54 |
+
</payeezy_setup>
|
| 55 |
+
<payeezy_write>
|
| 56 |
+
<connection>
|
| 57 |
+
<use>core_write</use>
|
| 58 |
+
</connection>
|
| 59 |
+
</payeezy_write>
|
| 60 |
+
<payeezy_read>
|
| 61 |
+
<connection>
|
| 62 |
+
<use>core_read</use>
|
| 63 |
+
</connection>
|
| 64 |
+
</payeezy_read>
|
| 65 |
+
</resources>
|
| 66 |
+
<helpers>
|
| 67 |
+
<payeezy>
|
| 68 |
+
<class>Cardpay_Payeezy_Helper</class>
|
| 69 |
+
</payeezy>
|
| 70 |
+
</helpers>
|
| 71 |
+
</global>
|
| 72 |
+
<default>
|
| 73 |
+
<payment>
|
| 74 |
+
<payeezy>
|
| 75 |
+
<active>0</active>
|
| 76 |
+
<model>payeezy/paymentMethod</model>
|
| 77 |
+
<order_status>processing</order_status>
|
| 78 |
+
<title>Credit Card (Payeezy)</title>
|
| 79 |
+
<cctypes>VI,MC,AE,DI,JCB</cctypes>
|
| 80 |
+
<payment_action>authorize</payment_action>
|
| 81 |
+
<allowspecific>0</allowspecific>
|
| 82 |
+
<currency>USD</currency>
|
| 83 |
+
<useccv>1</useccv>
|
| 84 |
+
<use_vault>1</use_vault>
|
| 85 |
+
</payeezy>
|
| 86 |
+
</payment>
|
| 87 |
+
</default>
|
| 88 |
+
<frontend>
|
| 89 |
+
<layout>
|
| 90 |
+
<updates>
|
| 91 |
+
<payeezy module="Cardpay_Payeezy">
|
| 92 |
+
<file>payeezy.xml</file>
|
| 93 |
+
</payeezy>
|
| 94 |
+
</updates>
|
| 95 |
+
</layout>
|
| 96 |
+
<routers>
|
| 97 |
+
<customer>
|
| 98 |
+
<args>
|
| 99 |
+
<modules>
|
| 100 |
+
<Cardpay_Payeezy after="Mage_Customer">Cardpay_Payeezy</Cardpay_Payeezy>
|
| 101 |
+
</modules>
|
| 102 |
+
</args>
|
| 103 |
+
</customer>
|
| 104 |
+
</routers>
|
| 105 |
+
<translate>
|
| 106 |
+
<modules>
|
| 107 |
+
<Cardpay_Payeezy>
|
| 108 |
+
<files>
|
| 109 |
+
<default>Cardpay_Payeezy.csv</default>
|
| 110 |
+
</files>
|
| 111 |
+
</Cardpay_Payeezy>
|
| 112 |
+
</modules>
|
| 113 |
+
</translate>
|
| 114 |
+
</frontend>
|
| 115 |
+
</congig>
|
app/code/community/Cardpay/Payeezy/etc/system.xml
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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_Payeezy
|
| 16 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.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 |
+
<payeezy translate="label" module="paygate">
|
| 25 |
+
<label>First Data Payeezy</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.cardpaysolutions.com/magento" target="_blank">Click here to sign up for a Payeezy 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 |
+
<merchant_token translate="label">
|
| 60 |
+
<label>Merchant Token</label>
|
| 61 |
+
<comment><![CDATA[Merchant Token provided by Payeezy after you establish your account.]]></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 |
+
</merchant_token>
|
| 68 |
+
<order_status translate="label">
|
| 69 |
+
<label>New order status</label>
|
| 70 |
+
<comment><![CDATA[The status of the order after the payment is successful.]]></comment>
|
| 71 |
+
<frontend_type>select</frontend_type>
|
| 72 |
+
<source_model>adminhtml/system_config_source_order_status</source_model>
|
| 73 |
+
<sort_order>5</sort_order>
|
| 74 |
+
<show_in_default>1</show_in_default>
|
| 75 |
+
<show_in_website>1</show_in_website>
|
| 76 |
+
<show_in_store>0</show_in_store>
|
| 77 |
+
</order_status>
|
| 78 |
+
<payment_action translate="label">
|
| 79 |
+
<label>Payment Action</label>
|
| 80 |
+
<frontend_type>select</frontend_type>
|
| 81 |
+
<source_model>payeezy/source_paymentAction</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 |
+
</payment_action>
|
| 87 |
+
<currency translate="label">
|
| 88 |
+
<label>Accepted Currency</label>
|
| 89 |
+
<comment><![CDATA[Account must be properly configured to process currencies other than USD. Contact sales for additional information: (866) 588-0503.]]></comment>
|
| 90 |
+
<frontend_type>select</frontend_type>
|
| 91 |
+
<source_model>adminhtml/system_config_source_currency</source_model>
|
| 92 |
+
<sort_order>7</sort_order>
|
| 93 |
+
<show_in_default>1</show_in_default>
|
| 94 |
+
<show_in_website>1</show_in_website>
|
| 95 |
+
<show_in_store>0</show_in_store>
|
| 96 |
+
</currency>
|
| 97 |
+
<cctypes translate="label">
|
| 98 |
+
<label>Credit Card Types</label>
|
| 99 |
+
<comment><![CDATA[Select which credit card types are accepted.]]></comment>
|
| 100 |
+
<frontend_type>multiselect</frontend_type>
|
| 101 |
+
<source_model>payeezy/source_cctype</source_model>
|
| 102 |
+
<sort_order>8</sort_order>
|
| 103 |
+
<show_in_default>1</show_in_default>
|
| 104 |
+
<show_in_website>1</show_in_website>
|
| 105 |
+
<show_in_store>0</show_in_store>
|
| 106 |
+
</cctypes>
|
| 107 |
+
<useccv translate="label">
|
| 108 |
+
<label>Credit Card Verification</label>
|
| 109 |
+
<comment><![CDATA[Whether the 3 or 4 digit card security code is required.]]></comment>
|
| 110 |
+
<frontend_type>select</frontend_type>
|
| 111 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 112 |
+
<sort_order>9</sort_order>
|
| 113 |
+
<show_in_default>1</show_in_default>
|
| 114 |
+
<show_in_website>1</show_in_website>
|
| 115 |
+
<show_in_store>0</show_in_store>
|
| 116 |
+
</useccv>
|
| 117 |
+
<use_vault translate="label">
|
| 118 |
+
<label>Allow Stored Cards</label>
|
| 119 |
+
<comment><![CDATA[Allow a logged in customer to save credit cards for future use. PCI Compliant TransArmor Tokenization.]]></comment>
|
| 120 |
+
<frontend_type>select</frontend_type>
|
| 121 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 122 |
+
<sort_order>10</sort_order>
|
| 123 |
+
<show_in_default>1</show_in_default>
|
| 124 |
+
<show_in_website>1</show_in_website>
|
| 125 |
+
<show_in_store>0</show_in_store>
|
| 126 |
+
</use_vault>
|
| 127 |
+
<ta_token translate="label">
|
| 128 |
+
<label>TransArmor Token</label>
|
| 129 |
+
<comment><![CDATA[TransArmor token provided by Payeezy after you establish your account. Required for Stored Card functionality to work.]]></comment>
|
| 130 |
+
<frontend_type>text</frontend_type>
|
| 131 |
+
<sort_order>11</sort_order>
|
| 132 |
+
<show_in_default>1</show_in_default>
|
| 133 |
+
<show_in_website>1</show_in_website>
|
| 134 |
+
<show_in_store>0</show_in_store>
|
| 135 |
+
</ta_token>
|
| 136 |
+
<allowspecific translate="label">
|
| 137 |
+
<label><![CDATA[Payment from applicable countries:]]></label>
|
| 138 |
+
<comment><![CDATA[Set this to "Specific Countries" if you wish to limit what countries may place orders.]]></comment>
|
| 139 |
+
<frontend_type>allowspecific</frontend_type>
|
| 140 |
+
<sort_order>12</sort_order>
|
| 141 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</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 |
+
</allowspecific>
|
| 146 |
+
<specificcountry translate="label">
|
| 147 |
+
<label><![CDATA[Payment from Specific countries:]]></label>
|
| 148 |
+
<comment><![CDATA[Which countries this payment method is available to. This becomes active if the setting above is set to "Specific Countries".]]></comment>
|
| 149 |
+
<frontend_type>multiselect</frontend_type>
|
| 150 |
+
<sort_order>13</sort_order>
|
| 151 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
| 152 |
+
<show_in_default>1</show_in_default>
|
| 153 |
+
<show_in_website>1</show_in_website>
|
| 154 |
+
<show_in_store>0</show_in_store>
|
| 155 |
+
</specificcountry>
|
| 156 |
+
<sort_order translate="label">
|
| 157 |
+
<label>Sort Order</label>
|
| 158 |
+
<comment><![CDATA[In which order this payment method will appear on the checkout page.]]></comment>
|
| 159 |
+
<frontend_type>text</frontend_type>
|
| 160 |
+
<sort_order>14</sort_order>
|
| 161 |
+
<show_in_default>1</show_in_default>
|
| 162 |
+
<show_in_website>1</show_in_website>
|
| 163 |
+
<show_in_store>0</show_in_store>
|
| 164 |
+
<frontend_class>validate-number</frontend_class>
|
| 165 |
+
</sort_order>
|
| 166 |
+
</fields>
|
| 167 |
+
</payeezy>
|
| 168 |
+
</groups>
|
| 169 |
+
</payment>
|
| 170 |
+
</sections>
|
| 171 |
+
</config>
|
app/code/community/Cardpay/Payeezy/sql/payeezy_setup/install-0.1.0.php
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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
/* @var $installer Cardpay_Payeezy_Model_Resource_Creditcard */
|
| 21 |
+
$installer = $this;
|
| 22 |
+
$installer->startSetup();
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Create table 'payeezy_credit_card'
|
| 26 |
+
*/
|
| 27 |
+
$table = $installer->getConnection()
|
| 28 |
+
->newTable($installer->getTable('payeezy_credit_card'))
|
| 29 |
+
->addColumn('payeezy_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
| 30 |
+
'unsigned' => true,
|
| 31 |
+
'identity' => true,
|
| 32 |
+
'nullable' => false,
|
| 33 |
+
'primary' => true,
|
| 34 |
+
), 'Payeezy 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_exp_month', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
| 43 |
+
'nullable' => true,
|
| 44 |
+
), 'Cc Exp Month')
|
| 45 |
+
->addColumn('cc_exp_year', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
| 46 |
+
'nullable' => true,
|
| 47 |
+
), 'Cc Exp Year')
|
| 48 |
+
->addColumn('cc_type', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
| 49 |
+
'nullable' => true,
|
| 50 |
+
), 'Cc Type')
|
| 51 |
+
->addColumn('is_default', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
| 52 |
+
'unsigned' => true,
|
| 53 |
+
'nullable' => false,
|
| 54 |
+
'default' => '0',
|
| 55 |
+
), 'Is Default')
|
| 56 |
+
->addIndex($installer->getIdxName('payeezy_credit_card', array('customer_id')),
|
| 57 |
+
array('customer_id'))
|
| 58 |
+
->setComment('Payeezy Credit Card');
|
| 59 |
+
|
| 60 |
+
$installer->getConnection()->createTable($table);
|
| 61 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/template/payeezy/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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.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('payeezy/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/payeezy.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_Payeezy
|
| 16 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.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="payeezy" ifconfig="payment/payeezy/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="payeezy/creditcard" name="customer_creditcard" template="payeezy/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="payeezy/creditcard" name="customer_creditcard" template="payeezy/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="payeezy/creditcard" name="customer_creditcard" template="payeezy/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="payeezy/creditcard" name="customer_creditcard" template="payeezy/creditcard/delete.phtml" />
|
| 54 |
+
</reference>
|
| 55 |
+
</customer_creditcard_delete>
|
| 56 |
+
</layout>
|
app/design/frontend/base/default/template/payeezy/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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.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('payeezy/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/payeezy/creditcard/edit.phtml
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.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 |
+
}
|
| 31 |
+
?>
|
| 32 |
+
<div class="tool-tip" id="payment-tool-tip" style="display:none;">
|
| 33 |
+
<div class="btn-close"><a href="#" id="payment-tool-tip-close" title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
|
| 34 |
+
<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>
|
| 35 |
+
</div>
|
| 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_payeezy">
|
| 43 |
+
<li>
|
| 44 |
+
<label for="payeezy_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
|
| 45 |
+
<div class="input-box">
|
| 46 |
+
<select id="payeezy_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="payeezy_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
|
| 56 |
+
<div class="input-box">
|
| 57 |
+
<input type="text" id="payeezy_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="payeezy_cc_type_exp_div" class="sp-methods">
|
| 61 |
+
<label for="payeezy_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
|
| 62 |
+
<div class="input-box">
|
| 63 |
+
<div class="v-fix">
|
| 64 |
+
<select id="payeezy_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="payeezy_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="payeezy_cc_type_cvv_div" class="sp-methods">
|
| 81 |
+
<label for="payeezy_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="<?php echo $_code ?>_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="payeezy_cc_make_default_div">
|
| 92 |
+
<label for="payeezy_cc_make_default"><?php echo $this->__('Make Default') ?></label>
|
| 93 |
+
<div class="input-box">
|
| 94 |
+
<input type="checkbox" name="payment[is_default]" id="payeezy_cc_make_default" value="1" />
|
| 95 |
+
</div>
|
| 96 |
+
</li>
|
| 97 |
+
<?php else: ?>
|
| 98 |
+
<input type="hidden" name="payment[is_default]" id="payeezy_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 |
+
|
| 108 |
+
<script type="text/javascript">
|
| 109 |
+
//< ![CDATA[
|
| 110 |
+
var dataForm = new VarienForm('cc-form-validate', true);
|
| 111 |
+
//]]>
|
| 112 |
+
</script>
|
app/design/frontend/base/default/template/payeezy/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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
?>
|
| 19 |
+
<?php
|
| 20 |
+
$payeezy = Mage::getModel('payeezy/creditcard');
|
| 21 |
+
$_savedCards = $payeezy->currentCustomerCards();
|
| 22 |
+
?>
|
| 23 |
+
<div class="page-title title-buttons">
|
| 24 |
+
<h1><?php echo $this->__('My Credit Cards') ?></h1>
|
| 25 |
+
<?php if ($payeezy->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/payeezy/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_Payeezy
|
| 15 |
+
* @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.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('payeezy/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, 'payeezy_id', initToken);
|
| 116 |
+
$('<?php echo $_code ?>_cc_type').value = initialCard.cc_type;
|
| 117 |
+
$('<?php echo $_code ?>_cc_number').value = initialCard.token;
|
| 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, 'payeezy_id', token);
|
| 132 |
+
$('<?php echo $_code ?>_cc_type').value = selectedCard.cc_type;
|
| 133 |
+
$('<?php echo $_code ?>_cc_number').value = selectedCard.token;
|
| 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_Payeezy.xml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Cardpay_Payeezy>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
<depends>
|
| 8 |
+
<Mage_Payment />
|
| 9 |
+
</depends>
|
| 10 |
+
</Cardpay_Payeezy>
|
| 11 |
+
</modules>
|
| 12 |
+
</config>
|
app/locale/en_US/Cardpay_Payeezy.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_Payeezy</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>First Data Payeezy payment extension with TransArmor.</summary>
|
| 10 |
+
<description>The First Data Payeezy payment extension allows you to securely accept credit cards through your Magento store. In addition to processing one-time transactions, the extension also utilizes First Data TransArmor Tokenization 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-01</date>
|
| 14 |
+
<time>22:15:14</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir name="Cardpay"><dir name="Payeezy"><dir name="Block"><file name="Creditcard.php" hash="a0d44b2d6901f147e7ba8ac1522a1f61"/><file name="Form.php" hash="35ecc9030ab25cdd83e8fb8662e1c4f1"/><file name="Info.php" hash="8c120874f2dcbea00ce1f3e11620c4e3"/></dir><dir name="Helper"><file name="Data.php" hash="b244a2c1646ae47d1ceced0473c8c144"/></dir><dir name="Model"><file name="Creditcard.php" hash="97ec6c6e017bb9895dd487aed85367a1"/><file name="PaymentMethod.php" hash="418681a6fd19eb104ebe8468622ae9d4"/><dir name="Resource"><dir name="Creditcard"><file name="Collection.php" hash="6003a43e766277d0ee7e788815473783"/></dir><file name="Creditcard.php" hash="13ed47dda59c30d23382eb4af76c2293"/></dir><dir name="Source"><file name="Cctype.php" hash="9c3e10285ec4d78d17e19e49d803518b"/><file name="PaymentAction.php" hash="1ddd3037b306f1ab9cffe8f93f0cb8e3"/></dir></dir><dir name="controllers"><file name="CreditcardController.php" hash="29b0520b713ecab57c3ad619e0ff6275"/></dir><dir name="etc"><file name="config.xml" hash="3e1c307ff93fc28a4f1b11c7e9f08404"/><file name="system.xml" hash="a8e92c962f47293363eedd03ded7083f"/></dir><dir name="sql"><dir name="payeezy_setup"><file name="install-0.1.0.php" hash="99c1f9408ce25663c185719b446b2adb"/></dir></dir></dir><file name=".DS_Store" hash="a5c46fc114cefdd5054ea2085bc3a3bd"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="payeezy"><file name="form.phtml" hash="ea092ad5359031ec57e3dfc22b007cda"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="payeezy.xml" hash="2bea5df11e86b9c8c589d1e572eea4f0"/></dir><dir name="template"><dir name="payeezy"><dir name="creditcard"><file name="delete.phtml" hash="7f52b91b36608bcaff0422490363c7fd"/><file name="edit.phtml" hash="f8135f96f390a5f41e4ca1545a710010"/><file name="index.phtml" hash="27b13b140de5e8797ee955b1aeb670d6"/></dir><file name="form.phtml" hash="ec1b6c13c4e8752cabeb0ac784886da0"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cardpay_Payeezy.xml" hash="7805ddefa49d4a140fc03668cde2c3c2"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Cardpay_Payeezy.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>
|
