Version Notes
Store Customer information on Authorize.net Secure Servers. The method is PCI compliant.
Download this release
Release Info
Developer | Silvertouch |
Extension | Sttl_Authorize |
Version | 1.0.1 |
Comparing to | |
See all releases |
Version 1.0.1
- SILVER_AuthorizeCIM-User_Guide-V.1.0.1.doc +0 -0
- app/code/local/Sttl/Authorizecim/Block/Form/Cim.php +176 -0
- app/code/local/Sttl/Authorizecim/Block/Info/Cim.php +49 -0
- app/code/local/Sttl/Authorizecim/Helper/Data.php +24 -0
- app/code/local/Sttl/Authorizecim/Model/Api.php +908 -0
- app/code/local/Sttl/Authorizecim/Model/Mysql4/Transaction.php +28 -0
- app/code/local/Sttl/Authorizecim/Model/Mysql4/Transaction/Collection.php +29 -0
- app/code/local/Sttl/Authorizecim/Model/Payment.php +683 -0
- app/code/local/Sttl/Authorizecim/Model/System/Config/Backend/Encrypted.php +58 -0
- app/code/local/Sttl/Authorizecim/Model/System/Config/Source/Cctype.php +24 -0
- app/code/local/Sttl/Authorizecim/Model/System/Config/Source/Method.php +47 -0
- app/code/local/Sttl/Authorizecim/Model/System/Config/Source/PaymentAction.php +33 -0
- app/code/local/Sttl/Authorizecim/Model/System/Config/Source/Yesno.php +33 -0
- app/code/local/Sttl/Authorizecim/Model/Transaction.php +29 -0
- app/code/local/Sttl/Authorizecim/etc/config.xml +119 -0
- app/code/local/Sttl/Authorizecim/etc/system.xml +193 -0
- app/code/local/Sttl/Authorizecim/sql/authorizecim_setup/mysql4-install-1.0.0.php +37 -0
- app/code/local/Sttl/Authorizecim/sql/authorizecim_setup/mysql4-upgrade-1.0.0-1.0.1.php +24 -0
- app/design/adminhtml/default/default/template/authorizecim/form/cim.phtml +117 -0
- app/design/adminhtml/default/default/template/authorizecim/form/cim_1.phtml +163 -0
- app/design/frontend/base/default/template/authorizecim/form/cim.phtml +169 -0
- app/etc/modules/Sttl_Authorizecim.xml +28 -0
- package.xml +24 -0
SILVER_AuthorizeCIM-User_Guide-V.1.0.1.doc
ADDED
Binary file
|
app/code/local/Sttl/Authorizecim/Block/Form/Cim.php
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Silver Touch Technologies Limited.
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
12 |
+
*
|
13 |
+
* @category Sttl
|
14 |
+
* @package Sttl_Authorizecim
|
15 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
16 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
17 |
+
*/
|
18 |
+
class Sttl_Authorizecim_Block_Form_Cim extends Mage_Payment_Block_Form {
|
19 |
+
|
20 |
+
protected function _construct() {
|
21 |
+
parent::_construct();
|
22 |
+
$this->setTemplate('authorizecim/form/cim.phtml');
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Retrieve payment configuration object
|
27 |
+
*
|
28 |
+
* @return Mage_Payment_Model_Config
|
29 |
+
*/
|
30 |
+
protected function _getConfig() {
|
31 |
+
return Mage::getSingleton('payment/config');
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Retrieve availables credit card types
|
36 |
+
*
|
37 |
+
* @return array
|
38 |
+
*/
|
39 |
+
public function getCcAvailableTypes() {
|
40 |
+
$types = $this->_getConfig()->getCcTypes();
|
41 |
+
if ($method = $this->getMethod()) {
|
42 |
+
$availableTypes = $method->getConfigData('cctypes');
|
43 |
+
if ($availableTypes) {
|
44 |
+
$availableTypes = explode(',', $availableTypes);
|
45 |
+
foreach ($types as $code => $name) {
|
46 |
+
if (!in_array($code, $availableTypes)) {
|
47 |
+
unset($types[$code]);
|
48 |
+
}
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
return $types;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Retrieve credit card expire months
|
57 |
+
*
|
58 |
+
* @return array
|
59 |
+
*/
|
60 |
+
public function getCcMonths() {
|
61 |
+
$months = $this->getData('cc_months');
|
62 |
+
if (is_null($months)) {
|
63 |
+
$months[0] = $this->__('Month');
|
64 |
+
$months = array_merge($months, $this->_getConfig()->getMonths());
|
65 |
+
$this->setData('cc_months', $months);
|
66 |
+
}
|
67 |
+
return $months;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Retrieve credit card expire years
|
72 |
+
*
|
73 |
+
* @return array
|
74 |
+
*/
|
75 |
+
public function getCcYears() {
|
76 |
+
$years = $this->getData('cc_years');
|
77 |
+
if (is_null($years)) {
|
78 |
+
$years = $this->_getConfig()->getYears();
|
79 |
+
$years = array(0 => $this->__('Year')) + $years;
|
80 |
+
$this->setData('cc_years', $years);
|
81 |
+
}
|
82 |
+
return $years;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Retrive has verification configuration
|
87 |
+
*
|
88 |
+
* @return boolean
|
89 |
+
*/
|
90 |
+
public function hasVerification() {
|
91 |
+
if ($this->getMethod()) {
|
92 |
+
$configData = $this->getMethod()->getConfigData('useccv');
|
93 |
+
if (is_null($configData)) {
|
94 |
+
return false;
|
95 |
+
}
|
96 |
+
return (bool) $configData;
|
97 |
+
}
|
98 |
+
return true;
|
99 |
+
}
|
100 |
+
|
101 |
+
/*
|
102 |
+
* Whether switch/solo card type available
|
103 |
+
*/
|
104 |
+
|
105 |
+
public function hasSsCardType() {
|
106 |
+
$availableTypes = explode(',', $this->getMethod()->getConfigData('cctypes'));
|
107 |
+
$ssPresenations = array_intersect(array('SS', 'SM', 'SO'), $availableTypes);
|
108 |
+
if ($availableTypes && count($ssPresenations) > 0) {
|
109 |
+
return true;
|
110 |
+
}
|
111 |
+
return false;
|
112 |
+
}
|
113 |
+
|
114 |
+
/*
|
115 |
+
* solo/switch card start year
|
116 |
+
* @return array
|
117 |
+
*/
|
118 |
+
|
119 |
+
public function getSsStartYears() {
|
120 |
+
$years = array();
|
121 |
+
$first = date("Y");
|
122 |
+
|
123 |
+
for ($index = 5; $index >= 0; $index--) {
|
124 |
+
$year = $first - $index;
|
125 |
+
$years[$year] = $year;
|
126 |
+
}
|
127 |
+
$years = array(0 => $this->__('Year')) + $years;
|
128 |
+
return $years;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Render block HTML
|
133 |
+
*
|
134 |
+
* @return string
|
135 |
+
*/
|
136 |
+
protected function _toHtml() {
|
137 |
+
Mage::dispatchEvent('payment_form_block_to_html_before', array(
|
138 |
+
'block' => $this
|
139 |
+
));
|
140 |
+
return parent::_toHtml();
|
141 |
+
}
|
142 |
+
|
143 |
+
public function getOldCreditCard() {
|
144 |
+
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
|
145 |
+
$paymentArray = array();
|
146 |
+
$customerEmail = Mage::getSingleton('checkout/session')->getQuote()->getCustomerEmail();
|
147 |
+
$collection = Mage::getModel('authorizecim/transaction')->getCollection()
|
148 |
+
->addFieldToFilter('email', $customerEmail)
|
149 |
+
->getFirstItem();
|
150 |
+
$card = Mage::getModel('authorizecim/api')->getPaymentCreditCard($collection->getProfileId());
|
151 |
+
if ($card && count($card)) {
|
152 |
+
$key = 0;
|
153 |
+
foreach ($card as $profile) {
|
154 |
+
$paymentProfileId = $profile->customerPaymentProfileId;
|
155 |
+
$cardNumber = $profile->payment->creditCard->cardNumber;
|
156 |
+
$expirationDate = $profile->payment->creditCard->expirationDate;
|
157 |
+
|
158 |
+
foreach ($paymentProfileId as $payment) {
|
159 |
+
$value = (string) $payment;
|
160 |
+
}
|
161 |
+
|
162 |
+
foreach ($cardNumber as $payment) {
|
163 |
+
$cardNo = (string) $payment;
|
164 |
+
}
|
165 |
+
$paymentArray[$key] = array('value' => (string) $value, 'label' => (string) $cardNo);
|
166 |
+
$key++;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
return $paymentArray;
|
171 |
+
} else {
|
172 |
+
return false;
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
}
|
app/code/local/Sttl/Authorizecim/Block/Info/Cim.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Silver Touch Technologies Limited.
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
12 |
+
*
|
13 |
+
* @category Sttl
|
14 |
+
* @package Sttl_Authorizecim
|
15 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
16 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
17 |
+
*/
|
18 |
+
class Sttl_Authorizecim_Block_Info_Cim extends Mage_Payment_Block_Info_Cc {
|
19 |
+
|
20 |
+
protected function _prepareSpecificInformation($transport = null) {
|
21 |
+
|
22 |
+
if (null !== $this->_paymentSpecificInformation) {
|
23 |
+
return $this->_paymentSpecificInformation;
|
24 |
+
}
|
25 |
+
$info = $this->getInfo();
|
26 |
+
if ($info->getData('last_trans_id')):
|
27 |
+
$orderId = $this->getInfo()->getOrder()->getId();
|
28 |
+
$CimCollection = Mage::getModel('authorizecim/transaction')->getCollection()
|
29 |
+
->addFieldToFilter('order_id', $orderId);
|
30 |
+
if($CimCollection->count()){
|
31 |
+
$cim = $CimCollection->getFirstItem();
|
32 |
+
$cardType = $cim->getCardType();
|
33 |
+
$cardno = $cim->getCclast4();
|
34 |
+
}else{
|
35 |
+
$card = Mage::getModel('authorizecim/api')->getPaymentDetail($info->getData('last_trans_id'));
|
36 |
+
$cardType = $card->cardType;
|
37 |
+
$cardno = $card->cardNumber;
|
38 |
+
}
|
39 |
+
$transport = new Varien_Object();
|
40 |
+
$transport->addData(array(
|
41 |
+
Mage::helper('payment')->__('Credit Card Type') => $cardType,
|
42 |
+
Mage::helper('payment')->__('Credit Card Number') => $cardno,
|
43 |
+
));
|
44 |
+
endif;
|
45 |
+
$transport = parent::_prepareSpecificInformation($transport);
|
46 |
+
return $transport;
|
47 |
+
}
|
48 |
+
|
49 |
+
}
|
app/code/local/Sttl/Authorizecim/Helper/Data.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Silver Touch Technologies Limited.
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
12 |
+
*
|
13 |
+
* @category Sttl
|
14 |
+
* @package Sttl_Authorizecim
|
15 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
16 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
17 |
+
*/
|
18 |
+
class Sttl_Authorizecim_Helper_Data extends Mage_Core_Helper_Data {
|
19 |
+
|
20 |
+
public function displayOldCard() {
|
21 |
+
return Mage::getStoreConfigFlag('payment/authorizecim/display_cc');
|
22 |
+
}
|
23 |
+
|
24 |
+
}
|
app/code/local/Sttl/Authorizecim/Model/Api.php
ADDED
@@ -0,0 +1,908 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Silver Touch Technologies Limited.
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
12 |
+
*
|
13 |
+
* @category Sttl
|
14 |
+
* @package Sttl_Authorizecim
|
15 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
16 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
17 |
+
*/
|
18 |
+
class Sttl_Authorizecim_Model_Api extends Mage_Payment_Model_Method_Abstract {
|
19 |
+
|
20 |
+
/** CIM gateway url live */
|
21 |
+
const CGI_URL = 'https://api.authorize.net/xml/v1/request.api';
|
22 |
+
|
23 |
+
/** CIM gateway url test */
|
24 |
+
const CGI_URL_TEST = 'https://apitest.authorize.net/xml/v1/request.api';
|
25 |
+
const XML_PATH_GENERATION_LOGIN = 'payment/authorizecim/login';
|
26 |
+
const XML_PATH_GENERATION_TRANSACTION = 'payment/authorizecim/trans_key';
|
27 |
+
|
28 |
+
protected $_code = 'authorizecim';
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Fields that should be replaced in debug with '***'
|
32 |
+
*
|
33 |
+
* @var array
|
34 |
+
*/
|
35 |
+
protected $_debugReplacePrivateDataKeys = array('name', 'transactionKey', 'cardNumber', 'expirationDate', '');
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Authorize
|
39 |
+
*
|
40 |
+
* @param Varien_Object $orderPayment
|
41 |
+
* @return Mage_GoogleCheckout_Model_Payment
|
42 |
+
*/
|
43 |
+
public function getPaymentCreditCard($profileId) {
|
44 |
+
$customerProfile = $this->getCustomerProfile($profileId);
|
45 |
+
return $customerProfile;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getPaymentDetail($transactionId) {
|
49 |
+
$customertransactionDetail = $this->getCustomerTransactionDetail($transactionId);
|
50 |
+
return $customertransactionDetail;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Authorize.NET
|
55 |
+
*
|
56 |
+
* @return merchant Authentiocation xml request
|
57 |
+
*/
|
58 |
+
protected function merchantAuthenticationBlock() {
|
59 |
+
return "<merchantAuthentication>" .
|
60 |
+
"<name>" . Mage::getStoreConfig(self::XML_PATH_GENERATION_LOGIN) . "</name>" .
|
61 |
+
"<transactionKey>" . Mage::getStoreConfig(self::XML_PATH_GENERATION_TRANSACTION) . "</transactionKey>" .
|
62 |
+
"</merchantAuthentication>";
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Authorize.NET
|
67 |
+
*
|
68 |
+
* @param Varien_Object $orderPayment
|
69 |
+
* @param customerProfileId of Authorize.net
|
70 |
+
* @return Payment Profile Id from Authorize.net
|
71 |
+
*/
|
72 |
+
protected function checkPaymentProfile($customerProfileId, Varien_Object $payment) {
|
73 |
+
$ccId = substr($payment->getCcNumber(), -4);
|
74 |
+
$cardExists = array();
|
75 |
+
|
76 |
+
$content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
77 |
+
"<getCustomerProfileRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
78 |
+
$this->merchantAuthenticationBlock() .
|
79 |
+
"<customerProfileId>" . $customerProfileId . "</customerProfileId>" .
|
80 |
+
"</getCustomerProfileRequest>";
|
81 |
+
|
82 |
+
$customerresponse = $this->sendRequestViaCurl($content);
|
83 |
+
$parsedresponse = simplexml_load_string($customerresponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
84 |
+
if ($parsedresponse) {
|
85 |
+
if (Sttl_Authorizecim_Model_Payment::RESPONSE_RESULT_CODE != $parsedresponse->messages->resultCode) {
|
86 |
+
$message = Mage::helper('paygate')->__("The operation failed with the following errors: ");
|
87 |
+
foreach ($parsedresponse->messages->message as $msg) {
|
88 |
+
$message .= Mage::helper('paygate')->__("[" . htmlspecialchars($msg->code) . "] " . htmlspecialchars($msg->text));
|
89 |
+
}
|
90 |
+
if(!count($parsedresponse->messages->message)){
|
91 |
+
$message = strip_tags($customerresponse);
|
92 |
+
}
|
93 |
+
Mage::throwException($message);
|
94 |
+
} else {
|
95 |
+
$paymentProfiles = $parsedresponse->profile->paymentProfiles;
|
96 |
+
if (count($paymentProfiles)) {
|
97 |
+
foreach ($paymentProfiles as $profile) {
|
98 |
+
$paymentProfileId = $profile->customerPaymentProfileId;
|
99 |
+
$cardNumber = substr($profile->payment->creditCard->cardNumber, -4);
|
100 |
+
|
101 |
+
if ($ccId != $cardNumber) {
|
102 |
+
$cardExists[] = 'false';
|
103 |
+
} else {
|
104 |
+
$cardExists[] = 'true';
|
105 |
+
break;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
if (in_array('true', $cardExists)) {
|
110 |
+
return $paymentProfileId;
|
111 |
+
} else {
|
112 |
+
return '';
|
113 |
+
}
|
114 |
+
$cimCollection = Mage::getModel('authorizecim/transaction')->getCollection()
|
115 |
+
->addFieldToFilter('payment_id', $paymentProfileId);
|
116 |
+
|
117 |
+
if ($cimCollection->count()) {
|
118 |
+
$cimCollection = $cimCollection->getFirstItem();
|
119 |
+
return $customerPaymentProfileId = $cimCollection->getPaymentId();
|
120 |
+
} else {
|
121 |
+
return '';
|
122 |
+
}
|
123 |
+
}
|
124 |
+
} else {
|
125 |
+
if($customerresponse){
|
126 |
+
$message = strip_tags($customerresponse);
|
127 |
+
}else{
|
128 |
+
$message = Mage::helper('paygate')->__("There has been some error occured while getting payment response.");
|
129 |
+
}
|
130 |
+
Mage::throwException($message);
|
131 |
+
}
|
132 |
+
|
133 |
+
//return $content;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Send request to gateway for fetching customer profile details
|
138 |
+
*
|
139 |
+
* @param customerProfileId of Authorize.net
|
140 |
+
* @return Payment Profile from Authorize.net
|
141 |
+
*/
|
142 |
+
protected function getCustomerProfile($customerProfileId) {
|
143 |
+
$content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
144 |
+
"<getCustomerProfileRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
145 |
+
$this->merchantAuthenticationBlock() .
|
146 |
+
"<customerProfileId>" . $customerProfileId . "</customerProfileId>" .
|
147 |
+
"</getCustomerProfileRequest>";
|
148 |
+
|
149 |
+
$customerresponse = $this->sendRequestViaCurl($content);
|
150 |
+
if ($customerresponse) {
|
151 |
+
$parsedresponse = simplexml_load_string($customerresponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
152 |
+
if (Sttl_Authorizecim_Model_Payment::RESPONSE_RESULT_CODE != $parsedresponse->messages->resultCode) {
|
153 |
+
return false;
|
154 |
+
} else {
|
155 |
+
$paymentProfiles = $parsedresponse->profile->paymentProfiles;
|
156 |
+
if (count($paymentProfiles)) {
|
157 |
+
return $paymentProfiles;
|
158 |
+
}
|
159 |
+
}
|
160 |
+
} else {
|
161 |
+
return false;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
protected function getCustomerTransactionDetail($customertransactionId) {
|
166 |
+
$content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
167 |
+
"<getTransactionDetailsRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
168 |
+
$this->merchantAuthenticationBlock() .
|
169 |
+
"<transId>" . $customertransactionId . "</transId>" .
|
170 |
+
"</getTransactionDetailsRequest>";
|
171 |
+
$customerresponse = $this->sendRequestViaCurl($content);
|
172 |
+
$parsedresponse = simplexml_load_string($customerresponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
173 |
+
if (Sttl_Authorizecim_Model_Payment::RESPONSE_RESULT_CODE != $parsedresponse->messages->resultCode) {
|
174 |
+
return false;
|
175 |
+
} else {
|
176 |
+
$parsedresponse = $parsedresponse->transaction->payment->creditCard;
|
177 |
+
if (count($parsedresponse)) {
|
178 |
+
return $parsedresponse;
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Check Shippping profile at Authorize.net
|
185 |
+
*
|
186 |
+
* @param customerProfileId of Authorize.net
|
187 |
+
* @return Shipping Id from Authorize.net
|
188 |
+
*/
|
189 |
+
protected function checkShippingProfile($customerProfileId) {
|
190 |
+
$content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
191 |
+
"<getCustomerProfileRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
192 |
+
$this->merchantAuthenticationBlock() .
|
193 |
+
"<customerProfileId>" . $customerProfileId . "</customerProfileId>" .
|
194 |
+
"</getCustomerProfileRequest>";
|
195 |
+
$customerresponse = $this->sendRequestViaCurl($content);
|
196 |
+
$parsedresponse = simplexml_load_string($customerresponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
197 |
+
if (Sttl_Authorizecim_Model_Payment::RESPONSE_RESULT_CODE != $parsedresponse->messages->resultCode) {
|
198 |
+
$message = Mage::helper('paygate')->__('The operation failed with the following errors: ');
|
199 |
+
foreach ($parsedresponse->messages->message as $msg) {
|
200 |
+
$message .= Mage::helper('paygate')->__("[" . htmlspecialchars($msg->code) . "] " . htmlspecialchars($msg->text));
|
201 |
+
}
|
202 |
+
if(!count($parsedresponse->messages->message)){
|
203 |
+
$message = strip_tags($customerresponse);
|
204 |
+
}
|
205 |
+
Mage::throwException($message);
|
206 |
+
} else {
|
207 |
+
$shippingProfileId = $parsedresponse->profile->shipToList->customerAddressId;
|
208 |
+
$cimCollection = Mage::getModel('authorizecim/transaction')->getCollection()
|
209 |
+
->addFieldToFilter('shipping_id', $shippingProfileId);
|
210 |
+
|
211 |
+
if ($cimCollection->count()) {
|
212 |
+
$cimCollection = $cimCollection->getFirstItem();
|
213 |
+
return $customerPaymentProfileId = $cimCollection->getShippingId();
|
214 |
+
} else {
|
215 |
+
return '';
|
216 |
+
}
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Create Customer Profile Authorize.net Request
|
222 |
+
*
|
223 |
+
* @param customerProfileId of Authorize.net
|
224 |
+
*/
|
225 |
+
protected function _buildCustomerRequest(Varien_Object $payment) {
|
226 |
+
$order = $payment->getOrder();
|
227 |
+
|
228 |
+
$content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
229 |
+
"<createCustomerProfileRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
230 |
+
$this->merchantAuthenticationBlock() .
|
231 |
+
"<profile>";
|
232 |
+
|
233 |
+
if (!empty($order)) {
|
234 |
+
$billing = $order->getBillingAddress();
|
235 |
+
$cust_email = $billing->getEmail();
|
236 |
+
if (!empty($cust_email)) {
|
237 |
+
$customer_email = $cust_email;
|
238 |
+
} else {
|
239 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
240 |
+
$billingAddress = $quote->getBillingAddress();
|
241 |
+
$customer_email = $billingAddress->getEmail();
|
242 |
+
}
|
243 |
+
|
244 |
+
$content .="<description></description>" .
|
245 |
+
"<email>" . $customer_email . "</email>";
|
246 |
+
}
|
247 |
+
|
248 |
+
$content .="</profile>" .
|
249 |
+
"</createCustomerProfileRequest>";
|
250 |
+
|
251 |
+
return $content;
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Delete Customer Profile Authorize.net Request
|
256 |
+
*
|
257 |
+
* @param customerProfileId of Authorize.net
|
258 |
+
*/
|
259 |
+
protected function _deleteCustomerProfile($customerProfileId, $isNew) {
|
260 |
+
if ($isNew) {
|
261 |
+
$request = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
262 |
+
"<deleteCustomerProfileRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
263 |
+
$this->merchantAuthenticationBlock() .
|
264 |
+
"<customerProfileId>" . $customerProfileId . "</customerProfileId>" .
|
265 |
+
"</deleteCustomerProfileRequest>";
|
266 |
+
$this->sendRequestViaCurl($request);
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Send request via Fsockopen
|
272 |
+
*/
|
273 |
+
protected function sendRequestViaFsockopen($host, $path, $content) {
|
274 |
+
$posturl = "ssl://" . $host;
|
275 |
+
$header = "Host: $host\r\n";
|
276 |
+
$header .= "User-Agent: PHP Script\r\n";
|
277 |
+
$header .= "Content-Type: text/xml\r\n";
|
278 |
+
$header .= "Content-Length: " . strlen($content) . "\r\n";
|
279 |
+
$header .= "Connection: close\r\n\r\n";
|
280 |
+
$fp = fsockopen($posturl, 443, $errno, $errstr, 30);
|
281 |
+
if (!$fp) {
|
282 |
+
$body = false;
|
283 |
+
} else {
|
284 |
+
error_reporting(E_ERROR);
|
285 |
+
fputs($fp, "POST $path HTTP/1.1\r\n");
|
286 |
+
fputs($fp, $header . $content);
|
287 |
+
fwrite($fp, $out);
|
288 |
+
$response = "";
|
289 |
+
while (!feof($fp)) {
|
290 |
+
$response = $response . fgets($fp, 128);
|
291 |
+
}
|
292 |
+
fclose($fp);
|
293 |
+
error_reporting(E_ALL ^ E_NOTICE);
|
294 |
+
|
295 |
+
$len = strlen($response);
|
296 |
+
$bodypos = strpos($response, "\r\n\r\n");
|
297 |
+
if ($bodypos <= 0) {
|
298 |
+
$bodypos = strpos($response, "\n\n");
|
299 |
+
}
|
300 |
+
while ($bodypos < $len && $response [$bodypos] != '<') {
|
301 |
+
$bodypos++;
|
302 |
+
}
|
303 |
+
$body = substr($response, $bodypos);
|
304 |
+
}
|
305 |
+
return $body;
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Send request via Curl
|
310 |
+
*/
|
311 |
+
protected function sendRequestViaCurl($content) {
|
312 |
+
$this->_debug(array('request' => $content));
|
313 |
+
$err = false;
|
314 |
+
$posturl = $this->getConfigData('cgi_url');
|
315 |
+
$posturl = $posturl ? $posturl : self::CGI_URL;
|
316 |
+
$ch = curl_init();
|
317 |
+
curl_setopt($ch, CURLOPT_URL, $posturl);
|
318 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
319 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
|
320 |
+
curl_setopt($ch, CURLOPT_HEADER, 1);
|
321 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
|
322 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
323 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
324 |
+
//curl_setopt($ch, CURLOPT_PROXY, "192.168.0.6:3128");
|
325 |
+
$response = curl_exec($ch);
|
326 |
+
if ($response === false) {
|
327 |
+
$err = curl_error($ch);
|
328 |
+
}
|
329 |
+
curl_close($ch);
|
330 |
+
if ($err) {
|
331 |
+
Mage::log(Mage::helper('paygate')->__($err));
|
332 |
+
return;
|
333 |
+
}
|
334 |
+
$len = strlen($response);
|
335 |
+
$bodypos = strpos($response, "\r\n\r\n");
|
336 |
+
if ($bodypos <= 0) {
|
337 |
+
$bodypos = strpos($response, "\n\n");
|
338 |
+
}
|
339 |
+
while ($bodypos < $len && $response[$bodypos] != '<') {
|
340 |
+
$bodypos++;
|
341 |
+
}
|
342 |
+
$body = substr($response, $bodypos);
|
343 |
+
$this->_debug(array('response' => $body));
|
344 |
+
return $body;
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Prepare request to gateway for creating customer payment profile
|
349 |
+
*
|
350 |
+
* @link http://www.authorize.net/support/AIM_guide.pdf
|
351 |
+
* @param Varien_Object $orderPayment
|
352 |
+
* @return unknown
|
353 |
+
*/
|
354 |
+
protected function _buildPaymentRequest(Varien_Object $payment, $customerProfileId) {
|
355 |
+
$order = $payment->getOrder();
|
356 |
+
|
357 |
+
$content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
358 |
+
"<createCustomerPaymentProfileRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
359 |
+
$this->merchantAuthenticationBlock() .
|
360 |
+
"<customerProfileId>" . $customerProfileId . "</customerProfileId>" .
|
361 |
+
"<paymentProfile>";
|
362 |
+
|
363 |
+
if (!empty($order)) {
|
364 |
+
$billing = $order->getBillingAddress();
|
365 |
+
$cust_email = $billing->getEmail();
|
366 |
+
if (!empty($cust_email)) {
|
367 |
+
$customer_email = $cust_email;
|
368 |
+
$first_name = $billing->getFirstname();
|
369 |
+
$last_name = $billing->getLastname();
|
370 |
+
$telephone = $billing->getTelephone();
|
371 |
+
} else {
|
372 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
373 |
+
$billingAddress = $quote->getBillingAddress();
|
374 |
+
$customer_email = $billingAddress->getEmail();
|
375 |
+
$first_name = $billingAddress->getFirstname();
|
376 |
+
$last_name = $billingAddress->getLastname();
|
377 |
+
$telephone = $billingAddress->getTelephone();
|
378 |
+
}
|
379 |
+
$content .="<billTo>" .
|
380 |
+
"<firstName>" . $first_name . "</firstName>" .
|
381 |
+
"<lastName>" . $last_name . "</lastName>" .
|
382 |
+
"<phoneNumber>" . $telephone . "</phoneNumber>" .
|
383 |
+
"</billTo>";
|
384 |
+
}
|
385 |
+
$content .="<payment>" .
|
386 |
+
"<creditCard>" .
|
387 |
+
"<cardNumber>" . $payment->getCcNumber() . "</cardNumber>" .
|
388 |
+
"<expirationDate>" . sprintf('%04d-%02d', $payment->getCcExpYear(), $payment->getCcExpMonth()) . "</expirationDate>" . // required format for API is YYYY-MM
|
389 |
+
"</creditCard>" .
|
390 |
+
"</payment>" .
|
391 |
+
"</paymentProfile>" .
|
392 |
+
//"<validationMode>testMode</validationMode>". // liveMode or testMode
|
393 |
+
"</createCustomerPaymentProfileRequest>";
|
394 |
+
return $content;
|
395 |
+
}
|
396 |
+
|
397 |
+
/**
|
398 |
+
* Prepare request to gateway for creating customer shipping address request
|
399 |
+
*
|
400 |
+
* @link http://www.authorize.net/support/AIM_guide.pdf
|
401 |
+
* @param Varien_Object $orderPayment
|
402 |
+
* @return unknown
|
403 |
+
*/
|
404 |
+
protected function _buildShippingRequest(Varien_Object $payment, $customerProfileId) {
|
405 |
+
$order = $payment->getOrder();
|
406 |
+
|
407 |
+
$content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
408 |
+
"<createCustomerShippingAddressRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
409 |
+
$this->merchantAuthenticationBlock() .
|
410 |
+
"<customerProfileId>" . $customerProfileId . "</customerProfileId>" .
|
411 |
+
"<address>";
|
412 |
+
if (!empty($order)) {
|
413 |
+
$shipping = $order->getShippingAddress();
|
414 |
+
$billing = $order->getBillingAddress();
|
415 |
+
/* added fix for virtual products */
|
416 |
+
if(!$shipping){
|
417 |
+
$shipping = $billing;
|
418 |
+
}
|
419 |
+
/* added fix for virtual products */
|
420 |
+
$content .="<firstName>" . $shipping->getFirstname() . "</firstName>" .
|
421 |
+
"<lastName>" . $shipping->getLastname() . "</lastName>" .
|
422 |
+
"<company>" . $shipping->getCompany() . "</company>" .
|
423 |
+
"<address>" . $shipping->getStreet(1) . "</address>" .
|
424 |
+
"<city>" . $shipping->getCity() . "</city>" .
|
425 |
+
"<state>" . $shipping->getRegion() . "</state>" .
|
426 |
+
"<zip>" . $shipping->getPostcode() . "</zip>" .
|
427 |
+
"<country>" . $shipping->getCountry() . "</country>" .
|
428 |
+
"<phoneNumber>" . $billing->getTelephone() . "</phoneNumber>" .
|
429 |
+
"<faxNumber>" . $billing->getFax() . "</faxNumber>";
|
430 |
+
}
|
431 |
+
|
432 |
+
$content .="</address>" .
|
433 |
+
"</createCustomerShippingAddressRequest>";
|
434 |
+
return $content;
|
435 |
+
}
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Prepare request to gateway for creating customer profile transaction
|
439 |
+
*
|
440 |
+
* @link http://www.authorize.net/support/AIM_guide.pdf
|
441 |
+
* @param Varien_Object $orderPayment
|
442 |
+
* @return unknown
|
443 |
+
*/
|
444 |
+
protected function _buildTransactionRequest(Varien_Object $payment, $customerProfileId, $paymentProfileId, $ShippingAddressId) {
|
445 |
+
$order = $payment->getOrder();
|
446 |
+
|
447 |
+
$content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
448 |
+
"<createCustomerProfileTransactionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
449 |
+
$this->merchantAuthenticationBlock() .
|
450 |
+
"<transaction>" .
|
451 |
+
"<profileTransAuthOnly>" .
|
452 |
+
"<amount>" . $payment->getAmount() . "</amount>" // should include tax, shipping, and everything.
|
453 |
+
;
|
454 |
+
|
455 |
+
if ($order->getTaxAmount()) {
|
456 |
+
$content .="<tax>" .
|
457 |
+
"<amount>" . $order->getTaxAmount() . "</amount>" .
|
458 |
+
"<name>Tax</name>" .
|
459 |
+
"<description>Tax</description>" .
|
460 |
+
"</tax>";
|
461 |
+
}
|
462 |
+
|
463 |
+
$shipping_method = $order->getShippingMethod();
|
464 |
+
if (empty($shipping_method)) {
|
465 |
+
$shipping_method = $order->getShippingDescription();
|
466 |
+
}
|
467 |
+
|
468 |
+
$content.="<shipping>" .
|
469 |
+
"<amount>" . $order->getShippingAmount() . "</amount>" .
|
470 |
+
"<name>" . $shipping_method . "</name>" .
|
471 |
+
"<description>" . $order->getShippingDescription() . "</description>" .
|
472 |
+
"</shipping>";
|
473 |
+
if (!empty($order)) {
|
474 |
+
|
475 |
+
$items = $order->getAllItems();
|
476 |
+
|
477 |
+
foreach ($items as $_item) {
|
478 |
+
|
479 |
+
$content .="<lineItems>" .
|
480 |
+
"<itemId>" . $_item->getId() . "</itemId>" .
|
481 |
+
"<name><![CDATA[" . substr($_item->getName(), 0, 30) . "]]></name>" .
|
482 |
+
"<description>Description of item sold</description>" .
|
483 |
+
"<quantity>" . $_item->getQtyOrdered() . "</quantity>" .
|
484 |
+
"<unitPrice>" . $_item->getPrice() . "</unitPrice>" .
|
485 |
+
"<taxable>false</taxable>" .
|
486 |
+
"</lineItems>";
|
487 |
+
}
|
488 |
+
}
|
489 |
+
$content .="<customerProfileId>" . $customerProfileId . "</customerProfileId>" .
|
490 |
+
"<customerPaymentProfileId>" . $paymentProfileId . "</customerPaymentProfileId>" .
|
491 |
+
"<customerShippingAddressId>" . $ShippingAddressId . "</customerShippingAddressId>";
|
492 |
+
|
493 |
+
if ($order && $order->getIncrementId()) {
|
494 |
+
$content .="<order>" .
|
495 |
+
"<invoiceNumber>" . $order->getIncrementId() . "</invoiceNumber>" .
|
496 |
+
"</order>";
|
497 |
+
}
|
498 |
+
|
499 |
+
$content .="</profileTransAuthOnly>" .
|
500 |
+
"</transaction>" .
|
501 |
+
"</createCustomerProfileTransactionRequest>";
|
502 |
+
return $content;
|
503 |
+
}
|
504 |
+
|
505 |
+
/**
|
506 |
+
* Prepare request to gateway for creating customer profile transaction
|
507 |
+
*
|
508 |
+
* @link http://www.authorize.net/support/AIM_guide.pdf
|
509 |
+
* @param Varien_Object $orderPayment
|
510 |
+
* @return unknown
|
511 |
+
*/
|
512 |
+
protected function _buildTransactionCaptureRequest(Varien_Object $payment, $customerProfileId, $paymentProfileId, $ShippingAddressId) {
|
513 |
+
$order = $payment->getOrder();
|
514 |
+
$content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
515 |
+
"<createCustomerProfileTransactionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
516 |
+
$this->merchantAuthenticationBlock() .
|
517 |
+
"<transaction>" .
|
518 |
+
"<profileTransAuthCapture>" .
|
519 |
+
"<amount>" . $payment->getAmount() . "</amount>"; // should include tax, shipping, and everything.
|
520 |
+
|
521 |
+
|
522 |
+
if ($order->getTaxAmount()) {
|
523 |
+
$content .="<tax>" .
|
524 |
+
"<amount>" . $order->getTaxAmount() . "</amount>" .
|
525 |
+
"<name>Tax</name>" .
|
526 |
+
"<description>Tax</description>" .
|
527 |
+
"</tax>";
|
528 |
+
}
|
529 |
+
|
530 |
+
$shipping_method = $order->getShippingMethod();
|
531 |
+
if (empty($shipping_method)) {
|
532 |
+
$shipping_method = $order->getShippingDescription();
|
533 |
+
}
|
534 |
+
|
535 |
+
$content.="<shipping>" .
|
536 |
+
"<amount>" . $order->getShippingAmount() . "</amount>" .
|
537 |
+
"<name>" . $shipping_method . "</name>" .
|
538 |
+
"<description>" . $order->getShippingDescription() . "</description>" .
|
539 |
+
"</shipping>";
|
540 |
+
|
541 |
+
if (!empty($order)) {
|
542 |
+
|
543 |
+
$items = $order->getAllItems();
|
544 |
+
|
545 |
+
foreach ($items as $_item) {
|
546 |
+
|
547 |
+
$content .="<lineItems>" .
|
548 |
+
"<itemId>" . $_item->getId() . "</itemId>" .
|
549 |
+
"<name><![CDATA[" . substr($_item->getName(), 0, 30) . "]]></name>" .
|
550 |
+
"<description>Description of item sold</description>" .
|
551 |
+
"<quantity>" . $_item->getQtyOrdered() . "</quantity>" .
|
552 |
+
"<unitPrice>" . $_item->getPrice() . "</unitPrice>" .
|
553 |
+
"<taxable>false</taxable>" .
|
554 |
+
"</lineItems>";
|
555 |
+
}
|
556 |
+
}
|
557 |
+
$content .="<customerProfileId>" . $customerProfileId . "</customerProfileId>" .
|
558 |
+
"<customerPaymentProfileId>" . $paymentProfileId . "</customerPaymentProfileId>" .
|
559 |
+
"<customerShippingAddressId>" . $ShippingAddressId . "</customerShippingAddressId>";
|
560 |
+
|
561 |
+
if ($order && $order->getIncrementId()) {
|
562 |
+
$content .="<order>" .
|
563 |
+
"<invoiceNumber>" . $order->getIncrementId() . "</invoiceNumber>" .
|
564 |
+
"</order>";
|
565 |
+
}
|
566 |
+
|
567 |
+
$content .="</profileTransAuthCapture>" .
|
568 |
+
"</transaction>" .
|
569 |
+
"</createCustomerProfileTransactionRequest>";
|
570 |
+
return $content;
|
571 |
+
}
|
572 |
+
|
573 |
+
/**
|
574 |
+
* Prepare request to gateway for creating customer profile transaction
|
575 |
+
*
|
576 |
+
* @link http://www.authorize.net/support/AIM_guide.pdf
|
577 |
+
* @param Varien_Object $orderPayment
|
578 |
+
* @return unknown
|
579 |
+
*/
|
580 |
+
protected function _buildProAuthCaptureRequest(Varien_Object $payment, $customerProfileId, $paymentProfileId, $ShippingAddressId) {
|
581 |
+
$order = $payment->getOrder();
|
582 |
+
|
583 |
+
$content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
584 |
+
"<createCustomerProfileTransactionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
585 |
+
$this->merchantAuthenticationBlock() .
|
586 |
+
"<transaction>" .
|
587 |
+
"<profileTransPriorAuthCapture>" .
|
588 |
+
"<amount>" . $payment->getAmount() . "</amount>"; // should include tax, shipping, and everything.
|
589 |
+
if ($order->getTaxAmount()) {
|
590 |
+
$content .="<tax>" .
|
591 |
+
"<amount>" . $order->getTaxAmount() . "</amount>" .
|
592 |
+
"<name>Tax</name>" .
|
593 |
+
"<description>Tax</description>" .
|
594 |
+
"</tax>";
|
595 |
+
}
|
596 |
+
|
597 |
+
$shipping_method = $order->getShippingMethod();
|
598 |
+
if (empty($shipping_method)) {
|
599 |
+
$shipping_method = $order->getShippingDescription();
|
600 |
+
}
|
601 |
+
|
602 |
+
$content.=
|
603 |
+
"<shipping>" .
|
604 |
+
"<amount>" . $order->getShippingAmount() . "</amount>" .
|
605 |
+
"<name>" . $shipping_method . "</name>" .
|
606 |
+
"<description>" . $order->getShippingDescription() . "</description>" .
|
607 |
+
"</shipping>";
|
608 |
+
|
609 |
+
if (!empty($order)) {
|
610 |
+
|
611 |
+
$items = $order->getAllItems();
|
612 |
+
|
613 |
+
foreach ($items as $_item) {
|
614 |
+
|
615 |
+
$content .="<lineItems>" .
|
616 |
+
"<itemId>" . $_item->getId() . "</itemId>" .
|
617 |
+
"<name><![CDATA[" . substr($_item->getName(), 0, 30) . "]]></name>" .
|
618 |
+
"<description>Description of item sold</description>" .
|
619 |
+
"<quantity>" . $_item->getQtyOrdered() . "</quantity>" .
|
620 |
+
"<unitPrice>" . $_item->getPrice() . "</unitPrice>" .
|
621 |
+
"<taxable>true</taxable>" .
|
622 |
+
"</lineItems>";
|
623 |
+
}
|
624 |
+
}
|
625 |
+
$content .="<customerProfileId>" . $customerProfileId . "</customerProfileId>" .
|
626 |
+
"<customerPaymentProfileId>" . $paymentProfileId . "</customerPaymentProfileId>" .
|
627 |
+
"<customerShippingAddressId>" . $ShippingAddressId . "</customerShippingAddressId>" .
|
628 |
+
"<transId>" . $payment->getCimTransactionid() . "</transId>";
|
629 |
+
|
630 |
+
$content .="</profileTransPriorAuthCapture>" .
|
631 |
+
"</transaction>" .
|
632 |
+
"</createCustomerProfileTransactionRequest>";
|
633 |
+
|
634 |
+
|
635 |
+
|
636 |
+
return $content;
|
637 |
+
}
|
638 |
+
|
639 |
+
/**
|
640 |
+
* Prepare request to gateway for creating customer profile transaction
|
641 |
+
*
|
642 |
+
* @link http://www.authorize.net/support/AIM_guide.pdf
|
643 |
+
* @param Varien_Object $orderPayment
|
644 |
+
* @return unknown
|
645 |
+
*/
|
646 |
+
protected function _buildCaptureRequest(Varien_Object $payment, $customerProfileId, $paymentProfileId, $ShippingAddressId) {
|
647 |
+
$order = $payment->getOrder();
|
648 |
+
|
649 |
+
$content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
650 |
+
"<createCustomerProfileTransactionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
651 |
+
$this->merchantAuthenticationBlock() .
|
652 |
+
"<transaction>" .
|
653 |
+
"<profileTransCaptureOnly>" .
|
654 |
+
"<amount>" . $payment->getAmount() . "</amount>"; // should include tax, shipping, and everything.
|
655 |
+
|
656 |
+
if ($order->getTaxAmount()) {
|
657 |
+
$content .="<tax>" .
|
658 |
+
"<amount>" . $order->getTaxAmount() . "</amount>" .
|
659 |
+
"<name>Tax</name>" .
|
660 |
+
"<description>Tax</description>" .
|
661 |
+
"</tax>";
|
662 |
+
}
|
663 |
+
|
664 |
+
$shipping_method = $order->getShippingMethod();
|
665 |
+
if (empty($shipping_method)) {
|
666 |
+
$shipping_method = $order->getShippingDescription();
|
667 |
+
}
|
668 |
+
|
669 |
+
$content.=
|
670 |
+
"<shipping>" .
|
671 |
+
"<amount>" . $order->getShippingAmount() . "</amount>" .
|
672 |
+
"<name>" . $shipping_method . "</name>" .
|
673 |
+
"<description>" . $order->getShippingDescription() . "</description>" .
|
674 |
+
"</shipping>";
|
675 |
+
|
676 |
+
if (!empty($order)) {
|
677 |
+
$items = $order->getAllItems();
|
678 |
+
foreach ($items as $_item) {
|
679 |
+
$content .="<lineItems>" .
|
680 |
+
"<itemId>" . $_item->getId() . "</itemId>" .
|
681 |
+
"<name><![CDATA[" . substr($_item->getName(), 0, 30) . "]]></name>" .
|
682 |
+
"<description>Description of item sold</description>" .
|
683 |
+
"<quantity>" . $_item->getQtyOrdered() . "</quantity>" .
|
684 |
+
"<unitPrice>" . $_item->getPrice() . "</unitPrice>" .
|
685 |
+
"<taxable>false</taxable>" .
|
686 |
+
"</lineItems>";
|
687 |
+
}
|
688 |
+
}
|
689 |
+
$content .="<customerProfileId>" . $customerProfileId . "</customerProfileId>" .
|
690 |
+
"<customerPaymentProfileId>" . $paymentProfileId . "</customerPaymentProfileId>" .
|
691 |
+
"<customerShippingAddressId>" . $ShippingAddressId . "</customerShippingAddressId>";
|
692 |
+
|
693 |
+
if ($order && $order->getIncrementId()) {
|
694 |
+
$content .="<order>" .
|
695 |
+
"<invoiceNumber>" . $order->getIncrementId() . "</invoiceNumber>" .
|
696 |
+
"</order>";
|
697 |
+
}
|
698 |
+
|
699 |
+
$content .="<taxExempt>false</taxExempt>" .
|
700 |
+
"<recurringBilling>false</recurringBilling>" .
|
701 |
+
"<cardCode>000</cardCode>" .
|
702 |
+
"<approvalCode>000000</approvalCode>" .
|
703 |
+
"</profileTransCaptureOnly>" .
|
704 |
+
"</transaction>" .
|
705 |
+
"</createCustomerProfileTransactionRequest>";
|
706 |
+
return $content;
|
707 |
+
}
|
708 |
+
|
709 |
+
/**
|
710 |
+
* Prepare request to gateway
|
711 |
+
*
|
712 |
+
* @link http://www.authorize.net/support/CIM_guide.pdf
|
713 |
+
* @param Mage_Sales_Model_Document $order
|
714 |
+
* @return unknown
|
715 |
+
*/
|
716 |
+
protected function _buildVoidRequest(Varien_Object $payment, $customerProfileId, $paymentProfileId, $ShippingAddressId) {
|
717 |
+
$order = $payment->getOrder();
|
718 |
+
$CimCollection = Mage::getModel('authorizecim/transaction')->getCollection()
|
719 |
+
->addFieldToFilter('order_payment_id', $payment->getId())
|
720 |
+
->addFieldToFilter('order_id', $order->getId())
|
721 |
+
->getFirstItem();
|
722 |
+
|
723 |
+
$customerProfileId = $CimCollection->getProfileId();
|
724 |
+
$paymentProfileId = $CimCollection->getPaymentId();
|
725 |
+
$ShippingAddressId = $CimCollection->getShippingId();
|
726 |
+
$cardNumber = $CimCollection->getCclast4();
|
727 |
+
$transId = $CimCollection->getTxnId();
|
728 |
+
|
729 |
+
$content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
730 |
+
"<createCustomerProfileTransactionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
731 |
+
$this->merchantAuthenticationBlock() .
|
732 |
+
"<transaction>" .
|
733 |
+
"<profileTransVoid>";
|
734 |
+
|
735 |
+
$content .="<customerProfileId>" . $customerProfileId . "</customerProfileId>" .
|
736 |
+
"<customerPaymentProfileId>" . $paymentProfileId . "</customerPaymentProfileId>" .
|
737 |
+
"<customerShippingAddressId>" . $ShippingAddressId . "</customerShippingAddressId>";
|
738 |
+
|
739 |
+
$content .="<transId>" . $transId . "</transId>" .
|
740 |
+
"</profileTransVoid>" .
|
741 |
+
"</transaction>" .
|
742 |
+
"</createCustomerProfileTransactionRequest>";
|
743 |
+
|
744 |
+
return array('req' => $content, 'cpid' => $customerProfileId, 'cppid' => $paymentProfileId, 'csid' => $ShippingAddressId, 'cc' => $cardNumber);
|
745 |
+
}
|
746 |
+
|
747 |
+
/**
|
748 |
+
* Prepare request to gateway
|
749 |
+
*
|
750 |
+
* @link http://www.authorize.net/support/CIM_guide.pdf
|
751 |
+
* @param Mage_Sales_Model_Document $order
|
752 |
+
* @return unknown
|
753 |
+
*/
|
754 |
+
protected function _buildRefundRequest(Varien_Object $payment, $amount) {
|
755 |
+
$order = $payment->getOrder();
|
756 |
+
$CimCollection = Mage::getModel('authorizecim/transaction')->getCollection()
|
757 |
+
->addFieldToFilter('order_payment_id', $payment->getId())
|
758 |
+
->addFieldToFilter('order_id', $order->getId());
|
759 |
+
|
760 |
+
if (!$CimCollection->count())
|
761 |
+
return array();
|
762 |
+
$CimCollection = $CimCollection->getFirstItem();
|
763 |
+
|
764 |
+
$customerProfileId = $CimCollection->getProfileId();
|
765 |
+
$paymentProfileId = $CimCollection->getPaymentId();
|
766 |
+
$ShippingAddressId = $CimCollection->getShippingId();
|
767 |
+
$transId = $CimCollection->getTxnId();
|
768 |
+
$card = $this->getPaymentDetail($transId);
|
769 |
+
$cardNumber = $card->cardNumber;
|
770 |
+
|
771 |
+
$content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
772 |
+
"<createCustomerProfileTransactionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
773 |
+
$this->merchantAuthenticationBlock() .
|
774 |
+
"<transaction>" .
|
775 |
+
"<profileTransRefund>";
|
776 |
+
$content .="<amount>" . $amount . "</amount>";
|
777 |
+
if ($order->getTaxAmount()) {
|
778 |
+
$content .="<tax>" .
|
779 |
+
"<amount>" . $order->getTaxAmount() . "</amount>" .
|
780 |
+
"<name>Tax</name>" .
|
781 |
+
"<description>Tax</description>" .
|
782 |
+
"</tax>";
|
783 |
+
}
|
784 |
+
|
785 |
+
$shipping_method = $order->getShippingMethod();
|
786 |
+
if (empty($shipping_method)) {
|
787 |
+
$shipping_method = $order->getShippingDescription();
|
788 |
+
}
|
789 |
+
|
790 |
+
$content.="<shipping>" .
|
791 |
+
"<amount>" . $order->getShippingAmount() . "</amount>" .
|
792 |
+
"<name>" . $shipping_method . "</name>" .
|
793 |
+
"<description>" . $order->getShippingDescription() . "</description>" .
|
794 |
+
"</shipping>";
|
795 |
+
if (!empty($order)) {
|
796 |
+
|
797 |
+
$items = $order->getAllItems();
|
798 |
+
if (count($items)) {
|
799 |
+
foreach ($items as $_item) {
|
800 |
+
$content .="<lineItems>" .
|
801 |
+
"<itemId>" . $_item->getId() . "</itemId>" .
|
802 |
+
"<name><![CDATA[" . substr($_item->getName(), 0, 30) . "]]></name>" .
|
803 |
+
"<description>Description of item sold</description>" .
|
804 |
+
"<quantity>" . $_item->getQtyOrdered() . "</quantity>" .
|
805 |
+
"<unitPrice>" . $_item->getPrice() . "</unitPrice>" .
|
806 |
+
"</lineItems>";
|
807 |
+
}
|
808 |
+
}
|
809 |
+
}
|
810 |
+
|
811 |
+
$content .="<customerProfileId>" . $customerProfileId . "</customerProfileId>" .
|
812 |
+
"<customerPaymentProfileId>" . $paymentProfileId . "</customerPaymentProfileId>" .
|
813 |
+
"<customerShippingAddressId>" . $ShippingAddressId . "</customerShippingAddressId>" .
|
814 |
+
"<creditCardNumberMasked>" . $cardNumber . "</creditCardNumberMasked>";
|
815 |
+
$content .="<order>" .
|
816 |
+
"<invoiceNumber>" . $order->getIncrementId() . "</invoiceNumber>" .
|
817 |
+
"<description>description of transaction</description>" .
|
818 |
+
"<purchaseOrderNumber>" . $order->getIncrementId() . "</purchaseOrderNumber>" .
|
819 |
+
"</order>";
|
820 |
+
$content .="<transId>" . $transId . "</transId>" .
|
821 |
+
"</profileTransRefund>" .
|
822 |
+
"</transaction>" .
|
823 |
+
"</createCustomerProfileTransactionRequest>";
|
824 |
+
return array('req' => $content, 'cpid' => $customerProfileId, 'cppid' => $paymentProfileId, 'csid' => $ShippingAddressId, 'cc' => $cardNumber);
|
825 |
+
}
|
826 |
+
|
827 |
+
/**
|
828 |
+
* Get config action to process initialization
|
829 |
+
*
|
830 |
+
* @return string
|
831 |
+
*/
|
832 |
+
public function getConfigPaymentAction() {
|
833 |
+
$paymentAction = $this->getConfigData('payment_action');
|
834 |
+
return empty($paymentAction) ? true : $paymentAction;
|
835 |
+
}
|
836 |
+
|
837 |
+
/**
|
838 |
+
* Gateway response wrapper
|
839 |
+
*
|
840 |
+
* @param string $text
|
841 |
+
* @return string
|
842 |
+
*/
|
843 |
+
protected function _wrapGatewayError($text) {
|
844 |
+
return Mage::helper('paygate')->__('Gateway error: %s', $text);
|
845 |
+
}
|
846 |
+
|
847 |
+
/**
|
848 |
+
* Round up and cast specified amount to float or string
|
849 |
+
*
|
850 |
+
* @param string|float $amount
|
851 |
+
* @param bool $asFloat
|
852 |
+
* @return string|float
|
853 |
+
*/
|
854 |
+
protected function _formatAmount($amount, $asFloat = false) {
|
855 |
+
$amount = sprintf('%.2F', $amount); // "f" depends on locale, "F" doesn't
|
856 |
+
return $asFloat ? (float) $amount : $amount;
|
857 |
+
}
|
858 |
+
|
859 |
+
/**
|
860 |
+
* Add payment transaction
|
861 |
+
*
|
862 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
863 |
+
* @param string $transactionId
|
864 |
+
* @param string $transactionType
|
865 |
+
* @param array $transactionDetails
|
866 |
+
* @param array $transactionAdditionalInfo
|
867 |
+
* @return null|Mage_Sales_Model_Order_Payment_Transaction
|
868 |
+
*/
|
869 |
+
protected function _addTransaction(Mage_Sales_Model_Order_Payment $payment, $transactionId, $transactionType, array $transactionDetails = array(), array $transactionAdditionalInfo = array(), $message = false
|
870 |
+
) {
|
871 |
+
$payment->setTransactionId($transactionId);
|
872 |
+
$payment->resetTransactionAdditionalInfo();
|
873 |
+
foreach ($transactionDetails as $key => $value) {
|
874 |
+
$payment->setData($key, $value);
|
875 |
+
}
|
876 |
+
foreach ($transactionAdditionalInfo as $key => $value) {
|
877 |
+
$payment->setTransactionAdditionalInfo($key, $value);
|
878 |
+
}
|
879 |
+
$transaction = $payment->addTransaction($transactionType, null, false, $message);
|
880 |
+
foreach ($transactionDetails as $key => $value) {
|
881 |
+
$payment->unsetData($key);
|
882 |
+
}
|
883 |
+
$payment->unsLastTransId();
|
884 |
+
|
885 |
+
/**
|
886 |
+
* It for self using
|
887 |
+
*/
|
888 |
+
$transaction->setMessage($message);
|
889 |
+
|
890 |
+
return $transaction;
|
891 |
+
}
|
892 |
+
|
893 |
+
/**
|
894 |
+
* Log debug data to file
|
895 |
+
*
|
896 |
+
* @param mixed $debugData
|
897 |
+
*/
|
898 |
+
protected function _debug($debugData) {
|
899 |
+
if ($this->getDebugFlag()) {
|
900 |
+
foreach ($this->_debugReplacePrivateDataKeys as $k) {
|
901 |
+
$debugData = preg_replace('/<' . $k . '>.*?<\/' . $k . '>/i', '<' . $k . '>***********</' . $k . '>', $debugData);
|
902 |
+
}
|
903 |
+
Mage::getModel('core/log_adapter', 'payment_' . $this->getCode() . '.log')
|
904 |
+
->log($debugData);
|
905 |
+
}
|
906 |
+
}
|
907 |
+
|
908 |
+
}
|
app/code/local/Sttl/Authorizecim/Model/Mysql4/Transaction.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silver Touch Technologies Limited.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
11 |
+
*
|
12 |
+
* @category Sttl
|
13 |
+
* @package Sttl_Authorizecim
|
14 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
15 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
16 |
+
*/
|
17 |
+
|
18 |
+
|
19 |
+
class Sttl_Authorizecim_Model_Mysql4_Transaction extends Mage_Core_Model_Mysql4_Abstract
|
20 |
+
{
|
21 |
+
public function _construct()
|
22 |
+
{
|
23 |
+
$this->_init('authorizecim/transaction', 'authorize_id');
|
24 |
+
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
}
|
app/code/local/Sttl/Authorizecim/Model/Mysql4/Transaction/Collection.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silver Touch Technologies Limited.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
11 |
+
*
|
12 |
+
* @category Sttl
|
13 |
+
* @package Sttl_Authorizecim
|
14 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
15 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
16 |
+
*/
|
17 |
+
|
18 |
+
class Sttl_Authorizecim_Model_Mysql4_Transaction_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
19 |
+
{
|
20 |
+
|
21 |
+
protected $_previewFlag;
|
22 |
+
|
23 |
+
public function _construct()
|
24 |
+
{
|
25 |
+
parent::_construct();
|
26 |
+
$this->_init('authorizecim/transaction');
|
27 |
+
}
|
28 |
+
|
29 |
+
}
|
app/code/local/Sttl/Authorizecim/Model/Payment.php
ADDED
@@ -0,0 +1,683 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Silver Touch Technologies Limited.
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
12 |
+
*
|
13 |
+
* @category Sttl
|
14 |
+
* @package Sttl_Authorizecim
|
15 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
16 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
17 |
+
*/
|
18 |
+
class Sttl_Authorizecim_Model_Payment extends Sttl_Authorizecim_Model_Api {
|
19 |
+
|
20 |
+
const XML_PAYMENT_ACTION = 'payment/authorizecim/payment_action';
|
21 |
+
const REQUEST_TYPE_AUTH_ONLY = 'AUTH_ONLY';
|
22 |
+
const REQUEST_TYPE_AUTH_CAPTURE = 'AUTH_CAPTURE';
|
23 |
+
const REQUEST_TYPE_VOID = 'VOID';
|
24 |
+
const REQUEST_TYPE_CREDIT = 'CREDIT';
|
25 |
+
const RESPONSE_RESULT_CODE = 'Ok';
|
26 |
+
|
27 |
+
protected $_formBlockType = 'authorizecim/form_cim';
|
28 |
+
protected $_infoBlockType = 'authorizecim/info_cim';
|
29 |
+
protected $_isGateway = true;
|
30 |
+
protected $_canAuthorize = true;
|
31 |
+
protected $_canCapture = true;
|
32 |
+
protected $_canCapturePartial = false;
|
33 |
+
protected $_canRefund = true;
|
34 |
+
protected $_canRefundInvoicePartial = true;
|
35 |
+
protected $_canVoid = true;
|
36 |
+
protected $_canUseCheckout = true;
|
37 |
+
protected $_canSaveCc = false;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Can be edit order (renew order)
|
41 |
+
*
|
42 |
+
* @return bool
|
43 |
+
*/
|
44 |
+
public function canEdit() {
|
45 |
+
return false;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function isAvailable($quote = null) {
|
49 |
+
$useGuest = $this->getConfigData('use_guest');
|
50 |
+
if (!$useGuest) {
|
51 |
+
$checkoutMethod = $quote->getCheckoutMethod();
|
52 |
+
if ($checkoutMethod == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST) {
|
53 |
+
return false;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
return parent::isAvailable($quote);
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Authorize
|
61 |
+
*
|
62 |
+
* @param Varien_Object $orderPayment
|
63 |
+
* @return Mage_GoogleCheckout_Model_Payment
|
64 |
+
*/
|
65 |
+
public function authorize(Varien_Object $payment, $amount) {
|
66 |
+
$isNew = $_paymentProfileId = $message = null;
|
67 |
+
$order = $payment->getOrder();
|
68 |
+
$total = $order->getBaseGrandTotal();
|
69 |
+
$amount = $total; //+$amount;
|
70 |
+
|
71 |
+
if ($amount <= 0) {
|
72 |
+
Mage::throwException(Mage::helper('paygate')->__('Invalid amount for authorization.'));
|
73 |
+
}
|
74 |
+
$payment->setAmount($amount);
|
75 |
+
|
76 |
+
$payment_values = Mage::app()->getRequest()->getParam('payment');
|
77 |
+
if (array_key_exists('cim_payment_profileid', $payment_values)) {
|
78 |
+
$cim_payment_profileid = $payment_values['cim_payment_profileid'];
|
79 |
+
if (!empty($cim_payment_profileid)) {
|
80 |
+
$_paymentProfileId = $cim_payment_profileid;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
$billing = $order->getBillingAddress();
|
85 |
+
if (!$billing->getEmail() && Mage::getSingleton('customer/session')->isLoggedIn()) {
|
86 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
87 |
+
$billing->setEmail($customer->getEmail());
|
88 |
+
}
|
89 |
+
$cimCollection = Mage::getModel('authorizecim/transaction')->getCollection()
|
90 |
+
->addFieldToFilter('email', $billing->getEmail());
|
91 |
+
if ($cimCollection->getSize()) {
|
92 |
+
$customerColection = $cimCollection->getFirstItem();
|
93 |
+
$customerProfileId = $customerColection->getProfileId();
|
94 |
+
$payment->setCimCustomerProfileid($customerProfileId);
|
95 |
+
} else {
|
96 |
+
$customerrequest = $this->_buildCustomerRequest($payment);
|
97 |
+
$customerresponse = $this->sendRequestViaCurl($customerrequest);
|
98 |
+
$parsedresponse = simplexml_load_string($customerresponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
99 |
+
|
100 |
+
if (self::RESPONSE_RESULT_CODE != $parsedresponse->messages->resultCode) {
|
101 |
+
$message = Mage::helper('paygate')->__("The operation failed with the following errors: ");
|
102 |
+
foreach ($parsedresponse->messages->message as $msg) {
|
103 |
+
$message .= Mage::helper('paygate')->__("[" . htmlspecialchars($msg->code) . "] " . htmlspecialchars($msg->text));
|
104 |
+
}
|
105 |
+
if(!count($parsedresponse->messages->message)){
|
106 |
+
$message = strip_tags($customerresponse);
|
107 |
+
}
|
108 |
+
} else {
|
109 |
+
$isNew = true;
|
110 |
+
$customerProfileId = $parsedresponse->customerProfileId;
|
111 |
+
$payment->setCimCustomerProfileid($customerProfileId);
|
112 |
+
}
|
113 |
+
if ($message) {
|
114 |
+
Mage::throwException($message);
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
if ($_paymentProfileId) {
|
119 |
+
$paymentProfile = $_paymentProfileId;
|
120 |
+
} else {
|
121 |
+
$paymentProfile = $this->checkPaymentProfile($customerProfileId, $payment);
|
122 |
+
}
|
123 |
+
/* Payment Profile */
|
124 |
+
if (!$paymentProfile) {
|
125 |
+
$request = $this->_buildPaymentRequest($payment, $customerProfileId);
|
126 |
+
$Paymentresponse = $this->sendRequestViaCurl($request);
|
127 |
+
$parsedPaymentresponse = simplexml_load_string($Paymentresponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
128 |
+
//$parsedPaymentresponse = simplexml_load_string($Paymentresponse);
|
129 |
+
if (self::RESPONSE_RESULT_CODE != $parsedPaymentresponse->messages->resultCode) {
|
130 |
+
$message = Mage::helper('paygate')->__("The operation failed with the following errors: ");
|
131 |
+
foreach ($parsedPaymentresponse->messages->message as $msg) {
|
132 |
+
$message .= Mage::helper('paygate')->__("[" . htmlspecialchars($msg->code) . "] " . htmlspecialchars($msg->text));
|
133 |
+
}
|
134 |
+
if(!count($parsedPaymentresponse->messages->message)){
|
135 |
+
$message = strip_tags($Paymentresponse);
|
136 |
+
}
|
137 |
+
} else {
|
138 |
+
$paymentProfileId = $parsedPaymentresponse->customerPaymentProfileId;
|
139 |
+
$payment->setCimPaymentProfileid($paymentProfileId);
|
140 |
+
}
|
141 |
+
if ($message) {
|
142 |
+
$payment->setSkipTransactionCreation(true);
|
143 |
+
$this->_deleteCustomerProfile($customerProfileId, $isNew);
|
144 |
+
Mage::throwException($message);
|
145 |
+
}
|
146 |
+
} else {
|
147 |
+
$payment->setCimPaymentProfileid($paymentProfile);
|
148 |
+
$paymentProfileId = $paymentProfile;
|
149 |
+
}
|
150 |
+
|
151 |
+
/* Shipping Profile */
|
152 |
+
$shippingProfile = $this->checkShippingProfile($customerProfileId);
|
153 |
+
|
154 |
+
if (!$shippingProfile) {
|
155 |
+
$ShippingRequest = $this->_buildShippingRequest($payment, $customerProfileId);
|
156 |
+
$ShippingResponse = $this->sendRequestViaCurl($ShippingRequest);
|
157 |
+
$parsedShippingresponse = simplexml_load_string($ShippingResponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
158 |
+
//$parsedShippingresponse = simplexml_load_string($ShippingResponse);
|
159 |
+
|
160 |
+
if (self::RESPONSE_RESULT_CODE != $parsedShippingresponse->messages->resultCode) {
|
161 |
+
$message = Mage::helper('paygate')->__("The operation failed with the following errors: ");
|
162 |
+
foreach ($parsedShippingresponse->messages->message as $msg) {
|
163 |
+
$message .= Mage::helper('paygate')->__("[" . htmlspecialchars($msg->code) . "] " . htmlspecialchars($msg->text));
|
164 |
+
}
|
165 |
+
if(!count($parsedShippingresponse->messages->message)){
|
166 |
+
$message = strip_tags($ShippingResponse);
|
167 |
+
}
|
168 |
+
} else {
|
169 |
+
$ShippingAddressId = $parsedShippingresponse->customerAddressId;
|
170 |
+
$payment->setCimShippingAddressid($ShippingAddressId);
|
171 |
+
}
|
172 |
+
if ($message) {
|
173 |
+
$payment->setSkipTransactionCreation(true);
|
174 |
+
$this->_deleteCustomerProfile($customerProfileId, $isNew);
|
175 |
+
Mage::throwException($message);
|
176 |
+
}
|
177 |
+
} else {
|
178 |
+
$payment->setCimShippingAddressid($shippingProfile);
|
179 |
+
$ShippingAddressId = $shippingProfile;
|
180 |
+
}
|
181 |
+
|
182 |
+
/* Transaction Profile */
|
183 |
+
$transactionAction = Mage::getStoreConfig(self::XML_PAYMENT_ACTION);
|
184 |
+
if ($transactionAction == self::ACTION_AUTHORIZE) {
|
185 |
+
$TransactionRequest = $this->_buildTransactionRequest($payment, $customerProfileId, $paymentProfileId, $ShippingAddressId);
|
186 |
+
$TransactionResponse = $this->sendRequestViaCurl($TransactionRequest);
|
187 |
+
$parsedresponse = simplexml_load_string($TransactionResponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
188 |
+
|
189 |
+
if (self::RESPONSE_RESULT_CODE != $parsedresponse->messages->resultCode) {
|
190 |
+
$payment->setSkipTransactionCreation(true);
|
191 |
+
$errorText = $parsedresponse->messages->message->code . "-" . $parsedresponse->messages->message->text;
|
192 |
+
$this->_deleteCustomerProfile($customerProfileId, $isNew);
|
193 |
+
Mage::throwException($this->_wrapGatewayError($errorText));
|
194 |
+
return $this;
|
195 |
+
}
|
196 |
+
if (isset($parsedresponse->directResponse)) {
|
197 |
+
$directResponseFields = explode(",", $parsedresponse->directResponse);
|
198 |
+
$responseCode = $directResponseFields[0]; // 1 = Approved 2 = Declined 3 = Error
|
199 |
+
if ($responseCode != 1) {
|
200 |
+
$errorText = $parsedresponse->messages->message->code . "-" . $parsedresponse->messages->message->text;
|
201 |
+
$this->_deleteCustomerProfile($customerProfileId, $isNew);
|
202 |
+
Mage::throwException($this->_wrapGatewayError($errorText));
|
203 |
+
return $this;
|
204 |
+
}
|
205 |
+
$responseReasonCode = $directResponseFields[2]; // See http://www.authorize.net/support/AIM_guide.pdf
|
206 |
+
$responseReasonText = $directResponseFields[3];
|
207 |
+
$approvalCode = $directResponseFields[4]; // Authorization code
|
208 |
+
|
209 |
+
$cclast4 = $directResponseFields[50]; // CC last 4 digits
|
210 |
+
$cctype = $directResponseFields[51]; // CC type
|
211 |
+
|
212 |
+
$transId = $directResponseFields[6];
|
213 |
+
$transId = htmlspecialchars($transId);
|
214 |
+
$payment->setCimTransactionid($transId);
|
215 |
+
$payment->setTransactionId($transId);
|
216 |
+
$payment->setIsTransactionClosed(0);
|
217 |
+
}
|
218 |
+
} else {
|
219 |
+
$TransactionRequest = $this->_buildTransactionCaptureRequest($payment, $customerProfileId, $paymentProfileId, $ShippingAddressId);
|
220 |
+
$TransactionResponse = $this->sendRequestViaCurl($TransactionRequest);
|
221 |
+
$parsedresponse = simplexml_load_string($TransactionResponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
222 |
+
//$parsedresponse = simplexml_load_string($TransactionResponse);
|
223 |
+
if (self::RESPONSE_RESULT_CODE != $parsedresponse->messages->resultCode) {
|
224 |
+
$payment->setSkipTransactionCreation(true);
|
225 |
+
$errorText = $parsedresponse->messages->message->code . "-" . $parsedresponse->messages->message->text;
|
226 |
+
$this->_deleteCustomerProfile($customerProfileId, $isNew);
|
227 |
+
Mage::throwException($this->_wrapGatewayError($errorText));
|
228 |
+
return $this;
|
229 |
+
}
|
230 |
+
if (isset($parsedresponse->directResponse)) {
|
231 |
+
$directResponseFields = explode(",", $parsedresponse->directResponse);
|
232 |
+
$responseCode = $directResponseFields[0]; // 1 = Approved 2 = Declined 3 = Error
|
233 |
+
if ($responseCode != 1) {
|
234 |
+
$errorText = $parsedresponse->messages->message->code . "-" . $transresponse->messages->message->text;
|
235 |
+
$this->_deleteCustomerProfile($customerProfileId, $isNew);
|
236 |
+
Mage::throwException($this->_wrapGatewayError($errorText));
|
237 |
+
return $this;
|
238 |
+
}
|
239 |
+
$responseReasonCode = $directResponseFields[2]; // See http://www.authorize.net/support/AIM_guide.pdf
|
240 |
+
$responseReasonText = $directResponseFields[3];
|
241 |
+
$approvalCode = $directResponseFields[4]; // Authorization code
|
242 |
+
|
243 |
+
$transId = $directResponseFields[6];
|
244 |
+
$transId = htmlspecialchars($transId);
|
245 |
+
|
246 |
+
$cclast4 = $directResponseFields[50]; // CC last 4 digits
|
247 |
+
$cctype = $directResponseFields[51]; // CC type
|
248 |
+
|
249 |
+
$payment->setCimTransactionid($transId);
|
250 |
+
$payment->setTransactionId($transId);
|
251 |
+
$payment->setIsTransactionClosed(0);
|
252 |
+
}
|
253 |
+
}
|
254 |
+
$cust_email = $billing->getEmail();
|
255 |
+
if (!empty($cust_email)) {
|
256 |
+
$customer_email = $cust_email;
|
257 |
+
} else {
|
258 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
259 |
+
$billingAddress = $quote->getBillingAddress();
|
260 |
+
$customer_email = $billingAddress->getEmail();
|
261 |
+
}
|
262 |
+
|
263 |
+
/* transaction save */
|
264 |
+
$data = array('order_id' => $order->getId(), 'email' => $customer_email, 'cclast4' => $cclast4,
|
265 |
+
'card_type' => $cctype, 'order_payment_id' => $payment->getId(), 'profile_id' => $customerProfileId,
|
266 |
+
'payment_id' => $paymentProfileId, 'shipping_id' => $ShippingAddressId, 'txn_id' => $transId, 'response' => $TransactionResponse);
|
267 |
+
$this->saveTransactionDetails($data);
|
268 |
+
return $this;
|
269 |
+
}
|
270 |
+
|
271 |
+
/* Send capture request to gateway
|
272 |
+
|
273 |
+
*
|
274 |
+
* @param Varien_Object $payment
|
275 |
+
* @param decimal $amount
|
276 |
+
* @return Mage_Paygate_Model_Authorizenet
|
277 |
+
* @throws Mage_Core_Exception
|
278 |
+
*/
|
279 |
+
|
280 |
+
public function capture(Varien_Object $payment, $amount) {
|
281 |
+
$transaction_details = $payment->getAuthorizationTransaction();
|
282 |
+
if (!empty($transaction_details)) {
|
283 |
+
$order_id = $transaction_details->getOrderId();
|
284 |
+
$transModel = Mage::getModel('authorizecim/transaction')
|
285 |
+
->getCollection()
|
286 |
+
->addFieldToFilter('order_id', $order_id);
|
287 |
+
|
288 |
+
if ($transModel->getSize()) {
|
289 |
+
$trandaction_profile = $transModel->getFirstItem();
|
290 |
+
$customer_profile_id = $trandaction_profile->getProfileId();
|
291 |
+
$customer_payment_id = $trandaction_profile->getPaymentId();
|
292 |
+
$customer_shipping_id = $trandaction_profile->getShippingId();
|
293 |
+
$payment->setAnetTransType(self::REQUEST_TYPE_AUTH_CAPTURE);
|
294 |
+
$order = $payment->getOrder();
|
295 |
+
$billing = $order->getBillingAddress();
|
296 |
+
$payment->setAmount($amount);
|
297 |
+
$TransactionRequest = $this->_buildCaptureRequest($payment, $customer_profile_id, $customer_payment_id, $customer_shipping_id);
|
298 |
+
$TransactionResponse = $this->sendRequestViaCurl($TransactionRequest);
|
299 |
+
$transresponse = simplexml_load_string($TransactionResponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
300 |
+
if (isset($transresponse->directResponse)) {
|
301 |
+
$directResponseFields = explode(",", $transresponse->directResponse);
|
302 |
+
$responseCode = $directResponseFields[0]; // 1 = Approved 2 = Declined 3 = Error
|
303 |
+
if ($responseCode == 1) {
|
304 |
+
$responseReasonCode = $directResponseFields[2]; // See http://www.authorize.net/support/AIM_guide.pdf
|
305 |
+
$responseReasonText = $directResponseFields[3];
|
306 |
+
$approvalCode = $directResponseFields[4]; // Authorization code
|
307 |
+
$transId = $directResponseFields[6];
|
308 |
+
$transId = htmlspecialchars($transId);
|
309 |
+
|
310 |
+
$cclast4 = $directResponseFields[50];
|
311 |
+
$cardType = $directResponseFields[51];
|
312 |
+
|
313 |
+
$payment->setStatus(self::STATUS_APPROVED);
|
314 |
+
$payment->setLastTransId($transId);
|
315 |
+
if (!$payment->getParentTransactionId() || $transId != $payment->getParentTransactionId()) {
|
316 |
+
$payment->setTransactionId($transId);
|
317 |
+
$payment->setIsTransactionClosed(0);
|
318 |
+
}
|
319 |
+
$payment->setCimTransactionid($transId);
|
320 |
+
|
321 |
+
/* transaction save */
|
322 |
+
$data = array('order_id' => $order->getId(), 'email' => $billing->getEmail(), 'cclast4' => $cclast4,
|
323 |
+
'card_type' => $cardType, 'order_payment_id' => $payment->getId(), 'profile_id' => $customer_profile_id,
|
324 |
+
'payment_id' => $customer_payment_id, 'shipping_id' => $customer_shipping_id, 'txn_id' => $transId, 'response' => $TransactionResponse);
|
325 |
+
$this->saveTransactionDetails($data);
|
326 |
+
}
|
327 |
+
|
328 |
+
if (self::RESPONSE_RESULT_CODE != $transresponse->messages->resultCode) {
|
329 |
+
$payment->setSkipTransactionCreation(true);
|
330 |
+
$errorText = $transresponse->messages->message->code . "-" . $transresponse->messages->message->text;
|
331 |
+
Mage::throwException($this->_wrapGatewayError($errorText));
|
332 |
+
}
|
333 |
+
} else {
|
334 |
+
$payment->setSkipTransactionCreation(true);
|
335 |
+
Mage::throwException(Mage::helper('paygate')->__('Error in capturing the payment.'));
|
336 |
+
}
|
337 |
+
} else {
|
338 |
+
//Authorize Capture
|
339 |
+
$this->authorize_capture($payment, $amount);
|
340 |
+
}
|
341 |
+
} else {
|
342 |
+
//Authorize Capture
|
343 |
+
$this->authorize_capture($payment, $amount);
|
344 |
+
}
|
345 |
+
}
|
346 |
+
|
347 |
+
protected function authorize_capture(Varien_Object $payment, $amount) {
|
348 |
+
$isNew = $message = null;
|
349 |
+
$order = $payment->getOrder();
|
350 |
+
$total = $order->getBaseGrandTotal();
|
351 |
+
$amount = $total; //+$amount;
|
352 |
+
|
353 |
+
if ($amount <= 0) {
|
354 |
+
Mage::throwException(Mage::helper('paygate')->__('Invalid amount for authorization.'));
|
355 |
+
}
|
356 |
+
$payment->setAmount($amount);
|
357 |
+
|
358 |
+
$payment_values = Mage::app()->getRequest()->getParam('payment');
|
359 |
+
if (array_key_exists('cim_payment_profileid', $payment_values)) {
|
360 |
+
|
361 |
+
$cim_payment_profileid = $payment_values['cim_payment_profileid'];
|
362 |
+
if (!empty($cim_payment_profileid)) {
|
363 |
+
$_paymentProfileId = $cim_payment_profileid;
|
364 |
+
}
|
365 |
+
}
|
366 |
+
|
367 |
+
$billing = $order->getBillingAddress();
|
368 |
+
if (!$billing->getEmail() && Mage::getSingleton('customer/session')->isLoggedIn()) {
|
369 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
370 |
+
$billing->setEmail($customer->getEmail());
|
371 |
+
}
|
372 |
+
$cimCollection = Mage::getModel('authorizecim/transaction')->getCollection()
|
373 |
+
->addFieldToFilter('email', $billing->getEmail());
|
374 |
+
if ($cimCollection->getSize()) {
|
375 |
+
$customerColection = $cimCollection->getFirstItem();
|
376 |
+
$customerProfileId = $customerColection->getProfileId();
|
377 |
+
$payment->setCimCustomerProfileid($customerProfileId);
|
378 |
+
} else {
|
379 |
+
$customerrequest = $this->_buildCustomerRequest($payment);
|
380 |
+
$customerresponse = $this->sendRequestViaCurl($customerrequest);
|
381 |
+
|
382 |
+
$parsedresponse = simplexml_load_string($customerresponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
383 |
+
|
384 |
+
if (self::RESPONSE_RESULT_CODE != $parsedresponse->messages->resultCode) {
|
385 |
+
$payment->setSkipTransactionCreation(true);
|
386 |
+
$message = Mage::helper('paygate')->__('The operation failed with the following errors: ');
|
387 |
+
foreach ($parsedresponse->messages->message as $msg) {
|
388 |
+
$message .= Mage::helper('paygate')->__("[" . htmlspecialchars($msg->code) . "] " . htmlspecialchars($msg->text));
|
389 |
+
}
|
390 |
+
if(!count($parsedresponse->messages->message)){
|
391 |
+
$message = strip_tags($customerresponse);
|
392 |
+
}
|
393 |
+
} else {
|
394 |
+
$isNew = true;
|
395 |
+
$customerProfileId = $parsedresponse->customerProfileId;
|
396 |
+
$payment->setCimCustomerProfileid($customerProfileId);
|
397 |
+
}
|
398 |
+
if ($message) {
|
399 |
+
$payment->setSkipTransactionCreation(true);
|
400 |
+
Mage::throwException($message);
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
if (!empty($_paymentProfileId)) {
|
405 |
+
$paymentProfile = $_paymentProfileId;
|
406 |
+
} else {
|
407 |
+
$paymentProfile = $this->checkPaymentProfile($customerProfileId, $payment);
|
408 |
+
}
|
409 |
+
|
410 |
+
/* Payment Profile */
|
411 |
+
if (!$paymentProfile) {
|
412 |
+
$request = $this->_buildPaymentRequest($payment, $customerProfileId);
|
413 |
+
$Paymentresponse = $this->sendRequestViaCurl($request);
|
414 |
+
$parsedPaymentresponse = simplexml_load_string($Paymentresponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
415 |
+
if (self::RESPONSE_RESULT_CODE != $parsedPaymentresponse->messages->resultCode) {
|
416 |
+
$message = Mage::helper('paygate')->__('The operation failed with the following errors: ');
|
417 |
+
foreach ($parsedPaymentresponse->messages->message as $msg) {
|
418 |
+
$message .= Mage::helper('paygate')->__("[" . htmlspecialchars($msg->code) . "] " . htmlspecialchars($msg->text));
|
419 |
+
}
|
420 |
+
if(!count($parsedPaymentresponse->messages->message)){
|
421 |
+
$message = strip_tags($Paymentresponse);
|
422 |
+
}
|
423 |
+
} else {
|
424 |
+
$paymentProfileId = $parsedPaymentresponse->customerPaymentProfileId;
|
425 |
+
$payment->setCimPaymentProfileid($paymentProfileId);
|
426 |
+
}
|
427 |
+
if ($message) {
|
428 |
+
$payment->setSkipTransactionCreation(true);
|
429 |
+
$this->_deleteCustomerProfile($customerProfileId, $isNew);
|
430 |
+
Mage::throwException($message);
|
431 |
+
}
|
432 |
+
} else {
|
433 |
+
$payment->setCimPaymentProfileid($paymentProfile);
|
434 |
+
$paymentProfileId = $paymentProfile;
|
435 |
+
}
|
436 |
+
|
437 |
+
/* Shipping Profile */
|
438 |
+
$shippingProfile = $this->checkShippingProfile($customerProfileId);
|
439 |
+
|
440 |
+
if (!$shippingProfile) {
|
441 |
+
$ShippingRequest = $this->_buildShippingRequest($payment, $customerProfileId);
|
442 |
+
$ShippingResponse = $this->sendRequestViaCurl($ShippingRequest);
|
443 |
+
$parsedShippingresponse = simplexml_load_string($ShippingResponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
444 |
+
|
445 |
+
if (self::RESPONSE_RESULT_CODE != $parsedShippingresponse->messages->resultCode) {
|
446 |
+
$message = Mage::helper('paygate')->__('The operation failed with the following errors: ');
|
447 |
+
foreach ($parsedShippingresponse->messages->message as $msg) {
|
448 |
+
$message .= Mage::helper('paygate')->__("[" . htmlspecialchars($msg->code) . "] " . htmlspecialchars($msg->text));
|
449 |
+
}
|
450 |
+
if(!count($parsedShippingresponse->messages->message)){
|
451 |
+
$message = strip_tags($ShippingResponse);
|
452 |
+
}
|
453 |
+
} else {
|
454 |
+
$ShippingAddressId = $parsedShippingresponse->customerAddressId;
|
455 |
+
$payment->setCimShippingAddressid($ShippingAddressId);
|
456 |
+
}
|
457 |
+
if ($message) {
|
458 |
+
$payment->setSkipTransactionCreation(true);
|
459 |
+
$this->_deleteCustomerProfile($customerProfileId, $isNew);
|
460 |
+
Mage::throwException($message);
|
461 |
+
}
|
462 |
+
} else {
|
463 |
+
$payment->setCimShippingAddressid($shippingProfile);
|
464 |
+
$ShippingAddressId = $shippingProfile;
|
465 |
+
}
|
466 |
+
|
467 |
+
$TransactionRequest = $this->_buildTransactionCaptureRequest($payment, $customerProfileId, $paymentProfileId, $ShippingAddressId);
|
468 |
+
$TransactionResponse = $this->sendRequestViaCurl($TransactionRequest);
|
469 |
+
$parsedresponse = simplexml_load_string($TransactionResponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
470 |
+
if (self::RESPONSE_RESULT_CODE != $parsedresponse->messages->resultCode) {
|
471 |
+
$errorText = $parsedresponse->messages->message->code . "-" . $parsedresponse->messages->message->text;
|
472 |
+
$this->_deleteCustomerProfile($customerProfileId, $isNew);
|
473 |
+
Mage::throwException($this->_wrapGatewayError($errorText));
|
474 |
+
return $this;
|
475 |
+
}
|
476 |
+
|
477 |
+
if (isset($parsedresponse->directResponse)) {
|
478 |
+
$directResponseFields = explode(",", $parsedresponse->directResponse);
|
479 |
+
$responseCode = $directResponseFields[0]; // 1 = Approved 2 = Declined 3 = Error
|
480 |
+
|
481 |
+
if ($responseCode != 1) {
|
482 |
+
$payment->setSkipTransactionCreation(true);
|
483 |
+
$errorText = $parsedresponse->messages->message->code . "-" . $parsedresponse->messages->message->text;
|
484 |
+
$this->_deleteCustomerProfile($customerProfileId, $isNew);
|
485 |
+
Mage::throwException($this->_wrapGatewayError($errorText));
|
486 |
+
return $this;
|
487 |
+
}
|
488 |
+
|
489 |
+
$responseReasonCode = $directResponseFields[2]; // See http://www.authorize.net/support/AIM_guide.pdf
|
490 |
+
$responseReasonText = $directResponseFields[3];
|
491 |
+
$approvalCode = $directResponseFields[4]; // Authorization code
|
492 |
+
$transId = $directResponseFields[6];
|
493 |
+
$transId = htmlspecialchars($transId);
|
494 |
+
|
495 |
+
$cclast4 = $directResponseFields[50];
|
496 |
+
$cardType = $directResponseFields[51];
|
497 |
+
|
498 |
+
$payment->setStatus(self::STATUS_APPROVED);
|
499 |
+
$payment->setLastTransId($transId);
|
500 |
+
$payment->setCimTransactionid($transId);
|
501 |
+
$payment->setTransactionId($transId);
|
502 |
+
$payment->setIsTransactionClosed(0);
|
503 |
+
|
504 |
+
$cust_email = $billing->getEmail();
|
505 |
+
if (!empty($cust_email)) {
|
506 |
+
$customer_email = $cust_email;
|
507 |
+
} else {
|
508 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
509 |
+
$billingAddress = $quote->getBillingAddress();
|
510 |
+
$customer_email = $billingAddress->getEmail();
|
511 |
+
}
|
512 |
+
|
513 |
+
/* transaction save */
|
514 |
+
$data = array('order_id' => $order->getId(), 'email' => $customer_email, 'cclast4' => $cclast4,
|
515 |
+
'card_type' => $cardType, 'order_payment_id' => $payment->getId(), 'profile_id' => $customerProfileId,
|
516 |
+
'payment_id' => $paymentProfileId, 'shipping_id' => $ShippingAddressId, 'txn_id' => $transId, 'response' => $TransactionResponse);
|
517 |
+
$this->saveTransactionDetails($data);
|
518 |
+
}
|
519 |
+
return $this;
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Void the payment through gateway
|
524 |
+
*
|
525 |
+
* @param Varien_Object $payment
|
526 |
+
* @return Mage_Paygate_Model_Authorizenet
|
527 |
+
* @throws Mage_Core_Exception
|
528 |
+
*/
|
529 |
+
public function void(Varien_Object $payment) {
|
530 |
+
if ($payment->getParentTransactionId()) {
|
531 |
+
$payment->setAnetTransType(self::REQUEST_TYPE_VOID);
|
532 |
+
|
533 |
+
$TransactionRequestArr = $this->_buildVoidRequest($payment, $payment->getCimCustomerProfileid(), $payment->getCimPaymentProfileid(), $payment->getCimShippingAddressid());
|
534 |
+
if (is_array($TransactionRequestArr) && count($TransactionRequestArr) > 0) {
|
535 |
+
$TransactionRequest = $TransactionRequestArr['req'];
|
536 |
+
$TransactionResponse = $this->sendRequestViaCurl($TransactionRequest);
|
537 |
+
$transresponse = simplexml_load_string($TransactionResponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
538 |
+
if (self::RESPONSE_RESULT_CODE != $transresponse->messages->resultCode) {
|
539 |
+
$message = Mage::helper('paygate')->__("The operation failed with the following errors: ");
|
540 |
+
foreach ($transresponse->messages->message as $msg) {
|
541 |
+
$message .= Mage::helper('paygate')->__("[" . htmlspecialchars($msg->code) . "] " . htmlspecialchars($msg->text));
|
542 |
+
}
|
543 |
+
if(!count($transresponse->messages->message)){
|
544 |
+
$message = strip_tags($TransactionResponse);
|
545 |
+
}
|
546 |
+
} else {
|
547 |
+
if (isset($transresponse->directResponse)) {
|
548 |
+
$directResponseFields = explode(",", $transresponse->directResponse);
|
549 |
+
$responseCode = $directResponseFields[0]; // 1 = Approved 2 = Declined 3 = Error
|
550 |
+
if ($responseCode == 1) {
|
551 |
+
$transId = $directResponseFields[6];
|
552 |
+
$transId = htmlspecialchars($transId);
|
553 |
+
|
554 |
+
$cclast4 = $directResponseFields[50];
|
555 |
+
$cardType = $directResponseFields[51];
|
556 |
+
|
557 |
+
$payment->setLastTransId($transId);
|
558 |
+
$payment->setIsTransactionClosed(1);
|
559 |
+
$order = $payment->getOrder();
|
560 |
+
$billing = $order->getBillingAddress();
|
561 |
+
$customer_profile_id = $TransactionRequestArr['cpid'];
|
562 |
+
$customer_payment_id = $TransactionRequestArr['cppid'];
|
563 |
+
$customer_shipping_id = $TransactionRequestArr['csid'];
|
564 |
+
|
565 |
+
/* transaction save */
|
566 |
+
$data = array('order_id' => $order->getId(), 'email' => $billing->getEmail(), 'cclast4' => $cclast4,
|
567 |
+
'card_type' => $cardType, 'order_payment_id' => $payment->getId(), 'profile_id' => $customer_profile_id,
|
568 |
+
'payment_id' => $customer_payment_id, 'shipping_id' => $customer_shipping_id, 'txn_id' => $transId, 'response' => $TransactionResponse);
|
569 |
+
$this->saveTransactionDetails($data);
|
570 |
+
|
571 |
+
$payment->setStatus(self::STATUS_SUCCESS);
|
572 |
+
return $this;
|
573 |
+
}
|
574 |
+
}
|
575 |
+
$payment->setSkipTransactionCreation(true);
|
576 |
+
$payment->setStatus(self::STATUS_ERROR);
|
577 |
+
$errorText = $transresponse->messages->message->code . "-" . $transresponse->messages->message->text;
|
578 |
+
Mage::throwException($errorText);
|
579 |
+
}
|
580 |
+
} else {
|
581 |
+
$payment->setSkipTransactionCreation(true);
|
582 |
+
$payment->setStatus(self::STATUS_ERROR);
|
583 |
+
Mage::throwException(Mage::helper('paygate')->__('Transaction not found.'));
|
584 |
+
}
|
585 |
+
} else {
|
586 |
+
$payment->setSkipTransactionCreation(true);
|
587 |
+
$payment->setStatus(self::STATUS_ERROR);
|
588 |
+
Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
|
589 |
+
}
|
590 |
+
}
|
591 |
+
|
592 |
+
public function cancel(Varien_Object $payment) {
|
593 |
+
return $this->void($payment);
|
594 |
+
}
|
595 |
+
|
596 |
+
/**
|
597 |
+
* Refund the amount
|
598 |
+
* Need to decode Last 4 digits for request.
|
599 |
+
*
|
600 |
+
* @param Varien_Object $payment
|
601 |
+
* @param decimal $amount
|
602 |
+
* @return Mage_Authorizenet_Model_Directpost
|
603 |
+
* @throws Mage_Core_Exception
|
604 |
+
*/
|
605 |
+
public function refund(Varien_Object $payment, $amount) {
|
606 |
+
if (!$this->canRefund()) {
|
607 |
+
Mage::throwException(Mage::helper('payment')->__('Refund action is not available.'));
|
608 |
+
}
|
609 |
+
if ($payment->getParentTransactionId()) {
|
610 |
+
$order = $payment->getOrder();
|
611 |
+
$payment->setAnetTransType(self::REQUEST_TYPE_CREDIT);
|
612 |
+
$TransactionRequestArr = $this->_buildRefundRequest($payment, $amount);
|
613 |
+
$TransactionRequest = $TransactionRequestArr['req'];
|
614 |
+
$TransactionResponse = $this->sendRequestViaCurl($TransactionRequest);
|
615 |
+
$transresponse = simplexml_load_string($TransactionResponse, "SimpleXMLElement", LIBXML_NOWARNING);
|
616 |
+
if (self::RESPONSE_RESULT_CODE != $transresponse->messages->resultCode) {
|
617 |
+
$message = Mage::helper('paygate')->__("The operation failed with the following errors: ");
|
618 |
+
foreach ($transresponse->messages->message as $msg) {
|
619 |
+
$message .= Mage::helper('paygate')->__("[" . htmlspecialchars($msg->code) . "] " . htmlspecialchars($msg->text));
|
620 |
+
}
|
621 |
+
if(!count($transresponse->messages->message)){
|
622 |
+
$message = strip_tags($TransactionResponse);
|
623 |
+
}
|
624 |
+
} else {
|
625 |
+
if (isset($transresponse->directResponse)) {
|
626 |
+
$directResponseFields = explode(",", $transresponse->directResponse);
|
627 |
+
$responseCode = $directResponseFields[0]; // 1 = Approved 2 = Declined 3 = Error
|
628 |
+
if ($responseCode == 1) {
|
629 |
+
$transId = $directResponseFields[6];
|
630 |
+
$transId = htmlspecialchars($transId);
|
631 |
+
|
632 |
+
$cclast4 = $directResponseFields[50];
|
633 |
+
$cardType = $directResponseFields[51];
|
634 |
+
/**
|
635 |
+
* If it is last amount for refund, transaction with type "capture" will be closed
|
636 |
+
* and card will has last transaction with type "refund"
|
637 |
+
*/
|
638 |
+
$payment->setLastTransId($transId);
|
639 |
+
if (!$payment->getParentTransactionId() || $transId != $payment->getParentTransactionId()) {
|
640 |
+
$payment->setTransactionId($transId);
|
641 |
+
}
|
642 |
+
$payment->setIsTransactionClosed(0);
|
643 |
+
|
644 |
+
if ($this->_formatAmount($order->getTotalRefunded()) == $this->_formatAmount($order->getTotalInvoiced())) {
|
645 |
+
$payment->setIsTransactionClosed(1);
|
646 |
+
}
|
647 |
+
$payment->setStatus(self::STATUS_SUCCESS);
|
648 |
+
$billing = $order->getBillingAddress();
|
649 |
+
|
650 |
+
/* transaction save */
|
651 |
+
$data = array('order_id' => $order->getId(), 'email' => $billing->getEmail(), 'cclast4' => $cclast4,
|
652 |
+
'card_type' => $cardType, 'order_payment_id' => $payment->getId(), 'profile_id' => $TransactionRequestArr['cpid'],
|
653 |
+
'payment_id' => $TransactionRequestArr['cppid'], 'shipping_id' => $TransactionRequestArr['csid'], 'txn_id' => $transId, 'response' => $TransactionResponse);
|
654 |
+
$this->saveTransactionDetails($data);
|
655 |
+
|
656 |
+
return $this;
|
657 |
+
}
|
658 |
+
}
|
659 |
+
}
|
660 |
+
$payment->setSkipTransactionCreation(true);
|
661 |
+
$payment->setStatus(self::STATUS_ERROR);
|
662 |
+
$errorText = $transresponse->messages->message->code . "-" . $transresponse->messages->message->text;
|
663 |
+
Mage::throwException(Mage::helper('paygate')->__($errorText));
|
664 |
+
return $this;
|
665 |
+
} else {
|
666 |
+
$payment->setSkipTransactionCreation(true);
|
667 |
+
$payment->setStatus(self::STATUS_ERROR);
|
668 |
+
Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
|
669 |
+
return $this;
|
670 |
+
}
|
671 |
+
}
|
672 |
+
|
673 |
+
/* save authorizecim transaction details */
|
674 |
+
|
675 |
+
protected function saveTransactionDetails($data) {
|
676 |
+
$transModel = Mage::getModel('authorizecim/transaction');
|
677 |
+
$transModel->setData($data)
|
678 |
+
->setCreated(Mage::getModel('core/date')->date())
|
679 |
+
->save();
|
680 |
+
return $transModel->getId();
|
681 |
+
}
|
682 |
+
|
683 |
+
}
|
app/code/local/Sttl/Authorizecim/Model/System/Config/Backend/Encrypted.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silver Touch Technologies Limited.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
11 |
+
*
|
12 |
+
* @category Sttl
|
13 |
+
* @package Sttl_Authorizecim
|
14 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
15 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
16 |
+
*/
|
17 |
+
|
18 |
+
class Sttl_Authorizecim_Model_System_Config_Backend_Encrypted extends Mage_Core_Model_Config_Data
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Decrypt value after loading
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
protected function _afterLoad()
|
26 |
+
{
|
27 |
+
$value = (string)$this->getValue();
|
28 |
+
if (!empty($value) && ($decrypted = Mage::helper('core')->decrypt($value))) {
|
29 |
+
$this->setValue($decrypted);
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Encrypt value before saving
|
35 |
+
*
|
36 |
+
*/
|
37 |
+
protected function _beforeSave()
|
38 |
+
{
|
39 |
+
$value = (string)$this->getValue();
|
40 |
+
// don't change value, if an obscured value came
|
41 |
+
if (preg_match('/^\*+$/', $this->getValue())) {
|
42 |
+
$value = $this->getOldValue();
|
43 |
+
}
|
44 |
+
if (!empty($value) && ($encrypted = Mage::helper('core')->encrypt($value))) {
|
45 |
+
$this->setValue($encrypted);
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Get & decrypt old value from configuration
|
51 |
+
*
|
52 |
+
* @return string
|
53 |
+
*/
|
54 |
+
public function getOldValue()
|
55 |
+
{
|
56 |
+
return Mage::helper('core')->decrypt(parent::getOldValue());
|
57 |
+
}
|
58 |
+
}
|
app/code/local/Sttl/Authorizecim/Model/System/Config/Source/Cctype.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silver Touch Technologies Limited.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
11 |
+
*
|
12 |
+
* @category Sttl
|
13 |
+
* @package Sttl_Authorizecim
|
14 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
15 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
16 |
+
*/
|
17 |
+
|
18 |
+
class Sttl_Authorizecim_Model_System_Config_Source_Cctype extends Mage_Payment_Model_Source_Cctype
|
19 |
+
{
|
20 |
+
public function getAllowedTypes()
|
21 |
+
{
|
22 |
+
return array('VI', 'MC', 'AE', 'DI', 'OT');
|
23 |
+
}
|
24 |
+
}
|
app/code/local/Sttl/Authorizecim/Model/System/Config/Source/Method.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silver Touch Technologies Limited.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
11 |
+
*
|
12 |
+
* @category Sttl
|
13 |
+
* @package Sttl_Authorizecim
|
14 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
15 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
16 |
+
*/
|
17 |
+
class Sttl_Authorizecim_Model_System_Config_Source_Method
|
18 |
+
{
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Options getter
|
22 |
+
*
|
23 |
+
* @return array
|
24 |
+
*/
|
25 |
+
public function toOptionArray()
|
26 |
+
{
|
27 |
+
return array(
|
28 |
+
array('value' => 'createCustomerProfileRequest', 'label'=>Mage::helper('authorizecim')->__('createCustomerProfileRequest')),
|
29 |
+
array('value' => 'createCustomerPaymentProfileRequest', 'label'=>Mage::helper('authorizecim')->__('createCustomerPaymentProfileRequest')),
|
30 |
+
array('value' => 'createCustomerShippingAddressRequest', 'label'=>Mage::helper('authorizecim')->__('createCustomerShippingAddressRequest')),
|
31 |
+
array('value' => 'createCustomerProfileTransactionRequest', 'label'=>Mage::helper('authorizecim')->__('createCustomerProfileTransactionRequest')),
|
32 |
+
array('value' => 'deleteCustomerProfileRequest', 'label'=>Mage::helper('authorizecim')->__('deleteCustomerProfileRequest')),
|
33 |
+
array('value' => 'deleteCustomerPaymentProfileRequest', 'label'=>Mage::helper('authorizecim')->__('deleteCustomerPaymentProfileRequest')),
|
34 |
+
array('value' => 'deleteCustomerShippingAddressRequest', 'label'=>Mage::helper('authorizecim')->__('deleteCustomerShippingAddressRequest')),
|
35 |
+
array('value' => 'getCustomerProfileIdsRequest', 'label'=>Mage::helper('authorizecim')->__('getCustomerProfileIdsRequest')),
|
36 |
+
array('value' => 'getCustomerProfileRequest', 'label'=>Mage::helper('authorizecim')->__('getCustomerProfileRequest')),
|
37 |
+
array('value' => 'getCustomerPaymentProfileRequest', 'label'=>Mage::helper('authorizecim')->__('getCustomerPaymentProfileRequest')),
|
38 |
+
array('value' => 'getCustomerShippingAddressRequest', 'label'=>Mage::helper('authorizecim')->__('getCustomerShippingAddressRequest')),
|
39 |
+
array('value' => 'updateCustomerProfileRequest', 'label'=>Mage::helper('authorizecim')->__('updateCustomerProfileRequest')),
|
40 |
+
array('value' => 'updateCustomerPaymentProfileRequest', 'label'=>Mage::helper('authorizecim')->__('updateCustomerPaymentProfileRequest')),
|
41 |
+
array('value' => 'updateCustomerShippingAddressRequest', 'label'=>Mage::helper('authorizecim')->__('updateCustomerShippingAddressRequest')),
|
42 |
+
array('value' => 'updateSplitTenderGroupRequest', 'label'=>Mage::helper('authorizecim')->__('updateSplitTenderGroupRequest')),
|
43 |
+
array('value' => 'validateCustomerPaymentProfileRequest', 'label'=>Mage::helper('authorizecim')->__('validateCustomerPaymentProfileRequest')),
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
app/code/local/Sttl/Authorizecim/Model/System/Config/Source/PaymentAction.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silver Touch Technologies Limited.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
11 |
+
*
|
12 |
+
* @category Sttl
|
13 |
+
* @package Sttl_Authorizecim
|
14 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
15 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
16 |
+
*/
|
17 |
+
class Sttl_Authorizecim_Model_System_Config_Source_PaymentAction
|
18 |
+
{
|
19 |
+
public function toOptionArray()
|
20 |
+
{
|
21 |
+
return array(
|
22 |
+
array(
|
23 |
+
'value' => Mage_Paygate_Model_Authorizenet::ACTION_AUTHORIZE,
|
24 |
+
'label' => Mage::helper('paygate')->__('Authorize Only')
|
25 |
+
),
|
26 |
+
array(
|
27 |
+
'value' => Mage_Paygate_Model_Authorizenet::ACTION_AUTHORIZE_CAPTURE,
|
28 |
+
'label' => Mage::helper('paygate')->__('Authorize and Capture')
|
29 |
+
),
|
30 |
+
|
31 |
+
);
|
32 |
+
}
|
33 |
+
}
|
app/code/local/Sttl/Authorizecim/Model/System/Config/Source/Yesno.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silver Touch Technologies Limited.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
11 |
+
*
|
12 |
+
* @category Sttl
|
13 |
+
* @package Sttl_Authorizecim
|
14 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
15 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
16 |
+
*/
|
17 |
+
class Sttl_Authorizecim_Model_System_Config_Source_Yesno
|
18 |
+
{
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Options getter
|
22 |
+
*
|
23 |
+
* @return array
|
24 |
+
*/
|
25 |
+
public function toOptionArray()
|
26 |
+
{
|
27 |
+
return array(
|
28 |
+
array('value' => 1, 'label'=>Mage::helper('authorizecim')->__('Yes')),
|
29 |
+
array('value' => 0, 'label'=>Mage::helper('authorizecim')->__('No')),
|
30 |
+
);
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
app/code/local/Sttl/Authorizecim/Model/Transaction.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Silver Touch Technologies Limited.
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
12 |
+
*
|
13 |
+
* @category Sttl
|
14 |
+
* @package Sttl_Authorizecim
|
15 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
16 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
17 |
+
*/
|
18 |
+
class Sttl_Authorizecim_Model_Transaction extends Mage_Core_Model_Abstract {
|
19 |
+
|
20 |
+
protected $_collection = null;
|
21 |
+
protected $_optionCollection = null;
|
22 |
+
protected static $_url = null;
|
23 |
+
|
24 |
+
public function _construct() {
|
25 |
+
parent::_construct();
|
26 |
+
$this->_init('authorizecim/transaction');
|
27 |
+
}
|
28 |
+
|
29 |
+
}
|
app/code/local/Sttl/Authorizecim/etc/config.xml
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Silver Touch Technologies Limited.
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
12 |
+
*
|
13 |
+
* @category Sttl
|
14 |
+
* @package Sttl_Authorizecim
|
15 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
16 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
17 |
+
*/
|
18 |
+
-->
|
19 |
+
<config>
|
20 |
+
<modules>
|
21 |
+
<Sttl_Authorizecim>
|
22 |
+
<version>1.0.2</version>
|
23 |
+
</Sttl_Authorizecim>
|
24 |
+
</modules>
|
25 |
+
<adminhtml>
|
26 |
+
<acl>
|
27 |
+
<resources>
|
28 |
+
<all>
|
29 |
+
<title>Allow Everything</title>
|
30 |
+
</all>
|
31 |
+
<admin>
|
32 |
+
<children>
|
33 |
+
<authorizecim>
|
34 |
+
<title>Authorize Module</title>
|
35 |
+
<sort_order>40</sort_order>
|
36 |
+
</authorizecim>
|
37 |
+
<system>
|
38 |
+
<children>
|
39 |
+
<config>
|
40 |
+
<children>
|
41 |
+
<authorizecim translate="title" module="authorizecim">
|
42 |
+
<title>Authorize Setting</title>
|
43 |
+
<sort_order>50</sort_order>
|
44 |
+
</authorizecim>
|
45 |
+
</children>
|
46 |
+
</config>
|
47 |
+
</children>
|
48 |
+
</system>
|
49 |
+
</children>
|
50 |
+
</admin>
|
51 |
+
</resources>
|
52 |
+
</acl>
|
53 |
+
</adminhtml>
|
54 |
+
<global>
|
55 |
+
<blocks>
|
56 |
+
<authorizecim>
|
57 |
+
<class>Sttl_Authorizecim_Block</class>
|
58 |
+
</authorizecim>
|
59 |
+
</blocks>
|
60 |
+
<models>
|
61 |
+
<authorizecim>
|
62 |
+
<class>Sttl_Authorizecim_Model</class>
|
63 |
+
<resourceModel>authorizecim_mysql4</resourceModel>
|
64 |
+
</authorizecim>
|
65 |
+
<authorizecim_mysql4>
|
66 |
+
<class>Sttl_Authorizecim_Model_Mysql4</class>
|
67 |
+
<entities>
|
68 |
+
<transaction>
|
69 |
+
<table>authorizecim_transaction</table>
|
70 |
+
</transaction>
|
71 |
+
</entities>
|
72 |
+
</authorizecim_mysql4>
|
73 |
+
</models>
|
74 |
+
<helpers>
|
75 |
+
<authorizecim>
|
76 |
+
<class>Sttl_Authorizecim_Helper</class>
|
77 |
+
</authorizecim>
|
78 |
+
</helpers>
|
79 |
+
<resources>
|
80 |
+
<authorizecim_setup>
|
81 |
+
<setup>
|
82 |
+
<module>Sttl_Authorizecim</module>
|
83 |
+
</setup>
|
84 |
+
<connection>
|
85 |
+
<use>core_setup</use>
|
86 |
+
</connection>
|
87 |
+
</authorizecim_setup>
|
88 |
+
<authorizecim_write>
|
89 |
+
<connection>
|
90 |
+
<use>core_write</use>
|
91 |
+
</connection>
|
92 |
+
</authorizecim_write>
|
93 |
+
<authorizecim_read>
|
94 |
+
<connection>
|
95 |
+
<use>core_read</use>
|
96 |
+
</connection>
|
97 |
+
</authorizecim_read>
|
98 |
+
</resources>
|
99 |
+
</global>
|
100 |
+
<default>
|
101 |
+
<payment>
|
102 |
+
<authorizecim>
|
103 |
+
<active>0</active>
|
104 |
+
<display_cc>1</display_cc>
|
105 |
+
<title>Credit Card (Authorize.net CIM)</title>
|
106 |
+
<model>authorizecim/payment</model>
|
107 |
+
<cctypes>AE,VI,MC,DI</cctypes>
|
108 |
+
<debug>0</debug>
|
109 |
+
<cgi_url>https://apitest.authorize.net/xml/v1/request.api</cgi_url>
|
110 |
+
<login backend_model="adminhtml/system_config_backend_encrypted"/>
|
111 |
+
<order_status>processing</order_status>
|
112 |
+
<payment_action>authorize</payment_action>
|
113 |
+
<trans_key backend_model="adminhtml/system_config_backend_encrypted"/>
|
114 |
+
<allowspecific>0</allowspecific>
|
115 |
+
<currency>USD</currency>
|
116 |
+
</authorizecim>
|
117 |
+
</payment>
|
118 |
+
</default>
|
119 |
+
</config>
|
app/code/local/Sttl/Authorizecim/etc/system.xml
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Silver Touch Technologies Limited.
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
12 |
+
*
|
13 |
+
* @category Sttl
|
14 |
+
* @package Sttl_Authorizecim
|
15 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
16 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
17 |
+
*/
|
18 |
+
-->
|
19 |
+
<config>
|
20 |
+
<sections>
|
21 |
+
<payment translate="label" module="authorizecim">
|
22 |
+
<groups>
|
23 |
+
<authorizecim translate="label">
|
24 |
+
<label>Authorize.net CIM</label>
|
25 |
+
<frontend_type>text</frontend_type>
|
26 |
+
<sort_order>1001</sort_order>
|
27 |
+
<show_in_default>1</show_in_default>
|
28 |
+
<show_in_website>0</show_in_website>
|
29 |
+
<show_in_store>0</show_in_store>
|
30 |
+
<fields>
|
31 |
+
<active translate="label">
|
32 |
+
<label>Authorize CIM Enable</label>
|
33 |
+
<frontend_type>select</frontend_type>
|
34 |
+
<source_model>authorizecim/system_config_source_yesno</source_model>
|
35 |
+
<sort_order>1</sort_order>
|
36 |
+
<show_in_default>1</show_in_default>
|
37 |
+
<show_in_website>1</show_in_website>
|
38 |
+
<show_in_store>1</show_in_store>
|
39 |
+
</active>
|
40 |
+
<display_cc translate="label">
|
41 |
+
<label>Display Old Cards</label>
|
42 |
+
<frontend_type>select</frontend_type>
|
43 |
+
<source_model>authorizecim/system_config_source_yesno</source_model>
|
44 |
+
<sort_order>5</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 |
+
</display_cc>
|
49 |
+
<use_guest translate="label">
|
50 |
+
<label>Use for Guest Users</label>
|
51 |
+
<frontend_type>select</frontend_type>
|
52 |
+
<source_model>authorizecim/system_config_source_yesno</source_model>
|
53 |
+
<sort_order>5</sort_order>
|
54 |
+
<show_in_default>1</show_in_default>
|
55 |
+
<show_in_website>1</show_in_website>
|
56 |
+
<show_in_store>1</show_in_store>
|
57 |
+
</use_guest>
|
58 |
+
<title translate="label">
|
59 |
+
<label>Title</label>
|
60 |
+
<frontend_type>text</frontend_type>
|
61 |
+
<sort_order>10</sort_order>
|
62 |
+
<show_in_default>1</show_in_default>
|
63 |
+
<show_in_website>1</show_in_website>
|
64 |
+
<show_in_store>1</show_in_store>
|
65 |
+
</title>
|
66 |
+
<login translate="label">
|
67 |
+
<label>API Login ID</label>
|
68 |
+
<frontend_type>obscure</frontend_type>
|
69 |
+
<backend_model>authorizecim/system_config_backend_encrypted</backend_model>
|
70 |
+
<sort_order>20</sort_order>
|
71 |
+
<show_in_default>1</show_in_default>
|
72 |
+
<show_in_website>1</show_in_website>
|
73 |
+
<show_in_store>1</show_in_store>
|
74 |
+
</login>
|
75 |
+
<trans_key translate="label">
|
76 |
+
<label>Transaction Key</label>
|
77 |
+
<frontend_type>obscure</frontend_type>
|
78 |
+
<backend_model>authorizecim/system_config_backend_encrypted</backend_model>
|
79 |
+
<sort_order>30</sort_order>
|
80 |
+
<show_in_default>1</show_in_default>
|
81 |
+
<show_in_website>1</show_in_website>
|
82 |
+
<show_in_store>1</show_in_store>
|
83 |
+
</trans_key>
|
84 |
+
<payment_action translate="label">
|
85 |
+
<label>Payment Action</label>
|
86 |
+
<frontend_type>select</frontend_type>
|
87 |
+
<source_model>authorizecim/system_config_source_paymentAction</source_model>
|
88 |
+
<sort_order>40</sort_order>
|
89 |
+
<show_in_default>1</show_in_default>
|
90 |
+
<show_in_website>1</show_in_website>
|
91 |
+
<show_in_store>0</show_in_store>
|
92 |
+
</payment_action>
|
93 |
+
<order_status translate="label">
|
94 |
+
<label>New Order Status</label>
|
95 |
+
<frontend_type>select</frontend_type>
|
96 |
+
<source_model>adminhtml/system_config_source_order_status_processing</source_model>
|
97 |
+
<sort_order>50</sort_order>
|
98 |
+
<show_in_default>1</show_in_default>
|
99 |
+
<show_in_website>1</show_in_website>
|
100 |
+
<show_in_store>0</show_in_store>
|
101 |
+
</order_status>
|
102 |
+
<cgi_url>
|
103 |
+
<label>Gateway URL</label>
|
104 |
+
<frontend_type>text</frontend_type>
|
105 |
+
<sort_order>70</sort_order>
|
106 |
+
<show_in_default>1</show_in_default>
|
107 |
+
<show_in_website>1</show_in_website>
|
108 |
+
<show_in_store>0</show_in_store>
|
109 |
+
</cgi_url>
|
110 |
+
<currency translate="label">
|
111 |
+
<label>Accepted Currency</label>
|
112 |
+
<frontend_type>select</frontend_type>
|
113 |
+
<source_model>adminhtml/system_config_source_currency</source_model>
|
114 |
+
<sort_order>80</sort_order>
|
115 |
+
<show_in_default>1</show_in_default>
|
116 |
+
<show_in_website>1</show_in_website>
|
117 |
+
<show_in_store>0</show_in_store>
|
118 |
+
</currency>
|
119 |
+
<debug translate="label">
|
120 |
+
<label>Debug</label>
|
121 |
+
<frontend_type>select</frontend_type>
|
122 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
123 |
+
<sort_order>90</sort_order>
|
124 |
+
<show_in_default>1</show_in_default>
|
125 |
+
<show_in_website>1</show_in_website>
|
126 |
+
<show_in_store>0</show_in_store>
|
127 |
+
</debug>
|
128 |
+
<cctypes translate="label">
|
129 |
+
<label>Credit Card Types</label>
|
130 |
+
<frontend_type>multiselect</frontend_type>
|
131 |
+
<source_model>authorizecim/system_config_source_cctype</source_model>
|
132 |
+
<sort_order>100</sort_order>
|
133 |
+
<show_in_default>1</show_in_default>
|
134 |
+
<show_in_website>1</show_in_website>
|
135 |
+
<show_in_store>0</show_in_store>
|
136 |
+
</cctypes>
|
137 |
+
<useccv translate="label">
|
138 |
+
<label>Credit Card Verification</label>
|
139 |
+
<frontend_type>select</frontend_type>
|
140 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
141 |
+
<sort_order>110</sort_order>
|
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 |
+
</useccv>
|
146 |
+
<allowspecific translate="label">
|
147 |
+
<label>Payment from Applicable Countries</label>
|
148 |
+
<frontend_type>allowspecific</frontend_type>
|
149 |
+
<sort_order>150</sort_order>
|
150 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
151 |
+
<show_in_default>1</show_in_default>
|
152 |
+
<show_in_website>1</show_in_website>
|
153 |
+
<show_in_store>0</show_in_store>
|
154 |
+
</allowspecific>
|
155 |
+
<specificcountry translate="label">
|
156 |
+
<label>Payment from Specific Countries</label>
|
157 |
+
<frontend_type>multiselect</frontend_type>
|
158 |
+
<sort_order>160</sort_order>
|
159 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
160 |
+
<show_in_default>1</show_in_default>
|
161 |
+
<show_in_website>1</show_in_website>
|
162 |
+
<show_in_store>0</show_in_store>
|
163 |
+
</specificcountry>
|
164 |
+
<min_order_total translate="label">
|
165 |
+
<label>Minimum Order Total</label>
|
166 |
+
<frontend_type>text</frontend_type>
|
167 |
+
<sort_order>170</sort_order>
|
168 |
+
<show_in_default>1</show_in_default>
|
169 |
+
<show_in_website>1</show_in_website>
|
170 |
+
<show_in_store>0</show_in_store>
|
171 |
+
</min_order_total>
|
172 |
+
<max_order_total translate="label">
|
173 |
+
<label>Maximum Order Total</label>
|
174 |
+
<frontend_type>text</frontend_type>
|
175 |
+
<sort_order>180</sort_order>
|
176 |
+
<show_in_default>1</show_in_default>
|
177 |
+
<show_in_website>1</show_in_website>
|
178 |
+
<show_in_store>0</show_in_store>
|
179 |
+
</max_order_total>
|
180 |
+
<sort_order translate="label">
|
181 |
+
<label>Sort Order</label>
|
182 |
+
<frontend_type>text</frontend_type>
|
183 |
+
<sort_order>200</sort_order>
|
184 |
+
<show_in_default>1</show_in_default>
|
185 |
+
<show_in_website>1</show_in_website>
|
186 |
+
<show_in_store>0</show_in_store>
|
187 |
+
</sort_order>
|
188 |
+
</fields>
|
189 |
+
</authorizecim>
|
190 |
+
</groups>
|
191 |
+
</payment>
|
192 |
+
</sections>
|
193 |
+
</config>
|
app/code/local/Sttl/Authorizecim/sql/authorizecim_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Silver Touch Technologies Limited.
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
12 |
+
*
|
13 |
+
* @category Sttl
|
14 |
+
* @package Sttl_Authorizecim
|
15 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
16 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
17 |
+
*/
|
18 |
+
$installer = $this;
|
19 |
+
|
20 |
+
$installer->startSetup();
|
21 |
+
$installer->run("
|
22 |
+
CREATE TABLE {$this->getTable('authorizecim/transaction')} (
|
23 |
+
`authorize_id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
24 |
+
`email` VARCHAR( 50 ) NOT NULL,
|
25 |
+
`order_id` INT( 11 ) NOT NULL ,
|
26 |
+
`order_payment_id` INT( 11 ) NOT NULL ,
|
27 |
+
`profile_id` double NOT NULL ,
|
28 |
+
`payment_id` double NOT NULL ,
|
29 |
+
`shipping_id` double NOT NULL ,
|
30 |
+
`txn_id` double NOT NULL ,
|
31 |
+
`response` TEXT NOT NULL ,
|
32 |
+
`created` DATETIME NOT NULL
|
33 |
+
) ENGINE = innodb;
|
34 |
+
");
|
35 |
+
|
36 |
+
$installer->endSetup();
|
37 |
+
?>
|
app/code/local/Sttl/Authorizecim/sql/authorizecim_setup/mysql4-upgrade-1.0.0-1.0.1.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Silver Touch Technologies Limited.
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
12 |
+
*
|
13 |
+
* @category Sttl
|
14 |
+
* @package Sttl_Authorizecim
|
15 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
16 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
17 |
+
*/
|
18 |
+
$installer = $this;
|
19 |
+
|
20 |
+
$installer->startSetup();
|
21 |
+
$installer->run("ALTER TABLE {$this->getTable('authorizecim/transaction')} ADD COLUMN `cclast4` VARCHAR(50) NULL;");
|
22 |
+
$installer->run("ALTER TABLE {$this->getTable('authorizecim/transaction')} ADD COLUMN `card_type` VARCHAR(50) NULL;");
|
23 |
+
$installer->endSetup();
|
24 |
+
?>
|
app/design/adminhtml/default/default/template/authorizecim/form/cim.phtml
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php $_code=$this->getMethodCode() ?>
|
28 |
+
<ul id="payment_form_<?php echo $_code ?>" style="display:none">
|
29 |
+
<li>
|
30 |
+
<div class="input-box">
|
31 |
+
<label for="<?php echo $_code ?>_cc_type"><?php echo Mage::helper('payment')->__('Credit Card Type') ?> <span class="required">*</span></label><br/>
|
32 |
+
<select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
|
33 |
+
<?php $_ccType = $this->getInfoData('cc_type') ?>
|
34 |
+
<option value=""></option>
|
35 |
+
<?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
|
36 |
+
<option value="<?php echo $_typeCode ?>" <?php if($_typeCode==$_ccType): ?>selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
|
37 |
+
<?php endforeach ?>
|
38 |
+
</select>
|
39 |
+
</div>
|
40 |
+
</li>
|
41 |
+
<li>
|
42 |
+
<div class="input-box">
|
43 |
+
<label for="<?php echo $_code ?>_cc_number"><?php echo Mage::helper('payment')->__('Credit Card Number') ?> <span class="required">*</span></label><br/>
|
44 |
+
<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')?>"/>
|
45 |
+
</div>
|
46 |
+
</li>
|
47 |
+
<li>
|
48 |
+
<div class="input-box">
|
49 |
+
<label for="<?php echo $_code ?>_expiration"><?php echo Mage::helper('payment')->__('Expiration Date') ?> <span class="required">*</span></label><br/>
|
50 |
+
<select id="<?php echo $_code ?>_expiration" style="width:140px;" name="payment[cc_exp_month]" class="validate-cc-exp required-entry">
|
51 |
+
<?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
|
52 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
53 |
+
<option value="<?php echo $k ?>" <?php if($k==$_ccExpMonth): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
|
54 |
+
<?php endforeach ?>
|
55 |
+
</select>
|
56 |
+
<?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
|
57 |
+
<select id="<?php echo $_code ?>_expiration_yr" style="width:103px;" name="payment[cc_exp_year]" class="required-entry">
|
58 |
+
<?php foreach ($this->getCcYears() as $k=>$v): ?>
|
59 |
+
<option value="<?php echo $k ? $k : '' ?>" <?php if($k==$_ccExpYear): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
|
60 |
+
<?php endforeach ?>
|
61 |
+
</select>
|
62 |
+
</div>
|
63 |
+
</li>
|
64 |
+
<?php if($this->hasVerification()): ?>
|
65 |
+
<li>
|
66 |
+
<div class="input-box">
|
67 |
+
<label for="<?php echo $_code ?>_cc_cid"><?php echo Mage::helper('payment')->__('Card Verification Number') ?> <span class="required">*</span></label><br/>
|
68 |
+
<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')?>"/>
|
69 |
+
</div>
|
70 |
+
</li>
|
71 |
+
<?php endif; ?>
|
72 |
+
|
73 |
+
<?php if ($this->hasSsCardType()): ?>
|
74 |
+
<li id="<?php echo $_code ?>_cc_type_ss_div">
|
75 |
+
<ul class="inner-form">
|
76 |
+
<li class="form-alt"><label for="<?php echo $_code ?>_cc_issue" class="required"><em>*</em><?php echo $this->__('Switch/Solo/Maestro Only') ?></label></li>
|
77 |
+
<li>
|
78 |
+
<label for="<?php echo $_code ?>_cc_issue"><?php echo $this->__('Issue Number') ?>:</label>
|
79 |
+
<span class="input-box">
|
80 |
+
<input type="text" title="<?php echo $this->__('Issue Number') ?>" class="input-text validate-cc-ukss cvv" id="<?php echo $_code ?>_cc_issue" name="payment[cc_ss_issue]" value="" />
|
81 |
+
</span>
|
82 |
+
</li>
|
83 |
+
|
84 |
+
<li>
|
85 |
+
<label for="<?php echo $_code ?>_start_month"><?php echo $this->__('Start Date') ?>:</label>
|
86 |
+
<div class="input-box">
|
87 |
+
<select id="<?php echo $_code ?>_start_month" name="payment[cc_ss_start_month]" class="validate-cc-ukss month">
|
88 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
89 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$this->getInfoData('cc_ss_start_month')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
90 |
+
<?php endforeach ?>
|
91 |
+
</select>
|
92 |
+
<select id="<?php echo $_code ?>_start_year" name="payment[cc_ss_start_year]" class="validate-cc-ukss year">
|
93 |
+
<?php foreach ($this->getSsStartYears() as $k=>$v): ?>
|
94 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$this->getInfoData('cc_ss_start_year')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
95 |
+
<?php endforeach ?>
|
96 |
+
</select>
|
97 |
+
</div>
|
98 |
+
</li>
|
99 |
+
<li class="adv-container"> </li>
|
100 |
+
</ul>
|
101 |
+
<script type="text/javascript">
|
102 |
+
//<![CDATA[
|
103 |
+
var SSChecked<?php echo $_code ?> = function() {
|
104 |
+
var elm = $('<?php echo $_code ?>_cc_type');
|
105 |
+
if (['SS','SM','SO'].indexOf(elm.value) != -1) {
|
106 |
+
$('<?php echo $_code ?>_cc_type_ss_div').show();
|
107 |
+
} else {
|
108 |
+
$('<?php echo $_code ?>_cc_type_ss_div').hide();
|
109 |
+
}
|
110 |
+
};
|
111 |
+
Event.observe($('<?php echo $_code ?>_cc_type'), 'change', SSChecked<?php echo $_code ?>);
|
112 |
+
SSChecked<?php echo $_code ?>();
|
113 |
+
//]]>
|
114 |
+
</script>
|
115 |
+
</li>
|
116 |
+
<?php endif; ?>
|
117 |
+
</ul>
|
app/design/adminhtml/default/default/template/authorizecim/form/cim_1.phtml
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silver Touch Technologies Limited.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
11 |
+
*
|
12 |
+
* @category Sttl
|
13 |
+
* @package Sttl_Authorizecim
|
14 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
15 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
16 |
+
*/
|
17 |
+
|
18 |
+
?>
|
19 |
+
<?php $_code=$this->getMethodCode() ?>
|
20 |
+
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
|
21 |
+
<?php if(Mage::helper('authorizecim')->displayOldCard()):
|
22 |
+
$cards = $this->getOldCreditCard();
|
23 |
+
if(!empty($cards)):?>
|
24 |
+
<li>
|
25 |
+
<label for="cim_payment_profileid" ><?php echo $this->__('Use Old Credit Card') ?></label>
|
26 |
+
<div class="input-box">
|
27 |
+
<select id="cim_payment_profileid" name="payment[cim_payment_profileid]" class="cc-select" onChange="usecreditcard(this.value)">
|
28 |
+
<option value=""><?php echo $this->__('--Please Select--')?></option>
|
29 |
+
<?php foreach ($cards as $_typeCode => $_typeName): ?>
|
30 |
+
<option value="<?php echo $_typeName['value'] ?>"<?php /*if($_typeName['value']==$_ccType): ?> selected="selected"<?php endif*/ ?>><?php echo $_typeName['label'] ?></option>
|
31 |
+
<?php endforeach ?>
|
32 |
+
</select>
|
33 |
+
</div>
|
34 |
+
</li>
|
35 |
+
<li>
|
36 |
+
</li>
|
37 |
+
<?php endif; ?>
|
38 |
+
<?php endif; ?>
|
39 |
+
<li>
|
40 |
+
<ul id="authorizecim_form">
|
41 |
+
<li>
|
42 |
+
<label for="<?php echo $_code ?>_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
|
43 |
+
<div class="input-box">
|
44 |
+
<select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
|
45 |
+
<option value=""><?php echo $this->__('--Please Select--')?></option>
|
46 |
+
<?php $_ccType = $this->getInfoData('cc_type') ?>
|
47 |
+
<?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
|
48 |
+
<option value="<?php echo $_typeCode ?>"<?php /*if($_typeCode==$_ccType): ?> selected="selected"<?php endif*/ ?>><?php echo $_typeName ?></option>
|
49 |
+
<?php endforeach ?>
|
50 |
+
</select>
|
51 |
+
</div>
|
52 |
+
</li>
|
53 |
+
<li>
|
54 |
+
<label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
|
55 |
+
<div class="input-box">
|
56 |
+
<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="" />
|
57 |
+
</div>
|
58 |
+
</li>
|
59 |
+
<li id="<?php echo $_code ?>_cc_type_exp_div">
|
60 |
+
<label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
|
61 |
+
<div class="input-box">
|
62 |
+
<div class="v-fix">
|
63 |
+
<select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
|
64 |
+
<?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
|
65 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
66 |
+
<option value="<?php echo $k?$k:'' ?>"<?php /*if($k==$_ccExpMonth): ?> selected="selected"<?php endif*/ ?>><?php echo $v ?></option>
|
67 |
+
<?php endforeach ?>
|
68 |
+
</select>
|
69 |
+
</div>
|
70 |
+
<div class="v-fix">
|
71 |
+
<?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
|
72 |
+
<select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
|
73 |
+
<?php foreach ($this->getCcYears() as $k=>$v): ?>
|
74 |
+
<option value="<?php echo $k?$k:'' ?>"<?php /*if($k==$_ccExpYear): ?> selected="selected"<?php endif*/ ?>><?php echo $v ?></option>
|
75 |
+
<?php endforeach ?>
|
76 |
+
</select>
|
77 |
+
</div>
|
78 |
+
</div>
|
79 |
+
</li>
|
80 |
+
<?php echo $this->getChildHtml() ?>
|
81 |
+
<?php if($this->hasVerification()): ?>
|
82 |
+
<li id="<?php echo $_code ?>_cc_type_cvv_div">
|
83 |
+
<label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
|
84 |
+
|
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->hasSsCardType()): ?>
|
94 |
+
<li id="<?php echo $_code ?>_cc_type_ss_div">
|
95 |
+
<ul class="inner-form">
|
96 |
+
<li class="form-alt"><label for="<?php echo $_code ?>_cc_issue" class="required"><em>*</em><?php echo $this->__('Switch/Solo/Maestro Only') ?></label></li>
|
97 |
+
<li>
|
98 |
+
<label for="<?php echo $_code ?>_cc_issue"><?php echo $this->__('Issue Number') ?>:</label>
|
99 |
+
<span class="input-box">
|
100 |
+
<input type="text" title="<?php echo $this->__('Issue Number') ?>" class="input-text validate-cc-ukss cvv" id="<?php echo $_code ?>_cc_issue" name="payment[cc_ss_issue]" value="" />
|
101 |
+
</span>
|
102 |
+
</li>
|
103 |
+
<li>
|
104 |
+
<label for="<?php echo $_code ?>_start_month"><?php echo $this->__('Start Date') ?>:</label>
|
105 |
+
<div class="input-box">
|
106 |
+
<div class="v-fix">
|
107 |
+
<select id="<?php echo $_code ?>_start_month" name="payment[cc_ss_start_month]" class="validate-cc-ukss month">
|
108 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
109 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$this->getInfoData('cc_ss_start_month')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
110 |
+
<?php endforeach ?>
|
111 |
+
</select>
|
112 |
+
</div>
|
113 |
+
<div class="v-fix">
|
114 |
+
<select id="<?php echo $_code ?>_start_year" name="payment[cc_ss_start_year]" class="validate-cc-ukss year">
|
115 |
+
<?php foreach ($this->getSsStartYears() as $k=>$v): ?>
|
116 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$this->getInfoData('cc_ss_start_year')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
117 |
+
<?php endforeach ?>
|
118 |
+
</select>
|
119 |
+
</div>
|
120 |
+
</div>
|
121 |
+
</li>
|
122 |
+
<li class="adv-container"> </li>
|
123 |
+
</ul>
|
124 |
+
</ul>
|
125 |
+
</li>
|
126 |
+
<script type="text/javascript">
|
127 |
+
//<![CDATA[
|
128 |
+
var SSChecked<?php echo $_code ?> = function() {
|
129 |
+
var elm = $('<?php echo $_code ?>_cc_type');
|
130 |
+
if (['SS','SM','SO'].indexOf(elm.value) != -1) {
|
131 |
+
$('<?php echo $_code ?>_cc_type_ss_div').show();
|
132 |
+
} else {
|
133 |
+
$('<?php echo $_code ?>_cc_type_ss_div').hide();
|
134 |
+
}
|
135 |
+
};
|
136 |
+
|
137 |
+
Event.observe($('<?php echo $_code ?>_cc_type'), 'change', SSChecked<?php echo $_code ?>);
|
138 |
+
SSChecked<?php echo $_code ?>();
|
139 |
+
//]]>
|
140 |
+
</script>
|
141 |
+
</li>
|
142 |
+
<?php endif; ?>
|
143 |
+
<script type="text/javascript">
|
144 |
+
usecreditcard = function(value) {
|
145 |
+
|
146 |
+
if (value != "") {
|
147 |
+
$('authorizecim_form').hide();
|
148 |
+
|
149 |
+
$('<?php echo $_code ?>_cc_type').addClassName('required-entry validate-cc-type-select');
|
150 |
+
$('<?php echo $_code ?>_cc_number').addClassName('validate-cc-number validate-cc-type');
|
151 |
+
$('<?php echo $_code ?>_expiration').addClassName('required-entry');
|
152 |
+
$('<?php echo $_code ?>_expiration_yr').addClassName('required-entry');
|
153 |
+
} else {
|
154 |
+
|
155 |
+
$('authorizecim_form').show();
|
156 |
+
$('<?php echo $_code ?>_cc_type').removeClassName('required-entry validate-cc-type-select');
|
157 |
+
$('<?php echo $_code ?>_cc_number').removeClassName('validate-cc-number validate-cc-type');
|
158 |
+
$('<?php echo $_code ?>_expiration').removeClassName('required-entry');
|
159 |
+
$('<?php echo $_code ?>_expiration_yr').removeClassName('required-entry');
|
160 |
+
}
|
161 |
+
};
|
162 |
+
</script>
|
163 |
+
</ul>
|
app/design/frontend/base/default/template/authorizecim/form/cim.phtml
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silver Touch Technologies Limited.
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
11 |
+
*
|
12 |
+
* @category Sttl
|
13 |
+
* @package Sttl_Authorizecim
|
14 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
15 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
16 |
+
*/
|
17 |
+
?>
|
18 |
+
<?php $_code = $this->getMethodCode() ?>
|
19 |
+
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
|
20 |
+
<?php
|
21 |
+
$hasCards = false;
|
22 |
+
if ($this->helper('authorizecim')->displayOldCard()):
|
23 |
+
$cards = $this->getOldCreditCard();
|
24 |
+
if (!empty($cards)): $hasCards = true;
|
25 |
+
?>
|
26 |
+
<li>
|
27 |
+
<label for="cim_payment_profileid" ><?php echo $this->__('Use Saved Cards') ?></label>
|
28 |
+
<div class="input-box">
|
29 |
+
<select id="cim_payment_profileid" name="payment[cim_payment_profileid]" class="cc-select" onChange="usecreditcard(this.value)">
|
30 |
+
<option value=""><?php echo $this->__('--Please Select--') ?></option>
|
31 |
+
<?php foreach ($cards as $_typeCode => $_typeName): ?>
|
32 |
+
<option value="<?php echo $_typeName['value'] ?>"<?php /* if($_typeName['value']==$_ccType): ?> selected="selected"<?php endif */ ?>><?php echo $_typeName['label'] ?></option>
|
33 |
+
<?php endforeach ?>
|
34 |
+
</select>
|
35 |
+
</div>
|
36 |
+
</li>
|
37 |
+
<?php endif; ?>
|
38 |
+
<?php endif; ?>
|
39 |
+
<li>
|
40 |
+
<ul id="authorizecim_form"<?php echo ($hasCards ? ' style="margin-top: 15px;"' : ''); ?>>
|
41 |
+
<li>
|
42 |
+
<label for="<?php echo $_code ?>_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
|
43 |
+
<div class="input-box">
|
44 |
+
<select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
|
45 |
+
<option value=""><?php echo $this->__('--Please Select--') ?></option>
|
46 |
+
<?php $_ccType = $this->getInfoData('cc_type') ?>
|
47 |
+
<?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
|
48 |
+
<option value="<?php echo $_typeCode ?>"<?php if ($_typeCode == $_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
|
49 |
+
<?php endforeach ?>
|
50 |
+
</select>
|
51 |
+
</div>
|
52 |
+
</li>
|
53 |
+
<li>
|
54 |
+
<label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
|
55 |
+
<div class="input-box">
|
56 |
+
<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="" />
|
57 |
+
</div>
|
58 |
+
</li>
|
59 |
+
<li id="<?php echo $_code ?>_cc_type_exp_div">
|
60 |
+
<label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
|
61 |
+
<div class="input-box">
|
62 |
+
<div class="v-fix">
|
63 |
+
<select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
|
64 |
+
<?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
|
65 |
+
<?php foreach ($this->getCcMonths() as $k => $v): ?>
|
66 |
+
<option value="<?php echo $k ? $k : '' ?>"<?php /* if($k==$_ccExpMonth): ?> selected="selected"<?php endif */ ?>><?php echo $v ?></option>
|
67 |
+
<?php endforeach ?>
|
68 |
+
</select>
|
69 |
+
</div>
|
70 |
+
<div class="v-fix">
|
71 |
+
<?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
|
72 |
+
<select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
|
73 |
+
<?php foreach ($this->getCcYears() as $k => $v): ?>
|
74 |
+
<option value="<?php echo $k ? $k : '' ?>"<?php /* if($k==$_ccExpYear): ?> selected="selected"<?php endif */ ?>><?php echo $v ?></option>
|
75 |
+
<?php endforeach ?>
|
76 |
+
</select>
|
77 |
+
</div>
|
78 |
+
</div>
|
79 |
+
</li>
|
80 |
+
<?php echo $this->getChildHtml() ?>
|
81 |
+
<?php if ($this->hasVerification()): ?>
|
82 |
+
<li id="<?php echo $_code ?>_cc_type_cvv_div">
|
83 |
+
<label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
|
84 |
+
|
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->hasSsCardType()): ?>
|
94 |
+
<li id="<?php echo $_code ?>_cc_type_ss_div">
|
95 |
+
<ul class="inner-form">
|
96 |
+
<li class="form-alt"><label for="<?php echo $_code ?>_cc_issue" class="required"><em>*</em><?php echo $this->__('Switch/Solo/Maestro Only') ?></label></li>
|
97 |
+
<li>
|
98 |
+
<label for="<?php echo $_code ?>_cc_issue"><?php echo $this->__('Issue Number') ?>:</label>
|
99 |
+
<span class="input-box">
|
100 |
+
<input type="text" title="<?php echo $this->__('Issue Number') ?>" class="input-text validate-cc-ukss cvv" id="<?php echo $_code ?>_cc_issue" name="payment[cc_ss_issue]" value="" />
|
101 |
+
</span>
|
102 |
+
</li>
|
103 |
+
<li>
|
104 |
+
<label for="<?php echo $_code ?>_start_month"><?php echo $this->__('Start Date') ?>:</label>
|
105 |
+
<div class="input-box">
|
106 |
+
<div class="v-fix">
|
107 |
+
<select id="<?php echo $_code ?>_start_month" name="payment[cc_ss_start_month]" class="validate-cc-ukss month">
|
108 |
+
<?php foreach ($this->getCcMonths() as $k => $v): ?>
|
109 |
+
<option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $this->getInfoData('cc_ss_start_month')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
110 |
+
<?php endforeach ?>
|
111 |
+
</select>
|
112 |
+
</div>
|
113 |
+
<div class="v-fix">
|
114 |
+
<select id="<?php echo $_code ?>_start_year" name="payment[cc_ss_start_year]" class="validate-cc-ukss year">
|
115 |
+
<?php foreach ($this->getSsStartYears() as $k => $v): ?>
|
116 |
+
<option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $this->getInfoData('cc_ss_start_year')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
117 |
+
<?php endforeach ?>
|
118 |
+
</select>
|
119 |
+
</div>
|
120 |
+
</div>
|
121 |
+
</li>
|
122 |
+
<li class="adv-container"> </li>
|
123 |
+
</ul>
|
124 |
+
</li>
|
125 |
+
</ul>
|
126 |
+
</li>
|
127 |
+
<script type="text/javascript">
|
128 |
+
//<![CDATA[
|
129 |
+
var SSChecked<?php echo $_code ?> = function() {
|
130 |
+
var elm = $('<?php echo $_code ?>_cc_type');
|
131 |
+
if (['SS', 'SM', 'SO'].indexOf(elm.value) != -1) {
|
132 |
+
$('<?php echo $_code ?>_cc_type_ss_div').show();
|
133 |
+
} else {
|
134 |
+
$('<?php echo $_code ?>_cc_type_ss_div').hide();
|
135 |
+
}
|
136 |
+
};
|
137 |
+
|
138 |
+
Event.observe($('<?php echo $_code ?>_cc_type'), 'change', SSChecked<?php echo $_code ?>);
|
139 |
+
SSChecked<?php echo $_code ?>();
|
140 |
+
//]]>
|
141 |
+
</script>
|
142 |
+
</li>
|
143 |
+
<?php endif; ?>
|
144 |
+
</ul>
|
145 |
+
<?php if ($hasCards): ?>
|
146 |
+
<script type="text/javascript">
|
147 |
+
//<![CDATA[
|
148 |
+
Event.observe($("cim_payment_profileid"), 'change', function() {
|
149 |
+
var val = $("cim_payment_profileid").value;
|
150 |
+
usecreditcard(val);
|
151 |
+
});
|
152 |
+
usecreditcard = function(value) {
|
153 |
+
if (value !== "") {
|
154 |
+
$('authorizecim_form').hide();
|
155 |
+
$('<?php echo $_code ?>_cc_type').addClassName('required-entry validate-cc-type-select');
|
156 |
+
$('<?php echo $_code ?>_cc_number').addClassName('validate-cc-number validate-cc-type');
|
157 |
+
$('<?php echo $_code ?>_expiration').addClassName('required-entry');
|
158 |
+
$('<?php echo $_code ?>_expiration_yr').addClassName('required-entry');
|
159 |
+
} else {
|
160 |
+
$('authorizecim_form').show();
|
161 |
+
$('<?php echo $_code ?>_cc_type').removeClassName('required-entry validate-cc-type-select');
|
162 |
+
$('<?php echo $_code ?>_cc_number').removeClassName('validate-cc-number validate-cc-type');
|
163 |
+
$('<?php echo $_code ?>_expiration').removeClassName('required-entry');
|
164 |
+
$('<?php echo $_code ?>_expiration_yr').removeClassName('required-entry');
|
165 |
+
}
|
166 |
+
}
|
167 |
+
//]]>
|
168 |
+
</script>
|
169 |
+
<?php endif; ?>
|
app/etc/modules/Sttl_Authorizecim.xml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Silver Touch Technologies Limited.
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
12 |
+
*
|
13 |
+
* @category Sttl
|
14 |
+
* @package Sttl_Authorizecim
|
15 |
+
* @copyright Copyright (c) 2011 Silver Touch Technologies Limited. (http://www.silvertouch.com/MagentoExtensions)
|
16 |
+
* @license http://www.silvertouch.com/MagentoExtensions/LICENSE.txt
|
17 |
+
*/ -->
|
18 |
+
<config>
|
19 |
+
<modules>
|
20 |
+
<Sttl_Authorizecim>
|
21 |
+
<active>true</active>
|
22 |
+
<codePool>local</codePool>
|
23 |
+
<depends>
|
24 |
+
<Mage_Payment/>
|
25 |
+
</depends>
|
26 |
+
</Sttl_Authorizecim>
|
27 |
+
</modules>
|
28 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Sttl_Authorizecim</name>
|
4 |
+
<version>1.0.2</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.extension.silvertouch.com/licence">STTL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Store Customer information on Authorize.net Secure Servers. The method is PCI compliant.</summary>
|
10 |
+
<description> The extension does not store CVV information and is thus PCI Compliant.
|
11 |
+
All credit card related sensitive information will be saved on the Authorize.net secure servers. This makes your website completely SAFE and PCI compliant.
|
12 |
+
A unique transaction ID will be created with each order. Using this transaction ID, we can capture payment, make refund and partial refund.
|
13 |
+
Place orders through the Magento back end using the module and get payments in realtime.
|
14 |
+
Enable/Disable the saved credit card details feature. If it is enabled, customer entered CC details will be automatically stored once the transaction is complete.
|
15 |
+
The stored Credit Card details are displayed to customers in DROP DOWN to select any one at time of second payment.
|
16 |
+
Split invoices or Multiple Invoices can also be generated for a single order.</description>
|
17 |
+
<notes>Store Customer information on Authorize.net Secure Servers. The method is PCI compliant.</notes>
|
18 |
+
<authors><author><name>Silvertouch</name><user>silvertouch</user><email>magento@silvertouch.com</email></author></authors>
|
19 |
+
<date>2014-11-27</date>
|
20 |
+
<time>07:01:45</time>
|
21 |
+
<contents><target name="magelocal"><dir name="Sttl"><dir name="Authorizecim"><dir name="Block"><dir name="Form"><file name="Cim.php" hash="780bb66cabad486addb3b33ef3976849"/></dir><dir name="Info"><file name="Cim.php" hash="29ce6bab73d82dd737222995ec684c7c"/></dir></dir><dir name="Helper"><file name="Data.php" hash="eac908b6e9796b06b46ef430213a1d25"/></dir><dir name="Model"><file name="Api.php" hash="249bd438b1a250f024a4fc8d27278727"/><dir name="Mysql4"><dir name="Transaction"><file name="Collection.php" hash="5ad3dcb791519bfccc34be021fb68572"/></dir><file name="Transaction.php" hash="48fea4dff97f25044ec4a7160fcad446"/></dir><file name="Payment.php" hash="1154efaefabdd467bcaccd79d25b8f80"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Encrypted.php" hash="386fac227eb4d2b27fa607c41a5901b8"/></dir><dir name="Source"><file name="Cctype.php" hash="da072261358e593ccf948ec213677f75"/><file name="Method.php" hash="62c3344c8161b192e237c3cda332557c"/><file name="PaymentAction.php" hash="c73dce91da2f91c3280880ac2d077fe7"/><file name="Yesno.php" hash="82d3d861803882979dd3939b287ff1d6"/></dir></dir></dir><file name="Transaction.php" hash="4bcc439d13e7d49403e2db9f37e53032"/></dir><dir name="etc"><file name="config.xml" hash="cd1edb5e96a8b766e4d35048e84a8ce6"/><file name="system.xml" hash="7656f0b87fca83f0b7f6505a04d6e24d"/></dir><dir name="sql"><dir name="authorizecim_setup"><file name="mysql4-install-1.0.0.php" hash="d77cb5dd3de267977121e5e2a778fbab"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="22793c1493f3cc6f454d75b34c401bd8"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sttl_Authorizecim.xml" hash="3ac020daad6c9ed617f11c0a15e146c8"/></dir></target><target name="mage"><dir name="."><file name="SILVER_AuthorizeCIM-User_Guide-V.1.0.1.doc" hash="96cd6725fb4804e48862fb9d372b9a4f"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="authorizecim"><dir name="form"><file name="cim.phtml" hash="90230d3f5d218bde9935d8a2fda6b600"/><file name="cim_1.phtml" hash="41eb14bfb9f3fbd0b79b4d22c0cb51a8"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="authorizecim"><dir name="form"><file name="cim.phtml" hash="62aa593c1c31ced3f5c2507940e2ce9c"/></dir></dir></dir></dir></dir></dir></target></contents>
|
22 |
+
<compatible/>
|
23 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
24 |
+
</package>
|