Version Notes
Last updated on 03/01/2014
Download this release
Release Info
Developer | CyoGate Merchant Solutions |
Extension | CyoGate_17x |
Version | 1.7.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.7.0.1 to 1.7.0.2
- app/code/local/GatewayProcessingServices/ThreeStep/Block/Payment/Form.php +67 -0
- app/code/local/GatewayProcessingServices/ThreeStep/Block/Payment/Iframe.php +51 -0
- app/code/local/GatewayProcessingServices/ThreeStep/Helper/Data.php +175 -0
- app/code/local/GatewayProcessingServices/ThreeStep/Model/Observer.php +93 -0
- app/code/local/GatewayProcessingServices/ThreeStep/Model/PaymentMethod.php +493 -0
- app/code/local/GatewayProcessingServices/ThreeStep/Model/Request.php +64 -0
- app/code/local/GatewayProcessingServices/ThreeStep/Model/Session.php +67 -0
- app/code/local/GatewayProcessingServices/ThreeStep/controllers/Adminhtml/PaymentController.php +215 -0
- app/code/local/GatewayProcessingServices/ThreeStep/controllers/PaymentController.php +184 -0
- app/code/local/GatewayProcessingServices/ThreeStep/etc/config.xml +113 -0
- app/code/local/GatewayProcessingServices/ThreeStep/etc/system.xml +152 -0
- app/design/adminhtml/default/default/layout/threestep.xml +9 -0
- app/design/frontend/base/default/layout/threestep.xml +18 -0
- app/design/frontend/default/default/template/threestep/payment/form.phtml +111 -0
- app/design/frontend/default/default/template/threestep/payment/iframe.phtml +25 -0
- app/design/frontend/default/default/template/threestep/payment/info.phtml +5 -0
- app/etc/modules/GatewayProcessingServices_ThreeStep.xml +15 -0
- package.xml +3 -3
app/code/local/GatewayProcessingServices/ThreeStep/Block/Payment/Form.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ThreeStep form block
|
4 |
+
*
|
5 |
+
* @category Local
|
6 |
+
* @package GatewayProcessingServices_ThreeStep
|
7 |
+
* @author GPS
|
8 |
+
*/
|
9 |
+
class GatewayProcessingServices_ThreeStep_Block_Payment_Form extends Mage_Payment_Block_Form_Cc
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Internal constructor
|
13 |
+
* Set info template for payment step
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
protected function _construct() {
|
17 |
+
|
18 |
+
parent::_construct();
|
19 |
+
$this->setTemplate('threestep/payment/info.phtml');
|
20 |
+
$this->setTemplate('../../../default/default/template/threestep/payment/info.phtml');
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Render block HTML
|
25 |
+
* If method is not threestep - nothing to return
|
26 |
+
*
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
protected function _toHtml()
|
30 |
+
{
|
31 |
+
if ($this->getMethod()->getCode() != Mage::getSingleton('threestep/PaymentMethod')->getCode()) {
|
32 |
+
return null;
|
33 |
+
}
|
34 |
+
|
35 |
+
return parent::_toHtml();
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Set method info
|
40 |
+
*
|
41 |
+
* @return GatewayProcessingServices_ThreeStep_Block_Payment_Form
|
42 |
+
*/
|
43 |
+
public function setMethodInfo()
|
44 |
+
{
|
45 |
+
$payment = Mage::getSingleton('checkout/type_onepage')
|
46 |
+
->getQuote()
|
47 |
+
->getPayment();
|
48 |
+
$this->setMethod($payment->getMethodInstance());
|
49 |
+
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Get type of request
|
55 |
+
*
|
56 |
+
* @return bool
|
57 |
+
*/
|
58 |
+
public function isAjaxRequest()
|
59 |
+
{
|
60 |
+
return $this->getAction()
|
61 |
+
->getRequest()
|
62 |
+
->getParam('isAjax');
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
?>
|
app/code/local/GatewayProcessingServices/ThreeStep/Block/Payment/Iframe.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* ThreeStep iframe block
|
5 |
+
*
|
6 |
+
* @category Local
|
7 |
+
* @package GatewayProcessingServices_ThreeStep
|
8 |
+
* @author GPS
|
9 |
+
*/
|
10 |
+
class GatewayProcessingServices_ThreeStep_Block_Payment_Iframe extends Mage_Core_Block_Template
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Request params
|
14 |
+
* @var array
|
15 |
+
*/
|
16 |
+
protected $_params = array();
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Internal constructor
|
20 |
+
* Set template for iframe
|
21 |
+
*
|
22 |
+
*/
|
23 |
+
protected function _construct()
|
24 |
+
{
|
25 |
+
parent::_construct();
|
26 |
+
$this->setTemplate('threestep/payment/iframe.phtml');
|
27 |
+
$this->setTemplate('../../../default/default/template/threestep/payment/iframe.phtml');
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Set output params
|
32 |
+
*
|
33 |
+
* @param array $params
|
34 |
+
* @return GatewayProcessingServices_ThreeStep_Block_Payment_Iframe
|
35 |
+
*/
|
36 |
+
public function setParams($params)
|
37 |
+
{
|
38 |
+
$this->_params = $params;
|
39 |
+
return $this;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Get params
|
44 |
+
*
|
45 |
+
* @return array
|
46 |
+
*/
|
47 |
+
public function getParams()
|
48 |
+
{
|
49 |
+
return $this->_params;
|
50 |
+
}
|
51 |
+
}
|
app/code/local/GatewayProcessingServices/ThreeStep/Helper/Data.php
ADDED
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* ThreeStep Data Helper
|
6 |
+
*
|
7 |
+
* @category Local
|
8 |
+
* @package GatewayProcessingServices_ThreeStep
|
9 |
+
* @author GPS
|
10 |
+
*/
|
11 |
+
class GatewayProcessingServices_ThreeStep_Helper_Data extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Return URL for admin area
|
15 |
+
*
|
16 |
+
* @param string $route
|
17 |
+
* @param array $params
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function getAdminUrl($route, $params) {
|
21 |
+
return Mage::getModel('adminhtml/url')->getUrl($route, $params);
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _getUrl($route,$params = array()) {
|
25 |
+
$params['_type'] = Mage_Core_Model_Store::URL_TYPE_LINK;
|
26 |
+
if (isset($params['is_secure'])) {
|
27 |
+
$params['_secure'] = (bool)$params['is_secure'];
|
28 |
+
} elseif (Mage::app()->getStore()->isCurrentlySecure()) {
|
29 |
+
$params['_secure'] = true;
|
30 |
+
}
|
31 |
+
|
32 |
+
return parent::_getUrl($route, $params);
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Retrieve place order url on front
|
39 |
+
*
|
40 |
+
* @return string
|
41 |
+
*/
|
42 |
+
public function getPlaceOrderFrontUrl()
|
43 |
+
{
|
44 |
+
return $this->_getUrl('threestep/payment/place');
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Get controller name
|
49 |
+
*
|
50 |
+
* @return string
|
51 |
+
*/
|
52 |
+
public function getControllerName()
|
53 |
+
{
|
54 |
+
return Mage::app()->getFrontController()->getRequest()->getControllerName();
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Retrieve save order url params
|
59 |
+
*
|
60 |
+
* @param string $controller
|
61 |
+
* @return array
|
62 |
+
*/
|
63 |
+
public function getSaveOrderUrlParams($controller)
|
64 |
+
{
|
65 |
+
$route = array();
|
66 |
+
switch ($controller) {
|
67 |
+
case 'onepage':
|
68 |
+
$route['action'] = 'saveOrder';
|
69 |
+
$route['controller'] = 'onepage';
|
70 |
+
$route['module'] = 'checkout';
|
71 |
+
break;
|
72 |
+
|
73 |
+
case 'sales_order_create':
|
74 |
+
case 'sales_order_edit':
|
75 |
+
$route['action'] = 'save';
|
76 |
+
$route['controller'] = 'sales_order_create';
|
77 |
+
$route['module'] = 'admin';
|
78 |
+
break;
|
79 |
+
|
80 |
+
default:
|
81 |
+
break;
|
82 |
+
}
|
83 |
+
|
84 |
+
return $route;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Retrieve redirect iframe url
|
89 |
+
*
|
90 |
+
* @param array params
|
91 |
+
* @return string
|
92 |
+
*/
|
93 |
+
public function getRedirectIframeUrl($params)
|
94 |
+
{
|
95 |
+
|
96 |
+
switch ($params['controller_action_name']) {
|
97 |
+
case 'onepage':
|
98 |
+
$route = 'threestep/payment/redirect';
|
99 |
+
break;
|
100 |
+
|
101 |
+
case 'admin':
|
102 |
+
$route = 'adminhtml/payment/redirect';
|
103 |
+
break;
|
104 |
+
|
105 |
+
default:
|
106 |
+
$route = 'threestep/payment/redirect';
|
107 |
+
break;
|
108 |
+
}
|
109 |
+
return $this->_getUrl($route,$params);
|
110 |
+
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Retrieve place order url
|
115 |
+
*
|
116 |
+
* @param array params
|
117 |
+
* @return string
|
118 |
+
*/
|
119 |
+
public function getSuccessOrderUrl($params)
|
120 |
+
{
|
121 |
+
$param = array();
|
122 |
+
switch ($params['controller_action_name']) {
|
123 |
+
case 'onepage':
|
124 |
+
$route = 'checkout/onepage/success';
|
125 |
+
break;
|
126 |
+
|
127 |
+
case 'admin':
|
128 |
+
$route = 'adminhtml/sales_order/view';
|
129 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($params['order_id']);
|
130 |
+
$param['order_id'] = $order->getId();
|
131 |
+
return $this->getAdminUrl($route, $param);
|
132 |
+
|
133 |
+
default :
|
134 |
+
$route = 'checkout/onepage/success';
|
135 |
+
break;
|
136 |
+
}
|
137 |
+
|
138 |
+
return $this->_getUrl($route, $param);
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Retrieve place order url in admin
|
143 |
+
*
|
144 |
+
* @return string
|
145 |
+
*/
|
146 |
+
public function getPlaceOrderAdminUrl()
|
147 |
+
{
|
148 |
+
return $this->getAdminUrl('*/payment/place', array());
|
149 |
+
}
|
150 |
+
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Update all child and parent order's edit increment numbers.
|
154 |
+
* Needed for Admin area.
|
155 |
+
*
|
156 |
+
* @param Mage_Sales_Model_Order $order
|
157 |
+
*/
|
158 |
+
public function updateOrderEditIncrements(Mage_Sales_Model_Order $order)
|
159 |
+
{
|
160 |
+
if ($order->getId() && $order->getOriginalIncrementId()) {
|
161 |
+
$collection = $order->getCollection();
|
162 |
+
$quotedIncrId = $collection->getConnection()->quote($order->getOriginalIncrementId());
|
163 |
+
$collection->getSelect()->where(
|
164 |
+
"original_increment_id = {$quotedIncrId} OR increment_id = {$quotedIncrId}"
|
165 |
+
);
|
166 |
+
|
167 |
+
foreach ($collection as $orderToUpdate) {
|
168 |
+
$orderToUpdate->setEditIncrement($order->getEditIncrement());
|
169 |
+
$orderToUpdate->save();
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
?>
|
app/code/local/GatewayProcessingServices/ThreeStep/Model/Observer.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ThreeStep payment observer
|
4 |
+
*
|
5 |
+
* @category Local
|
6 |
+
* @package GatewayProcessingServices_ThreeStep
|
7 |
+
* @author GPS
|
8 |
+
*/
|
9 |
+
class GatewayProcessingServices_ThreeStep_Model_Observer
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Save order into registry to use it in the overloaded controller.
|
13 |
+
*
|
14 |
+
* @param Varien_Event_Observer $observer
|
15 |
+
* @return GatewayProcessingServices_ThreeStep_Model_Observer
|
16 |
+
*/
|
17 |
+
public function saveOrderAfterSubmit(Varien_Event_Observer $observer)
|
18 |
+
{
|
19 |
+
/* @var $order Mage_Sales_Model_Order */
|
20 |
+
$order = $observer->getEvent()->getData('order');
|
21 |
+
Mage::register('threestep_order', $order, true);
|
22 |
+
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Set data for response of frontend saveOrder action
|
28 |
+
*
|
29 |
+
* @param Varien_Event_Observer $observer
|
30 |
+
* @return GatewayProcessingServices_ThreeStep_Model_Observer
|
31 |
+
*/
|
32 |
+
public function addAdditionalFieldsToResponseFrontend(Varien_Event_Observer $observer)
|
33 |
+
{
|
34 |
+
$order = $observer->getEvent()->getData('order');
|
35 |
+
$order = Mage::registry('threestep_order');
|
36 |
+
|
37 |
+
if ($order && $order->getId()) {
|
38 |
+
|
39 |
+
$payment = $order->getPayment();
|
40 |
+
if ($payment && $payment->getMethod() == Mage::getModel('threestep/PaymentMethod')->getCode()) {
|
41 |
+
|
42 |
+
$controller = $observer->getEvent()->getData('controller_action');
|
43 |
+
$result = Mage::helper('core')->jsonDecode(
|
44 |
+
$controller->getResponse()->getBody('default'),
|
45 |
+
Zend_Json::TYPE_ARRAY
|
46 |
+
);
|
47 |
+
|
48 |
+
if (empty($result['error'])) {
|
49 |
+
|
50 |
+
$order->setControllerActionName($controller->getRequest()->getControllerName());
|
51 |
+
|
52 |
+
$payment = $order->getPayment();
|
53 |
+
//if success, then set order to session and add new fields
|
54 |
+
$session = Mage::getSingleton('threestep/session');
|
55 |
+
$session->addCheckoutOrderIncrementId($order->getIncrementId());
|
56 |
+
$session->setLastOrderIncrementId($order->getIncrementId());
|
57 |
+
|
58 |
+
$requestToPaygate = $payment->getMethodInstance()->generateRequestFromOrder($order);
|
59 |
+
$requestToPaygate->setIsSecure((string)Mage::app()->getStore()->isCurrentlySecure());
|
60 |
+
|
61 |
+
$threestep = Mage::getModel('threestep/paymentmethod');
|
62 |
+
|
63 |
+
// Submit Step one
|
64 |
+
$formUrl = $threestep->doStepOne($requestToPaygate->getData());
|
65 |
+
$result['formUrl'] = $formUrl;
|
66 |
+
|
67 |
+
$result['threestep'] = array('fields' => $requestToPaygate->getData());
|
68 |
+
|
69 |
+
$controller->getResponse()->clearHeader('Location');
|
70 |
+
$controller->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
return $this;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Update all edit increments for all orders if module is enabled.
|
80 |
+
* Needed for correct work of edit orders in Admin area.
|
81 |
+
*
|
82 |
+
* @param Varien_Event_Observer $observer
|
83 |
+
* @return GatewayProcessingServices_ThreeStep_Model_Observer
|
84 |
+
*/
|
85 |
+
public function updateAllEditIncrements(Varien_Event_Observer $observer)
|
86 |
+
{
|
87 |
+
/* @var $order Mage_Sales_Model_Order */
|
88 |
+
$order = $observer->getEvent()->getData('order');
|
89 |
+
Mage::helper('threestep')->updateOrderEditIncrements($order);
|
90 |
+
|
91 |
+
return $this;
|
92 |
+
}
|
93 |
+
}
|
app/code/local/GatewayProcessingServices/ThreeStep/Model/PaymentMethod.php
ADDED
@@ -0,0 +1,493 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ThreeStep payment method model.
|
4 |
+
*
|
5 |
+
* @category Local
|
6 |
+
* @package GatewayProcessingServices_ThreeStep
|
7 |
+
* @author GPS
|
8 |
+
*/
|
9 |
+
class GatewayProcessingServices_ThreeStep_Model_PaymentMethod extends Mage_Payment_Model_Method_Cc
|
10 |
+
{
|
11 |
+
|
12 |
+
// The following flags determine functionality of the module to be used by frontend and backend
|
13 |
+
// All flags can be found in Mage_Payment_Model_Method_Abstract
|
14 |
+
|
15 |
+
protected $_code = 'threestep';
|
16 |
+
protected $_isGateway = true;
|
17 |
+
protected $_canAuthorize = true;
|
18 |
+
protected $_canCapture = true;
|
19 |
+
protected $_canCapturePartial = false;
|
20 |
+
protected $_canRefund = true;
|
21 |
+
protected $_canRefundInvoicePartial = true;
|
22 |
+
protected $_canVoid = true;
|
23 |
+
protected $_canUseInternal = true;
|
24 |
+
protected $_canUseCheckout = true;
|
25 |
+
protected $_canUseForMultishipping = false;
|
26 |
+
protected $_canSaveCC = false;
|
27 |
+
protected $_formBlockType = 'threestep/payment_form';
|
28 |
+
protected $_isInitializeNeeded = true;
|
29 |
+
protected $_infoBlockType = 'payment/info';
|
30 |
+
|
31 |
+
private $_gatewayURL = 'https://secure.cyogate.net/api/v2/three-step';
|
32 |
+
private $_gatewayQueryURL = 'https://secure.cyogate.net/api/query.php';
|
33 |
+
|
34 |
+
public $formURL = 'defaultURL';
|
35 |
+
public $token = '';
|
36 |
+
private $_APIKey;
|
37 |
+
private $_testAPIKey = '2F822Rw39fx762MaV7Yy86jXGTC7sCDy';
|
38 |
+
|
39 |
+
public function __construct()
|
40 |
+
{
|
41 |
+
$this->_APIKey = $this->getConfigData('api-key');
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Do not validate payment form using server methods
|
46 |
+
*
|
47 |
+
* @return bool
|
48 |
+
*/
|
49 |
+
public function validate() {
|
50 |
+
return true;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Skips the normal authorization process
|
55 |
+
*
|
56 |
+
*/
|
57 |
+
public function authorize(Varien_Object $payment, $amount)
|
58 |
+
{
|
59 |
+
$payment->setAdditionalInformation('payment_type', $this->getConfigData('payment_action'));
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Send capture request to gateway
|
64 |
+
*
|
65 |
+
*/
|
66 |
+
public function capture(Varien_Object $payment, $amount) {
|
67 |
+
|
68 |
+
$originalType = $payment->getAdditionalInformation('payment_type');
|
69 |
+
|
70 |
+
$testMode = $this->getConfigData('test_mode');
|
71 |
+
|
72 |
+
if ($originalType == 'authorize_capture') {
|
73 |
+
|
74 |
+
$payment->setAdditionalInformation('payment_type', $this->getConfigData('payment_action'));
|
75 |
+
} else {
|
76 |
+
$info = $payment->getTransactionId();
|
77 |
+
$transId = $info;
|
78 |
+
|
79 |
+
$orderId = $payment->getOrder()->getIncrementId();
|
80 |
+
|
81 |
+
$xmlRequest = new DOMDocument('1.0','UTF-8');
|
82 |
+
$xmlRequest->formatOutput = true;
|
83 |
+
$xmlCapture = $xmlRequest->createElement('capture');
|
84 |
+
|
85 |
+
if ($testMode) {
|
86 |
+
$this->appendXmlNode($xmlCapture,'api-key',$this->_testAPIKey);
|
87 |
+
} else {
|
88 |
+
$this->appendXmlNode($xmlCapture,'api-key',$this->_APIKey);
|
89 |
+
}
|
90 |
+
$this->appendXmlNode($xmlCapture,'transaction-id',$transId);
|
91 |
+
$this->appendXmlNode($xmlCapture,'amount',$amount);
|
92 |
+
$this->appendXmlNode($xmlCapture,'order-id',$orderId);
|
93 |
+
$xmlRequest->appendChild($xmlCapture);
|
94 |
+
$data = $this->sendXMLviaCurl($xmlRequest, $this->_gatewayURL);
|
95 |
+
|
96 |
+
$gwResponse = @new SimpleXMLElement((string)$data);
|
97 |
+
|
98 |
+
if ((string)$gwResponse->result == 1) {
|
99 |
+
$payment->setTransactionId((string)$gwResponse->{('transaction-id')});
|
100 |
+
$payment->setAdditionalInformation('transaction-id',(string)$gwResponse->{('transaction-id')});
|
101 |
+
$payment->setIsTransactionClosed(0);
|
102 |
+
return $this;
|
103 |
+
} else {
|
104 |
+
Mage::throwException('Transaction Declined: ' . (string)$gwResponse->{('result-text')});
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Refund the amount
|
111 |
+
*
|
112 |
+
* @param Varien_Object $payment
|
113 |
+
* @param decimal $amount
|
114 |
+
* @return GatewayProcessingServices_ThreeStep_Model_PaymentMethod
|
115 |
+
* @throws Mage_Core_Exception
|
116 |
+
*/
|
117 |
+
public function refund(Varien_Object $payment, $amount) {
|
118 |
+
|
119 |
+
$info = $payment->getAdditionalInformation();
|
120 |
+
$transId = $info['transaction-id'];
|
121 |
+
|
122 |
+
$testMode = $this->getConfigData('test_mode');
|
123 |
+
|
124 |
+
$xmlRequest = new DOMDocument('1.0','UTF-8');
|
125 |
+
$xmlRequest->formatOutput = true;
|
126 |
+
$xmlRefund = $xmlRequest->createElement('refund');
|
127 |
+
|
128 |
+
if ($testMode) {
|
129 |
+
$this->appendXmlNode($xmlRefund,'api-key',$this->_testAPIKey);
|
130 |
+
} else {
|
131 |
+
$this->appendXmlNode($xmlRefund,'api-key',$this->_APIKey);
|
132 |
+
}
|
133 |
+
$this->appendXmlNode($xmlRefund,'transaction-id',$transId);
|
134 |
+
$this->appendXmlNode($xmlRefund,'amount',$amount);
|
135 |
+
$xmlRequest->appendChild($xmlRefund);
|
136 |
+
$data = $this->sendXMLviaCurl($xmlRequest, $this->_gatewayURL);
|
137 |
+
|
138 |
+
$gwResponse = @new SimpleXMLElement((string)$data);
|
139 |
+
|
140 |
+
if ((string)$gwResponse->result == 1) {
|
141 |
+
$payment->setData('is_transaction_closed',1);
|
142 |
+
return $this;
|
143 |
+
} else {
|
144 |
+
Mage::throwException('Refund Failed: ' . (string)$gwResponse->{('result-text')});
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Void the payment through gateway
|
150 |
+
*
|
151 |
+
* @param Varien_Object $payment
|
152 |
+
* @return GatewayProcessingServices_ThreeStep_Model_PaymentMethod
|
153 |
+
* @throws Mage_Core_Exception
|
154 |
+
*/
|
155 |
+
public function void(Varien_Object $payment) {
|
156 |
+
|
157 |
+
$info = $payment->getAdditionalInformation();
|
158 |
+
$transId = $info['transaction-id'];
|
159 |
+
|
160 |
+
$testMode = $this->getConfigData('test_mode');
|
161 |
+
|
162 |
+
$xmlRequest = new DOMDocument('1.0','UTF-8');
|
163 |
+
$xmlRequest->formatOutput = true;
|
164 |
+
$xmlVoid = $xmlRequest->createElement('void');
|
165 |
+
if ($testMode) {
|
166 |
+
$this->appendXmlNode($xmlVoid,'api-key',$this->_testAPIKey);
|
167 |
+
} else {
|
168 |
+
$this->appendXmlNode($xmlVoid,'api-key',$this->_APIKey);
|
169 |
+
}
|
170 |
+
$this->appendXmlNode($xmlVoid,'transaction-id',$transId);
|
171 |
+
$xmlRequest->appendChild($xmlVoid);
|
172 |
+
$data = $this->sendXMLviaCurl($xmlRequest, $this->_gatewayURL);
|
173 |
+
|
174 |
+
$gwResponse = @new SimpleXMLElement((string)$data);
|
175 |
+
|
176 |
+
if ((string)$gwResponse->result == 1) {
|
177 |
+
$payment->setData('is_transaction_closed', 1);
|
178 |
+
$payment->setData('should_close_parent_transaction', 1);
|
179 |
+
return $this;
|
180 |
+
} else {
|
181 |
+
Mage::throwException('Void Failed: ' . (string)$gwResponse->{('result-text')});
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
public function cancel(Varien_Object $payment)
|
186 |
+
{
|
187 |
+
return $this->void($payment);
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Send Step 1 to GPS
|
192 |
+
*
|
193 |
+
* @param Array $infoArr
|
194 |
+
* @param unknown_type $orderData
|
195 |
+
* @return unknown
|
196 |
+
*/
|
197 |
+
public function doStepOne($infoArr) {
|
198 |
+
|
199 |
+
$testMode = $this->getConfigData('test_mode');
|
200 |
+
$type = $this->getConfigData('payment_action');
|
201 |
+
|
202 |
+
if ($type == 'authorize') {
|
203 |
+
$type = 'auth';
|
204 |
+
} else {
|
205 |
+
$type = 'sale';
|
206 |
+
}
|
207 |
+
|
208 |
+
$xmlRequest = new DOMDocument('1.0','UTF-8');
|
209 |
+
$xmlRequest->formatOutput = true;
|
210 |
+
|
211 |
+
$xmlTranType = $xmlRequest->createElement($type);
|
212 |
+
|
213 |
+
// Api Key
|
214 |
+
if ($testMode) {
|
215 |
+
$this->appendXmlNode($xmlTranType,'api-key',$this->_testAPIKey);
|
216 |
+
} else {
|
217 |
+
$this->appendXmlNode($xmlTranType, 'api-key', $this->_APIKey);
|
218 |
+
}
|
219 |
+
|
220 |
+
// Redirect URL
|
221 |
+
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
222 |
+
$redirectUrl = $this->getRelayUrl();
|
223 |
+
$urlVars = '?order_id=' . $infoArr['order_id'] . '&order_send_flag=' . $infoArr['order_send_confirmation'] . '&key=' . $infoArr['key'] . '&controller=' . $infoArr['controller_action_name'];
|
224 |
+
$redirectUrl .= htmlentities($urlVars);
|
225 |
+
$this->appendXmlNode($xmlTranType, 'redirect-url', $redirectUrl);
|
226 |
+
|
227 |
+
// Transaction Information
|
228 |
+
$this->appendXmlNode($xmlTranType, 'amount', $infoArr['amount']);
|
229 |
+
$this->appendXmlNode($xmlTranType, 'currency', $infoArr['currency']);
|
230 |
+
$this->appendXmlNode($xmlTranType, 'tax-amount', $infoArr['tax_amount']);
|
231 |
+
$this->appendXmlNode($xmlTranType, 'shipping-amount', $infoArr['shipping_amount']);
|
232 |
+
$this->appendXmlNode($xmlTranType, 'order-id', $infoArr['order_id']);
|
233 |
+
$this->appendXmlNode($xmlTranType, 'ip-address', $infoArr['ip_address']);
|
234 |
+
|
235 |
+
// Billing Information
|
236 |
+
$xmlBillingAddress = $xmlRequest->createElement('billing');
|
237 |
+
$this->appendXmlNode($xmlBillingAddress, 'first-name', $infoArr['billing_first_name']);
|
238 |
+
$this->appendXmlNode($xmlBillingAddress, 'last-name', $infoArr['billing_last_name']);
|
239 |
+
$this->appendXmlNode($xmlBillingAddress, 'address1', $infoArr['billing_address1']);
|
240 |
+
$this->appendXmlNode($xmlBillingAddress, 'address2', $infoArr['billing_address2']);
|
241 |
+
$this->appendXmlNode($xmlBillingAddress, 'city', $infoArr['billing_city']);
|
242 |
+
$this->appendXmlNode($xmlBillingAddress, 'state', $infoArr['billing_state']);
|
243 |
+
$this->appendXmlNode($xmlBillingAddress, 'postal', $infoArr['billing_postal']);
|
244 |
+
$this->appendXmlNode($xmlBillingAddress, 'country', $infoArr['billing_country']);
|
245 |
+
$this->appendXmlNode($xmlBillingAddress, 'phone', $infoArr['billing_phone']);
|
246 |
+
$this->appendXmlNode($xmlBillingAddress, 'email', $infoArr['billing_email']);
|
247 |
+
$this->appendXmlNode($xmlBillingAddress, 'company', $infoArr['billing_company']);
|
248 |
+
$this->appendXmlNode($xmlBillingAddress, 'fax', $infoArr['billing_fax']);
|
249 |
+
$xmlTranType->appendChild($xmlBillingAddress);
|
250 |
+
|
251 |
+
// Shipping Information
|
252 |
+
$xmlShippingAddress = $xmlRequest->createElement('shipping');
|
253 |
+
$this->appendXmlNode($xmlShippingAddress, 'first-name', $infoArr['shipping_first_name']);
|
254 |
+
$this->appendXmlNode($xmlShippingAddress, 'last-name', $infoArr['shipping_last_name']);
|
255 |
+
$this->appendXmlNode($xmlShippingAddress, 'address1', $infoArr['shipping_address1']);
|
256 |
+
$this->appendXmlNode($xmlShippingAddress, 'address2', $infoArr['shipping_address2']);
|
257 |
+
$this->appendXmlNode($xmlShippingAddress, 'city', $infoArr['shipping_city']);
|
258 |
+
$this->appendXmlNode($xmlShippingAddress, 'state', $infoArr['shipping_state']);
|
259 |
+
$this->appendXmlNode($xmlShippingAddress, 'postal', $infoArr['shipping_postal']);
|
260 |
+
$this->appendXmlNode($xmlShippingAddress, 'country', $infoArr['shipping_country']);
|
261 |
+
$this->appendXmlNode($xmlShippingAddress, 'company', $infoArr['shipping_company']);
|
262 |
+
$xmlTranType->appendChild($xmlShippingAddress);
|
263 |
+
|
264 |
+
$xmlRequest->appendChild($xmlTranType);
|
265 |
+
|
266 |
+
$data = $this->sendXMLviaCurl($xmlRequest,$this->_gatewayURL);
|
267 |
+
|
268 |
+
$gwResponse = @new SimpleXMLElement($data);
|
269 |
+
|
270 |
+
if ((string)$gwResponse->result == 1) {
|
271 |
+
$payment = Mage::getSingleton('checkout/session')->getQuote()->getPayment();
|
272 |
+
$payment->setAdditionalInformation('transaction-id',(string)$gwResponse->{('transaction-id')});
|
273 |
+
$formURL = $gwResponse->{'form-url'};
|
274 |
+
} else {
|
275 |
+
Mage::throwException('Error, received ' . $data);
|
276 |
+
}
|
277 |
+
return $formURL;
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* XML helper to attach child nodes
|
282 |
+
*/
|
283 |
+
public function appendXmlNode($parentNode,$name, $value) {
|
284 |
+
$tempNode = new DOMElement($name,$value);
|
285 |
+
$parentNode->appendChild($tempNode);
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Submit XML to GPS
|
290 |
+
*
|
291 |
+
*/
|
292 |
+
public function sendXMLviaCurl($xmlRequest,$gatewayURL) {
|
293 |
+
|
294 |
+
$ch = curl_init();
|
295 |
+
curl_setopt($ch, CURLOPT_URL, $gatewayURL);
|
296 |
+
|
297 |
+
$headers = array();
|
298 |
+
$headers[] = "Content-type: text/xml";
|
299 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
300 |
+
$xmlString = $xmlRequest->saveXML();
|
301 |
+
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
|
302 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
303 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
304 |
+
curl_setopt($ch, CURLOPT_PORT, 443);
|
305 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
306 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
307 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlString);
|
308 |
+
|
309 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
310 |
+
|
311 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
312 |
+
|
313 |
+
if (!($data = curl_exec($ch))) {
|
314 |
+
Mage::throwException(" CURL ERROR :" . curl_error($ch));
|
315 |
+
}
|
316 |
+
curl_close($ch);
|
317 |
+
|
318 |
+
return $data;
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Generate request object and fill its fields from Quote or Order object
|
323 |
+
*
|
324 |
+
* @param Mage_Core_Model_Abstract $entity Quote or order object.
|
325 |
+
* @return GatewayProcessingServices_ThreeStep_Model_Request
|
326 |
+
*/
|
327 |
+
public function generateRequestFromOrder(Mage_Sales_Model_Order $order)
|
328 |
+
{
|
329 |
+
$request = $this->_getRequestModel();
|
330 |
+
$request->setDataFromOrder($order, $this);
|
331 |
+
|
332 |
+
$this->_debug(array('request' => $request->getData()));
|
333 |
+
|
334 |
+
return $request;
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Return request model for form data building
|
339 |
+
*
|
340 |
+
* @return GatewayProcessingServices_ThreeStep_Model_Request
|
341 |
+
*/
|
342 |
+
protected function _getRequestModel()
|
343 |
+
{
|
344 |
+
return Mage::getModel('threestep/request');
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Return URL on which GPS will return payment result data in hidden request.
|
349 |
+
*
|
350 |
+
* @param int $storeId
|
351 |
+
* @return string
|
352 |
+
*/
|
353 |
+
public function getRelayUrl($storeId = null)
|
354 |
+
{
|
355 |
+
if ($storeId == null && $this->getStore()) {
|
356 |
+
$storeId = $this->getStore();
|
357 |
+
}
|
358 |
+
return Mage::app()->getStore($storeId)
|
359 |
+
->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, Mage::app()->getStore()->isCurrentlySecure()).
|
360 |
+
'threestep/payment/response';
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Operate with order using data from $_GET which came from GPS by Redirect URL.
|
365 |
+
*
|
366 |
+
* @param array $responseData data from GPS from $_GET
|
367 |
+
* @throws Mage_Core_Exception in case of validation error or order creation error
|
368 |
+
*/
|
369 |
+
public function process($info)
|
370 |
+
{
|
371 |
+
$orderIncrementId = $info['order_id'];
|
372 |
+
$token = $info['token'];
|
373 |
+
|
374 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
375 |
+
$payment = $order->getPayment();
|
376 |
+
|
377 |
+
$xmlRequest = new DOMDocument('1.0','UTF-8');
|
378 |
+
$xmlRequest->formatOutput = true;
|
379 |
+
$xmlCompleteTransaction = $xmlRequest->createElement('complete-action');
|
380 |
+
|
381 |
+
$testMode = $this->getConfigData('test_mode');
|
382 |
+
|
383 |
+
if ($testMode) {
|
384 |
+
$this->appendXmlNode($xmlCompleteTransaction,'api-key',$this->_testAPIKey);
|
385 |
+
} else {
|
386 |
+
$this->appendXmlNode($xmlCompleteTransaction,'api-key',$this->_APIKey);
|
387 |
+
}
|
388 |
+
|
389 |
+
$this->appendXmlNode($xmlCompleteTransaction,'token-id',$token);
|
390 |
+
$xmlRequest->appendChild($xmlCompleteTransaction);
|
391 |
+
$data = $this->sendXmlviaCurl($xmlRequest,$this->_gatewayURL);
|
392 |
+
|
393 |
+
$gwResponse = @new SimpleXMLElement((string)$data);
|
394 |
+
if ((string)$gwResponse->result == 1) {
|
395 |
+
$payment->setTransactionId((string)$gwResponse->{('transaction-id')});
|
396 |
+
$payment->setIsTransactionClosed(0);
|
397 |
+
$payment->setParentTransactionId(null);
|
398 |
+
$payment->setAdditionalInformation('transaction-id',(string)$gwResponse->{('transaction-id')});
|
399 |
+
|
400 |
+
// Create the transaction within shopping cart
|
401 |
+
if ($this->getConfigData('payment_action') == 'authorize') {
|
402 |
+
$payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
|
403 |
+
} else {
|
404 |
+
$payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
405 |
+
}
|
406 |
+
|
407 |
+
$message = Mage::helper('threestep')->__(
|
408 |
+
'Amount of %s approved by payment gateway. Transaction ID: "%s".',
|
409 |
+
$order->getBaseCurrency()->formatTxt($payment->getBaseAmountAuthorized()),
|
410 |
+
(string)$gwResponse->{('transaction-id')}
|
411 |
+
);
|
412 |
+
|
413 |
+
$orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
|
414 |
+
$orderStatus = $this->getConfigData('order_status');
|
415 |
+
if (!$orderStatus || $order->getIsVirtual()) {
|
416 |
+
$orderStatus = $order->getConfig()->getStateDefaultStatus($orderState);
|
417 |
+
}
|
418 |
+
|
419 |
+
$order->setState($orderState, $orderStatus ? $orderStatus : true, $message, false)
|
420 |
+
->save();
|
421 |
+
|
422 |
+
if ($payment->getAdditionalInformation('payment_type') == self::ACTION_AUTHORIZE_CAPTURE) {
|
423 |
+
try {
|
424 |
+
$payment->setTransactionId(null)
|
425 |
+
->setParentTransactionId((string)$gwResponse->{('transaction-id')})
|
426 |
+
->capture(null);
|
427 |
+
|
428 |
+
// set status from config for AUTH_AND_CAPTURE orders.
|
429 |
+
if ($order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING) {
|
430 |
+
$orderStatus = $this->getConfigData('order_status');
|
431 |
+
if (!$orderStatus || $order->getIsVirtual()) {
|
432 |
+
$orderStatus = $order->getConfig()
|
433 |
+
->getStateDefaultStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
|
434 |
+
}
|
435 |
+
if ($orderStatus) {
|
436 |
+
$order->setStatus($orderStatus);
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
$order->save();
|
441 |
+
} catch (Exception $e) {
|
442 |
+
Mage::logException($e);
|
443 |
+
}
|
444 |
+
}
|
445 |
+
// Send Order Confirmations
|
446 |
+
try {
|
447 |
+
if ($info['orderSendConfirmation'] === '' || $info['orderSendConfirmation'] == '1') {
|
448 |
+
$order->sendNewOrderEmail();
|
449 |
+
}
|
450 |
+
|
451 |
+
Mage::getModel('sales/quote')
|
452 |
+
->load($order->getQuoteId())
|
453 |
+
->setIsActive(false)
|
454 |
+
->save();
|
455 |
+
} catch (Exception $e) {
|
456 |
+
} // do not cancel order if we couldn't send email
|
457 |
+
} else {
|
458 |
+
Mage::throwException('Transaction Declined: ' . (string)$gwResponse->{('result-text')});
|
459 |
+
}
|
460 |
+
}
|
461 |
+
|
462 |
+
/**
|
463 |
+
* Instantiate state and set it to state object
|
464 |
+
*
|
465 |
+
* @param string $paymentAction
|
466 |
+
* @param Varien_Object
|
467 |
+
*/
|
468 |
+
public function initialize($paymentAction, $stateObject)
|
469 |
+
{
|
470 |
+
switch ($paymentAction) {
|
471 |
+
case self::ACTION_AUTHORIZE:
|
472 |
+
case self::ACTION_AUTHORIZE_CAPTURE:
|
473 |
+
$payment = $this->getInfoInstance();
|
474 |
+
$order = $payment->getOrder();
|
475 |
+
$order->setCanSendNewEmailFlag(false);
|
476 |
+
$payment->authorize(true, $order->getBaseTotalDue());
|
477 |
+
$payment->setAmountAuthorized($order->getTotalDue());
|
478 |
+
|
479 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, 'pending_payment', '', false);
|
480 |
+
|
481 |
+
$stateObject->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
482 |
+
$stateObject->setStatus('pending_payment');
|
483 |
+
$stateObject->setIsNotified(false);
|
484 |
+
break;
|
485 |
+
default:
|
486 |
+
break;
|
487 |
+
}
|
488 |
+
}
|
489 |
+
|
490 |
+
|
491 |
+
}
|
492 |
+
|
493 |
+
?>
|
app/code/local/GatewayProcessingServices/ThreeStep/Model/Request.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* ThreeStep request model.
|
5 |
+
*
|
6 |
+
* @category Local
|
7 |
+
* @package GatewayProcessingServices_ThreeStep
|
8 |
+
* @author GPS
|
9 |
+
*/
|
10 |
+
class GatewayProcessingServices_ThreeStep_Model_Request extends Varien_Object
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Set entity data to request
|
14 |
+
*
|
15 |
+
* @param Mage_Sales_Model_Order $order
|
16 |
+
* @param GatewayProcessingServices_ThreeStep_Model_PaymentMethod $paymentMethod
|
17 |
+
* @return GatewayProcessingServices_ThreeStep_Model_Request
|
18 |
+
*/
|
19 |
+
public function setDataFromOrder(Mage_Sales_Model_Order $order, GatewayProcessingServices_ThreeStep_Model_PaymentMethod $paymentMethod)
|
20 |
+
{
|
21 |
+
$payment = $order->getPayment();
|
22 |
+
$this->setOrderSendConfirmation($order->getSendConfirmationFlag());
|
23 |
+
$this->setOrderId($order->getIncrementId());
|
24 |
+
$this->setKey($order->getKey());
|
25 |
+
$this->setControllerActionName($order->getControllerActionName());
|
26 |
+
$this->setAmount($payment->getBaseAmountAuthorized());
|
27 |
+
$this->setCurrency($order->getBaseCurrencyCode());
|
28 |
+
$this->setTaxAmount(sprintf('%.2F', $order->getBaseTaxAmount()))
|
29 |
+
->setShippingAmount(sprintf('%.2F', $order->getBaseShippingAmount()));
|
30 |
+
|
31 |
+
$billing = $order->getBillingAddress();
|
32 |
+
if (!empty($billing)) {
|
33 |
+
$this->setBillingFirstName(strval($billing->getFirstname()))
|
34 |
+
->setBillingLastName(strval($billing->getLastname()))
|
35 |
+
->setBillingCompany(strval($billing->getCompany()))
|
36 |
+
->setBillingAddress1(strval($billing->getStreet(1)))
|
37 |
+
->setBillingAddress2(strval($billing->getStreet(2)))
|
38 |
+
->setBillingCity(strval($billing->getCity()))
|
39 |
+
->setBillingState(strval($billing->getRegion()))
|
40 |
+
->setBillingPostal(strval($billing->getPostcode()))
|
41 |
+
->setBillingCountry(strval($billing->getCountry()))
|
42 |
+
->setBillingPhone(strval($billing->getTelephone()))
|
43 |
+
->setBillingFax(strval($billing->getFax()))
|
44 |
+
->setBillingEmail(strval($order->getCustomerEmail()));
|
45 |
+
}
|
46 |
+
|
47 |
+
$shipping = $order->getShippingAddress();
|
48 |
+
if (!empty($shipping)) {
|
49 |
+
$this->setShippingFirstName(strval($shipping->getFirstname()))
|
50 |
+
->setShippingLastName(strval($shipping->getLastname()))
|
51 |
+
->setShippingCompany(strval($shipping->getCompany()))
|
52 |
+
->setShippingAddress1(strval($shipping->getStreet(1)))
|
53 |
+
->setShippingAddress2(strval($shipping->getStreet(2)))
|
54 |
+
->setShippingCity(strval($shipping->getCity()))
|
55 |
+
->setShippingState(strval($shipping->getRegion()))
|
56 |
+
->setShippingPostal(strval($shipping->getPostcode()))
|
57 |
+
->setShippingCountry(strval($shipping->getCountry()));
|
58 |
+
}
|
59 |
+
$this->setIpAddress(strval($order->getRemoteIp()));
|
60 |
+
$this->setPoNum(strval($payment->getPoNumber()));
|
61 |
+
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
}
|
app/code/local/GatewayProcessingServices/ThreeStep/Model/Session.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ThreeStep session model.
|
4 |
+
*
|
5 |
+
* @category Local
|
6 |
+
* @package GatewayProcessingServices_ThreeStep
|
7 |
+
* @author GPS
|
8 |
+
*/
|
9 |
+
class GatewayProcessingServices_ThreeStep_Model_Session extends Mage_Core_Model_Session_Abstract
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Class constructor. Initialize session namespace
|
13 |
+
*/
|
14 |
+
public function __construct()
|
15 |
+
{
|
16 |
+
$this->init('threestep');
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Add order IncrementId to session
|
21 |
+
*
|
22 |
+
* @param string $orderIncrementId
|
23 |
+
*/
|
24 |
+
public function addCheckoutOrderIncrementId($orderIncrementId)
|
25 |
+
{
|
26 |
+
$orderIncIds = $this->getThreeStepOrderIncrementIds();
|
27 |
+
if (!$orderIncIds) {
|
28 |
+
$orderIncIds = array();
|
29 |
+
}
|
30 |
+
$orderIncIds[$orderIncrementId] = 1;
|
31 |
+
$this->setThreeStepOrderIncrementIds($orderIncIds);
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Remove order IncrementId from session
|
36 |
+
*
|
37 |
+
* @param string $orderIncrementId
|
38 |
+
*/
|
39 |
+
public function removeCheckoutOrderIncrementId($orderIncrementId)
|
40 |
+
{
|
41 |
+
$orderIncIds = $this->getThreeStepOrderIncrementIds();
|
42 |
+
|
43 |
+
if (!is_array($orderIncIds)) {
|
44 |
+
return;
|
45 |
+
}
|
46 |
+
|
47 |
+
if (isset($orderIncIds[$orderIncrementId])) {
|
48 |
+
unset($orderIncIds[$orderIncrementId]);
|
49 |
+
}
|
50 |
+
$this->setThreeStepOrderIncrementIds($orderIncIds);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Return if order incrementId is in session.
|
55 |
+
*
|
56 |
+
* @param string $orderIncrementId
|
57 |
+
* @return bool
|
58 |
+
*/
|
59 |
+
public function isCheckoutOrderIncrementIdExist($orderIncrementId)
|
60 |
+
{
|
61 |
+
$orderIncIds = $this->getThreeStepOrderIncrementIds();
|
62 |
+
if (is_array($orderIncIds) && isset($orderIncIds[$orderIncrementId])) {
|
63 |
+
return true;
|
64 |
+
}
|
65 |
+
return false;
|
66 |
+
}
|
67 |
+
}
|
app/code/local/GatewayProcessingServices/ThreeStep/controllers/Adminhtml/PaymentController.php
ADDED
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once 'Mage/Adminhtml/controllers/Sales/Order/CreateController.php';
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Admihtml ThreeStep Payment Controller
|
7 |
+
*
|
8 |
+
* @category Local
|
9 |
+
* @package GatewayProcessingServices_ThreeStep
|
10 |
+
* @author GPS
|
11 |
+
*/
|
12 |
+
class GatewayProcessingServices_ThreeStep_Adminhtml_PaymentController
|
13 |
+
extends Mage_Adminhtml_Sales_Order_CreateController
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Get session model
|
17 |
+
*
|
18 |
+
* @return GatewayProcessingServices_ThreeStep_Model_Session
|
19 |
+
*/
|
20 |
+
protected function _getThreeStepSession()
|
21 |
+
{
|
22 |
+
return Mage::getSingleton('threestep/session');
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Retrieve session object
|
27 |
+
*
|
28 |
+
* @return Mage_Adminhtml_Model_Session_Quote
|
29 |
+
*/
|
30 |
+
protected function _getOrderSession()
|
31 |
+
{
|
32 |
+
return Mage::getSingleton('adminhtml/session_quote');
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Retrieve order create model
|
37 |
+
*
|
38 |
+
* @return Mage_Adminhtml_Model_Sales_Order_Create
|
39 |
+
*/
|
40 |
+
protected function _getOrderCreateModel()
|
41 |
+
{
|
42 |
+
return Mage::getSingleton('adminhtml/sales_order_create');
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Send step 1 request to GPS and build step 2 for submit
|
47 |
+
*
|
48 |
+
*/
|
49 |
+
public function placeAction()
|
50 |
+
{
|
51 |
+
$paymentParam = $this->getRequest()->getParam('payment');
|
52 |
+
$controller = $this->getRequest()->getParam('controller');
|
53 |
+
$this->getRequest()->setPost('collect_shipping_rates', 1);
|
54 |
+
$this->_processActionData('save');
|
55 |
+
|
56 |
+
//get confirmation by email flag
|
57 |
+
$orderData = $this->getRequest()->getPost('order');
|
58 |
+
|
59 |
+
// Email confirmation checkbox
|
60 |
+
$sendConfirmationFlag = 0;
|
61 |
+
if ($orderData) {
|
62 |
+
$sendConfirmationFlag = (!empty($orderData['send_confirmation'])) ? 1 : 0;
|
63 |
+
} else {
|
64 |
+
$orderData = array();
|
65 |
+
}
|
66 |
+
|
67 |
+
if (isset($paymentParam['method'])) {
|
68 |
+
$saveOrderFlag = Mage::getStoreConfig('payment/'.$paymentParam['method'].'/create_order_before');
|
69 |
+
$result = array();
|
70 |
+
$params = Mage::helper('threestep')->getSaveOrderUrlParams($controller);
|
71 |
+
|
72 |
+
//create order partially
|
73 |
+
$this->_getOrderCreateModel()->setPaymentData($paymentParam);
|
74 |
+
$this->_getOrderCreateModel()->getQuote()->getPayment()->addData($paymentParam);
|
75 |
+
|
76 |
+
$orderData['send_confirmation'] = 0;
|
77 |
+
$this->getRequest()->setPost('order', $orderData);
|
78 |
+
|
79 |
+
try {
|
80 |
+
$oldOrder = $this->_getOrderCreateModel()->getSession()->getOrder();
|
81 |
+
$oldOrder->setActionFlag(Mage_Sales_Model_Order::ACTION_FLAG_CANCEL, false);
|
82 |
+
|
83 |
+
$order = $this->_getOrderCreateModel()
|
84 |
+
->setIsValidate(true)
|
85 |
+
->importPostData($this->getRequest()->getPost('order'))
|
86 |
+
->createOrder();
|
87 |
+
|
88 |
+
$order->setSendConfirmationFlag($sendConfirmationFlag);
|
89 |
+
|
90 |
+
$adminUrl = Mage::getSingleton('adminhtml/url');
|
91 |
+
if ($adminUrl->useSecretKey()) {
|
92 |
+
$order->setKey(
|
93 |
+
$adminUrl->getSecretKey('payment','redirect')
|
94 |
+
);
|
95 |
+
}
|
96 |
+
|
97 |
+
$order->setControllerActionName($controller);
|
98 |
+
|
99 |
+
$payment = $order->getPayment();
|
100 |
+
if ($payment && $payment->getMethod() == Mage::getModel('threestep/paymentmethod')->getCode()) {
|
101 |
+
//return json with data.
|
102 |
+
$session = $this->_getThreeStepSession();
|
103 |
+
$session->addCheckoutOrderIncrementId($order->getIncrementId());
|
104 |
+
$session->setLastOrderIncrementId($order->getIncrementId());
|
105 |
+
|
106 |
+
$requestToPaygate = $payment->getMethodInstance()->generateRequestFromOrder($order);
|
107 |
+
$requestToPaygate->setStoreId($this->_getOrderCreateModel()->getQuote()->getStoreId());
|
108 |
+
|
109 |
+
$threestep = Mage::getModel('threestep/paymentmethod');
|
110 |
+
|
111 |
+
// Submit Step One
|
112 |
+
$formUrl = $threestep->doStepOne($requestToPaygate->getData());
|
113 |
+
$result['formUrl'] = $formUrl;
|
114 |
+
|
115 |
+
$result['threestep'] = array('fields' => $requestToPaygate->getData());
|
116 |
+
}
|
117 |
+
|
118 |
+
$result['success'] = 1;
|
119 |
+
$isError = false;
|
120 |
+
}
|
121 |
+
catch (Mage_Core_Exception $e) {
|
122 |
+
$message = $e->getMessage();
|
123 |
+
if( !empty($message) ) {
|
124 |
+
$this->_getSession()->addError($message);
|
125 |
+
}
|
126 |
+
$isError = true;
|
127 |
+
}
|
128 |
+
catch (Exception $e) {
|
129 |
+
$this->_getSession()->addException($e, $this->__('Order saving error: %s', $e->getMessage()));
|
130 |
+
$isError = true;
|
131 |
+
}
|
132 |
+
|
133 |
+
if ($isError) {
|
134 |
+
$result['success'] = 0;
|
135 |
+
$result['error'] = 1;
|
136 |
+
$result['redirect'] = Mage::getSingleton('adminhtml/url')->getUrl('*/sales_order_create/');
|
137 |
+
}
|
138 |
+
|
139 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
140 |
+
}
|
141 |
+
else {
|
142 |
+
$result = array(
|
143 |
+
'error_messages' => $this->__('Please, choose payment method')
|
144 |
+
);
|
145 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Retrieve params and put javascript into iframe
|
151 |
+
*
|
152 |
+
*/
|
153 |
+
public function redirectAction()
|
154 |
+
{
|
155 |
+
|
156 |
+
$redirectParams = $this->getRequest()->getParams();
|
157 |
+
|
158 |
+
$params = array();
|
159 |
+
if (!empty($redirectParams['success']) && isset($redirectParams['controller_action_name'])
|
160 |
+
) {
|
161 |
+
$params['redirect_parent'] = Mage::helper('threestep')->getSuccessOrderUrl($redirectParams);
|
162 |
+
$this->_getThreeStepSession()->unsetData('quote_id');
|
163 |
+
|
164 |
+
//clear sessions
|
165 |
+
$this->_getSession()->clear();
|
166 |
+
|
167 |
+
Mage::getSingleton('adminhtml/session')->clear();
|
168 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The order has been created.'));
|
169 |
+
}
|
170 |
+
|
171 |
+
if (!empty($redirectParams['error_msg'])) {
|
172 |
+
$cancelOrder = empty($redirectParams['order_id']);
|
173 |
+
$this->_returnQuote(true, $redirectParams['error_msg']);
|
174 |
+
}
|
175 |
+
|
176 |
+
$block = $this->getLayout()
|
177 |
+
->createBlock('threestep/payment_iframe')
|
178 |
+
->setParams(array_merge($params, $redirectParams));
|
179 |
+
$this->getResponse()->setBody($block->toHtml());
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Return order quote by ajax
|
184 |
+
*
|
185 |
+
*/
|
186 |
+
public function returnQuoteAction()
|
187 |
+
{
|
188 |
+
$this->_returnQuote();
|
189 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('success' => 1)));
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Return quote
|
194 |
+
*
|
195 |
+
* @param bool $cancelOrder
|
196 |
+
* @param string $errorMsg
|
197 |
+
*/
|
198 |
+
protected function _returnQuote($cancelOrder = false, $errorMsg = '')
|
199 |
+
{
|
200 |
+
$incrementId = $this->_getThreeStepSession()->getLastOrderIncrementId();
|
201 |
+
if ($incrementId &&
|
202 |
+
$this->_getThreeStepSession()
|
203 |
+
->isCheckoutOrderIncrementIdExist($incrementId)
|
204 |
+
) {
|
205 |
+
/* @var $order Mage_Sales_Model_Order */
|
206 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
207 |
+
if ($order->getId()) {
|
208 |
+
$this->_getThreeStepSession()->removeCheckoutOrderIncrementId($order->getIncrementId());
|
209 |
+
if ($cancelOrder && $order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
|
210 |
+
$order->registerCancellation($errorMsg)->save();
|
211 |
+
}
|
212 |
+
}
|
213 |
+
}
|
214 |
+
}
|
215 |
+
}
|
app/code/local/GatewayProcessingServices/ThreeStep/controllers/PaymentController.php
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ThreeStep Payment Controller
|
4 |
+
*
|
5 |
+
* @category Local
|
6 |
+
* @package GatewayProcessingServices_ThreeStep
|
7 |
+
* @author GPS
|
8 |
+
*/
|
9 |
+
class GatewayProcessingServices_ThreeStep_PaymentController extends Mage_Core_Controller_Front_Action {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Get session model
|
13 |
+
|
14 |
+
* @return GatewayProcessingServices_ThreeStep_Model_Session
|
15 |
+
*/
|
16 |
+
protected function _getThreeStepSession()
|
17 |
+
{
|
18 |
+
return Mage::getSingleton('threestep/session');
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return Mage_Checkout_Model_Session
|
23 |
+
*/
|
24 |
+
protected function _getCheckout()
|
25 |
+
{
|
26 |
+
return Mage::getSingleton('checkout/session');
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Get iframe block instance
|
31 |
+
*
|
32 |
+
* @return GatewayProcessingServices_ThreeStep_Block_Payment_Iframe
|
33 |
+
*/
|
34 |
+
protected function _getIframeBlock()
|
35 |
+
{
|
36 |
+
return $this->getLayout()->createBlock('threestep/payment_iframe');
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Send requests to GPS
|
41 |
+
*
|
42 |
+
*/
|
43 |
+
public function placeAction()
|
44 |
+
{
|
45 |
+
|
46 |
+
$paymentParam = $this->getRequest()->getParam('payment');
|
47 |
+
$controller = $this->getRequest()->getParam('controller');
|
48 |
+
if (isset($paymentParam['method'])) {
|
49 |
+
$params = Mage::helper('threestep')->getSaveOrderUrlParams($controller);
|
50 |
+
$this->_getThreeStepSession()->setQuoteId($this->_getCheckout()->getQuote()->getId());
|
51 |
+
$this->_forward(
|
52 |
+
$params['action'],
|
53 |
+
$params['controller'],
|
54 |
+
$params['module'],
|
55 |
+
$this->getRequest()->getParams()
|
56 |
+
);
|
57 |
+
} else {
|
58 |
+
$result = array(
|
59 |
+
'error_messages' => $this->__('Please, choose payment method'),
|
60 |
+
'goto_section' => 'payment'
|
61 |
+
);
|
62 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Response action.
|
68 |
+
*
|
69 |
+
* Action for returning from GPS step 2
|
70 |
+
*/
|
71 |
+
public function responseAction()
|
72 |
+
{
|
73 |
+
|
74 |
+
$result = array();
|
75 |
+
|
76 |
+
$controllerActionName = $_GET['controller'];
|
77 |
+
|
78 |
+
if ($controllerActionName == 'sales_order_create' || $controllerActionName == 'sales_order_edit') {
|
79 |
+
$result['controller_action_name'] = 'admin';
|
80 |
+
} else {
|
81 |
+
$result['controller_action_name'] = 'onepage';
|
82 |
+
}
|
83 |
+
|
84 |
+
$data['token'] = $_GET['token-id'];
|
85 |
+
$data['order_id'] = $_GET['order_id'];
|
86 |
+
$data['orderSendConfirmation'] = $_GET['order_send_flag'];
|
87 |
+
$data['key'] = $_GET['key'];
|
88 |
+
|
89 |
+
$result['order_id'] = $data['order_id'];
|
90 |
+
|
91 |
+
$paymentMethod = Mage::getModel('threestep/PaymentMethod');
|
92 |
+
|
93 |
+
try {
|
94 |
+
$paymentMethod->process($data);
|
95 |
+
$result['success'] = 1;
|
96 |
+
}
|
97 |
+
catch (Mage_Core_Exception $e) {
|
98 |
+
Mage::logException($e);
|
99 |
+
$result['success'] = 0;
|
100 |
+
$result['error_msg'] = $e->getMessage();
|
101 |
+
}
|
102 |
+
catch (Exception $e) {
|
103 |
+
Mage::logException($e);
|
104 |
+
$result['success'] = 0;
|
105 |
+
$result['error_msg'] = $this->__('There was an error processing your order. Please contact us or try again later.');
|
106 |
+
}
|
107 |
+
|
108 |
+
if (!empty($data['key'])) {
|
109 |
+
$result['key'] = $data['key'];
|
110 |
+
}
|
111 |
+
|
112 |
+
$params['redirect'] = Mage::helper('threestep')->getRedirectIframeUrl($result);
|
113 |
+
|
114 |
+
$block = $this->_getIframeBlock()->setParams($params);
|
115 |
+
$this->getResponse()->setBody($block->toHtml());
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Retrieve params and put javascript into iframe
|
120 |
+
*
|
121 |
+
*/
|
122 |
+
public function redirectAction()
|
123 |
+
{
|
124 |
+
|
125 |
+
$redirectParams = $this->getRequest()->getParams();
|
126 |
+
|
127 |
+
|
128 |
+
$params = array();
|
129 |
+
if (!empty($redirectParams['success']) && isset($redirectParams['controller_action_name'])) {
|
130 |
+
$this->_getThreeStepSession()->unsetData('quote_id');
|
131 |
+
$params['redirect_parent'] = Mage::helper('threestep')->getSuccessOrderUrl($redirectParams);
|
132 |
+
}
|
133 |
+
if (!empty($redirectParams['error_msg'])) {
|
134 |
+
$this->_returnCustomerQuote(true, $redirectParams['error_msg']);
|
135 |
+
}
|
136 |
+
|
137 |
+
$block = $this->_getIframeBlock()->setParams(array_merge($params, $redirectParams));
|
138 |
+
$this->getResponse()->setBody($block->toHtml());
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Return customer quote by ajax
|
143 |
+
*
|
144 |
+
*/
|
145 |
+
public function returnQuoteAction()
|
146 |
+
{
|
147 |
+
$this->_returnCustomerQuote();
|
148 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('success' => 1)));
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Return customer quote
|
153 |
+
*
|
154 |
+
* @param bool $cancelOrder
|
155 |
+
* @param string $errorMsg
|
156 |
+
*/
|
157 |
+
protected function _returnCustomerQuote($cancelOrder = false, $errorMsg = '')
|
158 |
+
{
|
159 |
+
$incrementId = $this->_getThreeStepSession()->getLastOrderIncrementId();
|
160 |
+
|
161 |
+
if ($incrementId &&
|
162 |
+
$this->_getThreeStepSession()->isCheckoutOrderIncrementIdExist($incrementId)
|
163 |
+
) {
|
164 |
+
/* @var $order Mage_Sales_Model_Order */
|
165 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
166 |
+
if ($order->getId()) {
|
167 |
+
$quote = Mage::getModel('sales/quote')
|
168 |
+
->load($order->getQuoteId());
|
169 |
+
if ($quote->getId()) {
|
170 |
+
$quote->setIsActive(1)
|
171 |
+
->setReservedOrderId(NULL)
|
172 |
+
->save();
|
173 |
+
$this->_getCheckout()->replaceQuote($quote);
|
174 |
+
}
|
175 |
+
$this->_getThreeStepSession()->removeCheckoutOrderIncrementId($incrementId);
|
176 |
+
$this->_getThreeStepSession()->unsetData('quote_id');
|
177 |
+
if ($cancelOrder) {
|
178 |
+
$order->registerCancellation($errorMsg)->save();
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
}
|
app/code/local/GatewayProcessingServices/ThreeStep/etc/config.xml
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<GatewayProcessingServices_ThreeStep>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</GatewayProcessingServices_ThreeStep>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<blocks>
|
10 |
+
<threestep>
|
11 |
+
<class>GatewayProcessingServices_ThreeStep_Block</class>
|
12 |
+
</threestep>
|
13 |
+
</blocks>
|
14 |
+
<models>
|
15 |
+
<threestep>
|
16 |
+
<class>GatewayProcessingServices_ThreeStep_Model</class>
|
17 |
+
</threestep>
|
18 |
+
</models>
|
19 |
+
<helpers>
|
20 |
+
<threestep>
|
21 |
+
<class>GatewayProcessingServices_ThreeStep_Helper</class>
|
22 |
+
</threestep>
|
23 |
+
</helpers>
|
24 |
+
</global>
|
25 |
+
<frontend>
|
26 |
+
<routers>
|
27 |
+
<threestep>
|
28 |
+
<use>standard</use>
|
29 |
+
<args>
|
30 |
+
<module>GatewayProcessingServices_ThreeStep</module>
|
31 |
+
<frontName>threestep</frontName>
|
32 |
+
</args>
|
33 |
+
</threestep>
|
34 |
+
<checkout>
|
35 |
+
<args>
|
36 |
+
<modules>
|
37 |
+
<GatewayProcessingServices_ThreeStep before="Mage_Checkout">GatewayProcessingServices_ThreeStep</GatewayProcessingServices_ThreeStep>
|
38 |
+
</modules>
|
39 |
+
</args>
|
40 |
+
</checkout>
|
41 |
+
</routers>
|
42 |
+
<layout>
|
43 |
+
<updates>
|
44 |
+
<threestep>
|
45 |
+
<file>threestep.xml</file>
|
46 |
+
</threestep>
|
47 |
+
</updates>
|
48 |
+
</layout>
|
49 |
+
<events>
|
50 |
+
<checkout_submit_all_after>
|
51 |
+
<observers>
|
52 |
+
<threestep_save_order_after_submit>
|
53 |
+
<class>threestep/observer</class>
|
54 |
+
<method>saveOrderAfterSubmit</method>
|
55 |
+
</threestep_save_order_after_submit>
|
56 |
+
</observers>
|
57 |
+
</checkout_submit_all_after>
|
58 |
+
<controller_action_postdispatch_checkout_onepage_saveOrder>
|
59 |
+
<observers>
|
60 |
+
<threestep_save_order_onepage>
|
61 |
+
<class>threestep/observer</class>
|
62 |
+
<method>addAdditionalFieldsToResponseFrontend</method>
|
63 |
+
</threestep_save_order_onepage>
|
64 |
+
</observers>
|
65 |
+
</controller_action_postdispatch_checkout_onepage_saveOrder>
|
66 |
+
</events>
|
67 |
+
</frontend>
|
68 |
+
<admin>
|
69 |
+
<routers>
|
70 |
+
<adminhtml>
|
71 |
+
<args>
|
72 |
+
<modules>
|
73 |
+
<GatewayProcessingServices_ThreeStep before="Mage_Adminhtml">GatewayProcessingServices_ThreeStep_Adminhtml</GatewayProcessingServices_ThreeStep>
|
74 |
+
</modules>
|
75 |
+
</args>
|
76 |
+
</adminhtml>
|
77 |
+
</routers>
|
78 |
+
</admin>
|
79 |
+
<adminhtml>
|
80 |
+
<layout>
|
81 |
+
<updates>
|
82 |
+
<threestep>
|
83 |
+
<file>threestep.xml</file>
|
84 |
+
</threestep>
|
85 |
+
</updates>
|
86 |
+
</layout>
|
87 |
+
<events>
|
88 |
+
<checkout_submit_all_after>
|
89 |
+
<observers>
|
90 |
+
<threestep_update_all_edit_increments>
|
91 |
+
<class>threestep/observer</class>
|
92 |
+
<method>updateAllEditIncrements</method>
|
93 |
+
</threestep_update_all_edit_increments>
|
94 |
+
</observers>
|
95 |
+
</checkout_submit_all_after>
|
96 |
+
</events>
|
97 |
+
</adminhtml>
|
98 |
+
<default>
|
99 |
+
<payment>
|
100 |
+
<threestep>
|
101 |
+
<active>0</active>
|
102 |
+
<model>threestep/paymentMethod</model>
|
103 |
+
<order_status>pending</order_status>
|
104 |
+
<title>Credit Card</title>
|
105 |
+
<cctypes>VI,MC,DI,AE</cctypes>
|
106 |
+
<payment_action>authorize</payment_action>
|
107 |
+
<currency>USD</currency>
|
108 |
+
<allowspecific>0</allowspecific>
|
109 |
+
<useccv>0</useccv>
|
110 |
+
</threestep>
|
111 |
+
</payment>
|
112 |
+
</default>
|
113 |
+
</config>
|
app/code/local/GatewayProcessingServices/ThreeStep/etc/system.xml
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<payment>
|
5 |
+
<groups>
|
6 |
+
<threestep translate="label" module="paygate">
|
7 |
+
<label>CyoGate</label>
|
8 |
+
<sort_order>1</sort_order>
|
9 |
+
<show_in_default>1</show_in_default>
|
10 |
+
<show_in_website>1</show_in_website>
|
11 |
+
<show_in_store>0</show_in_store>
|
12 |
+
<fields>
|
13 |
+
<active translate="label">
|
14 |
+
<label>Enabled</label>
|
15 |
+
<frontend_type>select</frontend_type>
|
16 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
17 |
+
<comment><![CDATA[Whether this payment method is enabled or disabled]]></comment>
|
18 |
+
<sort_order>1</sort_order>
|
19 |
+
<show_in_default>1</show_in_default>
|
20 |
+
<show_in_website>1</show_in_website>
|
21 |
+
<show_in_store>0</show_in_store>
|
22 |
+
</active>
|
23 |
+
<title translate="label">
|
24 |
+
<label>Title</label>
|
25 |
+
<frontend_type>text</frontend_type>
|
26 |
+
<sort_order>2</sort_order>
|
27 |
+
<comment><![CDATA[The title of the payment method that will be displayed to customers.]]></comment>
|
28 |
+
<show_in_default>1</show_in_default>
|
29 |
+
<show_in_website>1</show_in_website>
|
30 |
+
<show_in_store>1</show_in_store>
|
31 |
+
</title>
|
32 |
+
<api-key translate="label">
|
33 |
+
<label>Gateway API-key</label>
|
34 |
+
<frontend_type>text</frontend_type>
|
35 |
+
<sort_order>3</sort_order>
|
36 |
+
<comment><![CDATA[API-key that is use to hook the payment method to your gateway account. The API-key can be found within your merchant control panel under "Options"->"Security Keys". It will be the longer value underneath "Key".]]></comment>
|
37 |
+
<show_in_default>1</show_in_default>
|
38 |
+
<show_in_website>1</show_in_website>
|
39 |
+
<show_in_store>0</show_in_store>
|
40 |
+
</api-key>
|
41 |
+
<payment_action translate="label">
|
42 |
+
<label>Payment Action</label>
|
43 |
+
<frontend_type>select</frontend_type>
|
44 |
+
<source_model>paygate/authorizenet_source_paymentAction</source_model>
|
45 |
+
<sort_order>4</sort_order>
|
46 |
+
<comment><![CDATA["Authorize Only" or "Authorize and Capture". If you select Authorize Only, you will need to capture the transaction in order for funds to move.]]></comment>
|
47 |
+
<show_in_default>1</show_in_default>
|
48 |
+
<show_in_website>1</show_in_website>
|
49 |
+
<show_in_store>0</show_in_store>
|
50 |
+
</payment_action>
|
51 |
+
<order_status transaction="label">
|
52 |
+
<label>New order status</label>
|
53 |
+
<frontend_type>select</frontend_type>
|
54 |
+
<source_model>adminhtml/system_config_source_order_status</source_model>
|
55 |
+
<comment><![CDATA[The status of the order after the payment is successful.]]></comment>
|
56 |
+
<sort_order>5</sort_order>
|
57 |
+
<show_in_default>1</show_in_default>
|
58 |
+
<show_in_website>1</show_in_website>
|
59 |
+
<show_in_store>0</show_in_store>
|
60 |
+
</order_status>
|
61 |
+
<test_mode translate="label">
|
62 |
+
<label>Test Mode</label>
|
63 |
+
<frontend_type>select</frontend_type>
|
64 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
65 |
+
<comment><![CDATA[If test mode is enabled, your transactions will be sent to a test merchant account.]]></comment>
|
66 |
+
<sort_order>6</sort_order>
|
67 |
+
<show_in_default>1</show_in_default>
|
68 |
+
<show_in_website>1</show_in_website>
|
69 |
+
<show_in_store>0</show_in_store>
|
70 |
+
</test_mode>
|
71 |
+
<currency translate="label">
|
72 |
+
<label>Accepted Currency</label>
|
73 |
+
<frontend_type>select</frontend_type>
|
74 |
+
<source_model>adminhtml/system_config_source_currency</source_model>
|
75 |
+
<sort_order>7</sort_order>
|
76 |
+
<show_in_default>1</show_in_default>
|
77 |
+
<show_in_website>1</show_in_website>
|
78 |
+
<show_in_store>0</show_in_store>
|
79 |
+
</currency>
|
80 |
+
<cctypes translate="label">
|
81 |
+
<label>Credit Card Types</label>
|
82 |
+
<frontend_type>multiselect</frontend_type>
|
83 |
+
<source_model>paygate/authorizenet_source_cctype</source_model>
|
84 |
+
<sort_order>9</sort_order>
|
85 |
+
<comment><![CDATA[Select which credit card types are accepted.]]></comment>
|
86 |
+
<show_in_default>1</show_in_default>
|
87 |
+
<show_in_website>1</show_in_website>
|
88 |
+
<show_in_store>0</show_in_store>
|
89 |
+
</cctypes>
|
90 |
+
<useccv translate="label">
|
91 |
+
<label>Credit Card Verification</label>
|
92 |
+
<frontend_type>select</frontend_type>
|
93 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
94 |
+
<comment><![CDATA[Whether the 3 or 4 digit card security code is required.]]></comment>
|
95 |
+
<sort_order>10</sort_order>
|
96 |
+
<show_in_default>1</show_in_default>
|
97 |
+
<show_in_website>1</show_in_website>
|
98 |
+
<show_in_store>0</show_in_store>
|
99 |
+
</useccv>
|
100 |
+
<allowspecific translate="label">
|
101 |
+
<label><![CDATA[Payment from applicable countries:]]></label>
|
102 |
+
<comment><![CDATA[Set this to "Specific Countries" if you wish to limit what countries may place orders.]]></comment>
|
103 |
+
<frontend_type>allowspecific</frontend_type>
|
104 |
+
<sort_order>11</sort_order>
|
105 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
106 |
+
<show_in_default>1</show_in_default>
|
107 |
+
<show_in_website>1</show_in_website>
|
108 |
+
<show_in_store>1</show_in_store>
|
109 |
+
</allowspecific>
|
110 |
+
<specificcountry translate="label">
|
111 |
+
<label><![CDATA[Payment from Specific countries:]]></label>
|
112 |
+
<comment><![CDATA[Which countries this payment method is available to. This becomes active if the setting above is set to "Specific Countries".]]></comment>
|
113 |
+
<frontend_type>multiselect</frontend_type>
|
114 |
+
<sort_order>12</sort_order>
|
115 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
116 |
+
<show_in_default>1</show_in_default>
|
117 |
+
<show_in_website>1</show_in_website>
|
118 |
+
<show_in_store>1</show_in_store>
|
119 |
+
</specificcountry>
|
120 |
+
<min_order_total translate="label">
|
121 |
+
<label>Minimum Order Total</label>
|
122 |
+
<frontend_type>text</frontend_type>
|
123 |
+
<sort_order>13</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 |
+
</min_order_total>
|
128 |
+
<max_order_total translate="label">
|
129 |
+
<label>Maximum Order Total</label>
|
130 |
+
<frontend_type>text</frontend_type>
|
131 |
+
<sort_order>14</sort_order>
|
132 |
+
<show_in_default>1</show_in_default>
|
133 |
+
<show_in_website>1</show_in_website>
|
134 |
+
<show_in_store>0</show_in_store>
|
135 |
+
</max_order_total>
|
136 |
+
<sort_order translate="label">
|
137 |
+
<label>Sort Order</label>
|
138 |
+
<comment><![CDATA[In which order this payment method will appear on the checkout page.]]></comment>
|
139 |
+
<frontend_type>text</frontend_type>
|
140 |
+
<sort_order>15</sort_order>
|
141 |
+
<show_in_default>1</show_in_default>
|
142 |
+
<show_in_website>1</show_in_website>
|
143 |
+
<show_in_store>0</show_in_store>
|
144 |
+
<frontend_class>validate-number</frontend_class>
|
145 |
+
</sort_order>
|
146 |
+
</fields>
|
147 |
+
</threestep>
|
148 |
+
</groups>
|
149 |
+
</payment>
|
150 |
+
</sections>
|
151 |
+
</config>
|
152 |
+
|
app/design/adminhtml/default/default/layout/threestep.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<layout version="0.1.0">
|
4 |
+
<adminhtml_sales_order_create_index>
|
5 |
+
<reference name="head">
|
6 |
+
<action method="addJs"><file>mage/threestep.js</file></action>
|
7 |
+
</reference>
|
8 |
+
</adminhtml_sales_order_create_index>
|
9 |
+
</layout>
|
app/design/frontend/base/default/layout/threestep.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<layout version="0.1.0">
|
4 |
+
<checkout_onepage_index>
|
5 |
+
<reference name="head">
|
6 |
+
<action method="addJs"><file>mage/threestep.js</file></action>
|
7 |
+
</reference>
|
8 |
+
</checkout_onepage_index>
|
9 |
+
<checkout_onepage_review>
|
10 |
+
<reference name="checkout.onepage.review.info.items.after">
|
11 |
+
<block type="threestep/payment_form" name="payment.form.threestep" template="threestep/payment/form.phtml">
|
12 |
+
<action method="setMethodInfo"></action>
|
13 |
+
</block>
|
14 |
+
</reference>
|
15 |
+
</checkout_onepage_review>
|
16 |
+
</layout>
|
17 |
+
|
18 |
+
|
app/design/frontend/default/default/template/threestep/payment/form.phtml
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$_form = $this;
|
4 |
+
$_code = $_form->getMethodCode();
|
5 |
+
$_method = $_form->getMethod();
|
6 |
+
$_controller = $this->helper('threestep')->getControllerName();
|
7 |
+
$_orderUrl = $this->helper('threestep')->getPlaceOrderFrontUrl();
|
8 |
+
|
9 |
+
?>
|
10 |
+
|
11 |
+
<div class="buttons-set">
|
12 |
+
<iframe id="threestep-iframe" allowtransparency="true" frameborder="0" name="iframeThreeStep" style="display:none;height:100%;width:100%;background-color:transparent" src="<?php echo $this->getJsUrl() ?>blank.html"></iframe>
|
13 |
+
|
14 |
+
<form id="co-threestep-form" action="#" method="post">
|
15 |
+
<fieldset>
|
16 |
+
<dl class="sp-methods">
|
17 |
+
<dt class="a-left"><?php echo $this->__('Credit Card Information') ?></dt>
|
18 |
+
<dd>
|
19 |
+
<ul id="payment_form_<?php echo $_code ?>" class="form-list">
|
20 |
+
<li>
|
21 |
+
<label for="<?php echo $_code ?>_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
|
22 |
+
<div class="input-box">
|
23 |
+
<select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
|
24 |
+
<option value=""><?php echo $this->__('--Please Select--')?></option>
|
25 |
+
<?php $_ccType = $_form->getInfoData('cc_type') ?>
|
26 |
+
<?php foreach ($_form->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
|
27 |
+
<option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
|
28 |
+
<?php endforeach ?>
|
29 |
+
</select>
|
30 |
+
</div>
|
31 |
+
</li>
|
32 |
+
<li>
|
33 |
+
<label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
|
34 |
+
<div class="input-box">
|
35 |
+
<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="" />
|
36 |
+
</div>
|
37 |
+
</li>
|
38 |
+
<li id="<?php echo $_code ?>_cc_type_exp_div">
|
39 |
+
<label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
|
40 |
+
<div class="input-box">
|
41 |
+
<div class="v-fix">
|
42 |
+
<select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
|
43 |
+
<?php $_ccExpMonth = $_form->getInfoData('cc_exp_month') ?>
|
44 |
+
<?php foreach ($_form->getCcMonths() as $k=>$v): ?>
|
45 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
46 |
+
<?php endforeach ?>
|
47 |
+
</select>
|
48 |
+
</div>
|
49 |
+
<div class="v-fix">
|
50 |
+
<?php $_ccExpYear = $_form->getInfoData('cc_exp_year') ?>
|
51 |
+
<select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
|
52 |
+
<?php foreach ($_form->getCcYears() as $k=>$v): ?>
|
53 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
54 |
+
<?php endforeach ?>
|
55 |
+
</select>
|
56 |
+
</div>
|
57 |
+
</div>
|
58 |
+
</li>
|
59 |
+
<?php echo $_form->getChildHtml() ?>
|
60 |
+
<?php if($_form->hasVerification()): ?>
|
61 |
+
<li id="<?php echo $_code ?>_cc_type_cvv_div">
|
62 |
+
<label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
|
63 |
+
<div class="input-box">
|
64 |
+
<div class="v-fix">
|
65 |
+
<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="" />
|
66 |
+
</div>
|
67 |
+
<a href="#" id="threestep-cvv-what-is-this" style="cursor:help; margin-left:5px;"><?php echo $this->__('What is this?') ?></a>
|
68 |
+
</div>
|
69 |
+
</li>
|
70 |
+
<?php endif; ?>
|
71 |
+
</ul>
|
72 |
+
</dd>
|
73 |
+
</dl>
|
74 |
+
</fieldset>
|
75 |
+
</form>
|
76 |
+
</div>
|
77 |
+
<div class="tool-tip" id="threestep-tool-tip" style="display:none;">
|
78 |
+
<div class="btn-close"><a href="#" id="threestep-tool-tip-close" title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
|
79 |
+
<div class="tool-tip-content"><img src="<?php echo $this->getSkinUrl('images/cvv.gif') ?>" alt="<?php echo $this->__('Card Verification Number Visual Reference') ?>" title="<?php echo $this->__('Card Verification Number Visual Reference') ?>" /></div>
|
80 |
+
</div>
|
81 |
+
<script type="text/javascript">
|
82 |
+
//<![CDATA[
|
83 |
+
if ($('threestep-cvv-what-is-this')) {
|
84 |
+
$('threestep-cvv-what-is-this').observe('click', toggleCvvToolTip);
|
85 |
+
}
|
86 |
+
new Validation('co-threestep-form');
|
87 |
+
function toggleCvvToolTip(event){
|
88 |
+
if($('threestep-tool-tip')){
|
89 |
+
$('threestep-tool-tip').setStyle({
|
90 |
+
top: (Event.pointerY(event)-560)+'px'
|
91 |
+
})
|
92 |
+
$('threestep-tool-tip').toggle();
|
93 |
+
}
|
94 |
+
Event.stop(event);
|
95 |
+
}
|
96 |
+
if($('threestep-tool-tip-close')){
|
97 |
+
Event.observe($('threestep-tool-tip-close'), 'click', toggleCvvToolTip);
|
98 |
+
}
|
99 |
+
threeStepModel = new threeStep(
|
100 |
+
'<?php echo $_code ?>',
|
101 |
+
'threestep-iframe',
|
102 |
+
'<?php echo $_controller ?>',
|
103 |
+
'<?php echo $_orderUrl ?>',
|
104 |
+
'',
|
105 |
+
'<?php echo $this->getUrl('checkout/onepage/saveOrder', array('_secure' => $this->getRequest()->isSecure())) ?>');
|
106 |
+
//]]>
|
107 |
+
</script>
|
108 |
+
|
109 |
+
|
110 |
+
|
111 |
+
|
app/design/frontend/default/default/template/threestep/payment/iframe.phtml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$_params = $this->getParams();
|
3 |
+
$_helper = $this->helper('threestep');
|
4 |
+
?>
|
5 |
+
<html>
|
6 |
+
<head>
|
7 |
+
<script type="text/javascript">
|
8 |
+
//<![CDATA[
|
9 |
+
<?php if (isset($_params['redirect'])): ?>
|
10 |
+
window.location="<?php echo $this->escapeUrl($_params['redirect']) ?>";
|
11 |
+
<?php endif; ?>
|
12 |
+
<?php if (isset($_params['redirect_parent'])): ?>
|
13 |
+
window.top.location="<?php echo $this->escapeUrl($_params['redirect_parent']) ?>";
|
14 |
+
<?php endif; ?>
|
15 |
+
<?php if (isset($_params['error_msg'])): ?>
|
16 |
+
window.top.threeStepModel.showError(<?php echo $this->helper('core')->jsonEncode($_params['error_msg']) ?>);
|
17 |
+
<?php if (isset($_params['order_id'])): ?>
|
18 |
+
window.top.threeStepModel.successUrl="<?php echo $_helper->getSuccessOrderUrl($_params) ?>";
|
19 |
+
<?php endif; ?>
|
20 |
+
<?php endif; ?>
|
21 |
+
//]]>
|
22 |
+
</script>
|
23 |
+
</head>
|
24 |
+
<body></body>
|
25 |
+
</html>
|
app/design/frontend/default/default/template/threestep/payment/info.phtml
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<ul id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none">
|
2 |
+
<li>
|
3 |
+
<?php echo $this->__('You will be required to enter your payment details before you place an order.') ?>
|
4 |
+
</li>
|
5 |
+
</ul>
|
app/etc/modules/GatewayProcessingServices_ThreeStep.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<GatewayProcessingServices_ThreeStep>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Payment />
|
9 |
+
<Mage_Sales />
|
10 |
+
<Mage_Checkout />
|
11 |
+
<Mage_Adminhtml />
|
12 |
+
</depends>
|
13 |
+
</GatewayProcessingServices_ThreeStep>
|
14 |
+
</modules>
|
15 |
+
</config>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>CyoGate_17x</name>
|
4 |
-
<version>1.7.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
@@ -11,8 +11,8 @@
|
|
11 |
<notes>Last updated on 03/01/2014</notes>
|
12 |
<authors><author><name>CyoGate Merchant Solutions</name><user>cyberoptic</user><email>jon@cyop.net</email></author></authors>
|
13 |
<date>2014-03-01</date>
|
14 |
-
<time>
|
15 |
-
<contents><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="threestep.xml" hash=""/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="threestep.xml" hash=""/></dir></dir></dir><dir name="default"><dir name="default"><dir name="template"><dir name="threestep"><dir name="payment"><file name="form.phtml" hash=""/><file name="iframe.phtml" hash=""/><file name="info.phtml" hash=""/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="GatewayProcessingServices_ThreeStep.xml" hash=""/></dir></target><target name="mageweb"><dir name="js"><dir name="mage"><file name="threestep.js" hash=""/></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>5.5.9</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>CyoGate_17x</name>
|
4 |
+
<version>1.7.0.2</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
11 |
<notes>Last updated on 03/01/2014</notes>
|
12 |
<authors><author><name>CyoGate Merchant Solutions</name><user>cyberoptic</user><email>jon@cyop.net</email></author></authors>
|
13 |
<date>2014-03-01</date>
|
14 |
+
<time>16:35:06</time>
|
15 |
+
<contents><target name="magelocal"><dir name="GatewayProcessingServices"><dir name="ThreeStep"><dir name="Block"><dir name="Payment"><file name="Form.php" hash="a886c978ea1c74ac1d3a9e837b89c502"/><file name="Iframe.php" hash="93aa9c8155a94423daa300e681c94560"/></dir></dir><dir name="Helper"><file name="Data.php" hash="81b7e8e3a57e5c90c1562922a9a006b6"/></dir><dir name="Model"><file name="Observer.php" hash="2f21135a82157df250ff6bfe38c3bd42"/><file name="PaymentMethod.php" hash="f1ffa5c96e9b0db249c145f836c51085"/><file name="Request.php" hash="a4adcfe1fddfbae5e345252f8e6b25e5"/><file name="Session.php" hash="562dfac163beba663d97214625f6a3c1"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PaymentController.php" hash="3aec589ae0e5b8e800020d1700c38d96"/></dir><file name="PaymentController.php" hash="ff05b9b77e74c91d93cd38e9ec30c586"/></dir><dir name="etc"><file name="config.xml" hash="7820ce4635a6b5261033705d1ead80ea"/><file name="system.xml" hash="7095be3cc10b1e4f967bba71bd49fff8"/></dir></dir></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="threestep.xml" hash=""/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="threestep.xml" hash=""/></dir></dir></dir><dir name="default"><dir name="default"><dir name="template"><dir name="threestep"><dir name="payment"><file name="form.phtml" hash=""/><file name="iframe.phtml" hash=""/><file name="info.phtml" hash=""/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="GatewayProcessingServices_ThreeStep.xml" hash=""/></dir></target><target name="mageweb"><dir name="js"><dir name="mage"><file name="threestep.js" hash=""/></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>5.5.9</max></php></required></dependencies>
|
18 |
</package>
|