Phoenix_Worldpay - Version 1.2.2

Version Notes

- Minor fix for Magento 1.4

Download this release

Release Info

Developer Magento Core Team
Extension Phoenix_Worldpay
Version 1.2.2
Comparing to
See all releases


Code changes from version 1.2.0 to 1.2.2

app/code/community/Phoenix/Worldpay/Block/Processing.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
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://opensource.org/licenses/osl-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
- * @category Phoenix
16
- * @package Phoenix_Worldpay
17
- * @copyright Copyright (c) 2008 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
18
- */
19
-
20
- class Phoenix_Worldpay_Block_Processing extends Mage_Core_Block_Abstract
21
- {
22
- protected function _toHtml()
23
- {
24
- $payment = $this->getOrder()->getPayment()->getMethodInstance();
25
-
26
- $form = new Varien_Data_Form();
27
- $form->setAction($payment->getUrl())
28
- ->setId('worldpay_checkout')
29
- ->setName('worldpay_checkout')
30
- ->setMethod('POST')
31
- ->setUseContainer(true);
32
- foreach ($payment->getFormFields() as $field=>$value) {
33
- $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
34
- }
35
- $html = '<html><body>';
36
- $html.= $this->__('You will be redirected to Worldpay in a few seconds.');
37
- $html.= $form->toHtml();
38
- $html.= '<script type="text/javascript">document.getElementById("worldpay_checkout").submit();</script>';
39
- $html.= '</body></html>';
40
-
41
- return $html;
42
- }
43
-
44
-
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Phoenix/Worldpay/Block/Redirect.php CHANGED
@@ -19,12 +19,6 @@
19
 
20
  class Phoenix_Worldpay_Block_Redirect extends Mage_Core_Block_Template
21
  {
22
-
23
- protected function _construct()
24
- {
25
- parent::_construct();
26
- }
27
-
28
  /**
29
  * Return checkout session instance
30
  *
@@ -52,7 +46,7 @@ class Phoenix_Worldpay_Block_Redirect extends Mage_Core_Block_Template
52
  }
53
 
54
  /**
55
- * Get Form data by using ogone payment api
56
  *
57
  * @return array
58
  */
19
 
20
  class Phoenix_Worldpay_Block_Redirect extends Mage_Core_Block_Template
21
  {
 
 
 
 
 
 
22
  /**
23
  * Return checkout session instance
24
  *
46
  }
47
 
48
  /**
49
+ * Get form data
50
  *
51
  * @return array
52
  */
app/code/community/Phoenix/Worldpay/Model/Config/Backend/Instid.php CHANGED
@@ -26,24 +26,26 @@ class Phoenix_Worldpay_Model_Config_Backend_Instid extends Mage_Core_Model_Confi
26
  */
27
  protected function _beforeSave()
28
  {
29
- try {
30
- $client = new Varien_Http_Client();
31
- $client->setUri((string)Mage::getConfig()->getNode('phoenix/worldpay/verify_url'))
32
- ->setConfig(array('timeout'=>10,))
33
- ->setParameterPost('inst_id', $this->getValue())
34
- ->setMethod(Zend_Http_Client::POST);
35
- $response = $client->request();
36
- $responseBody = $response->getBody();
37
- if (empty($responseBody) || $responseBody != 'VERIFIED') {
38
- // verification failed. throw error message (not implemented yet).
39
- }
40
-
41
- // okay, inst_id verified. continue saving.
42
 
43
- } catch (Zend_Http_Client_Exception $e) {
44
- // verification system unavailable. no further action.
45
- }
46
-
47
- return $this;
 
 
48
  }
49
  }
26
  */
27
  protected function _beforeSave()
28
  {
29
+ try {
30
+ if ($this->getValue()) {
31
+ $client = new Varien_Http_Client();
32
+ $client->setUri((string)Mage::getConfig()->getNode('phoenix/worldpay/verify_url'))
33
+ ->setConfig(array('timeout'=>10,))
34
+ ->setHeaders('accept-encoding', '')
35
+ ->setParameterPost('inst_id', $this->getValue())
36
+ ->setMethod(Zend_Http_Client::POST);
37
+ $response = $client->request();
38
+ // $responseBody = $response->getBody();
39
+ // if (empty($responseBody) || $responseBody != 'VERIFIED') {
40
+ // verification failed. throw error message (not implemented yet).
41
+ // }
42
 
43
+ // okay, inst_id verified. continue saving.
44
+ }
45
+ } catch (Exception $e) {
46
+ // verification system unavailable. no further action.
47
+ }
48
+
49
+ return parent::_beforeSave();
50
  }
51
  }
app/code/community/Phoenix/Worldpay/controllers/ProcessingController.php CHANGED
@@ -71,7 +71,7 @@ class Phoenix_Worldpay_ProcessingController extends Mage_Core_Controller_Front_A
71
  */
72
  public function responseAction()
73
  {
74
- try {
75
  $request = $this->_checkReturnedPost();
76
  if ($request['transStatus'] == 'Y') {
77
  $this->_processSale($request);
@@ -80,14 +80,14 @@ class Phoenix_Worldpay_ProcessingController extends Mage_Core_Controller_Front_A
80
  } else {
81
  Mage::throwException('Transaction was not successfull.');
82
  }
83
- } catch (Mage_Core_Exception $e) {
84
- $this->getResponse()->setBody(
85
- $this->getLayout()
86
- ->createBlock($this->_failureBlockType)
87
- ->setOrder($this->_order)
88
- ->toHtml()
89
- );
90
- }
91
  }
92
 
93
  /**
@@ -98,7 +98,10 @@ class Phoenix_Worldpay_ProcessingController extends Mage_Core_Controller_Front_A
98
  try {
99
  $session = $this->_getCheckout();
100
  $quoteId = $session->getWorldpayQuoteId();
101
- $this->_getCheckout()->setLastSuccessQuoteId($quoteId);
 
 
 
102
  $this->_redirect('checkout/onepage/success');
103
  return;
104
  } catch (Mage_Core_Exception $e) {
@@ -126,29 +129,41 @@ class Phoenix_Worldpay_ProcessingController extends Mage_Core_Controller_Front_A
126
  */
127
  protected function _checkReturnedPost()
128
  {
129
- // check request type
130
  if (!$this->getRequest()->isPost())
131
- Mage::throwException('Wrong request type.');
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
- // get request variables
134
  $request = $this->getRequest()->getPost();
135
  if (empty($request))
136
- Mage::throwException('Request doesn\'t contain POST elements.');
137
 
138
- // check order id
139
  if (empty($request['MC_orderid']) || strlen($request['MC_orderid']) > 50)
140
- Mage::throwException('Missing or invalid order ID');
141
 
142
- // load order for further validation
143
  $this->_order = Mage::getModel('sales/order')->loadByIncrementId($request['MC_orderid']);
144
  if (!$this->_order->getId())
145
- Mage::throwException('Order not found');
146
 
147
  $this->_paymentInst = $this->_order->getPayment()->getMethodInstance();
148
 
149
- // check transaction password
150
  if ($this->_paymentInst->getConfigData('transaction_password') != $request['callbackPW'])
151
- Mage::throwException('Transaction password wrong');
152
 
153
 
154
  return $request;
@@ -161,20 +176,20 @@ class Phoenix_Worldpay_ProcessingController extends Mage_Core_Controller_Front_A
161
  {
162
  // check transaction amount and currency
163
  if ($this->_paymentInst->getConfigData('use_store_currency')) {
164
- $price = number_format($this->_order->getGrandTotal(),2,'.','');
165
- $currency = $this->_order->getOrderCurrencyCode();
166
- } else {
167
- $price = number_format($this->_order->getBaseGrandTotal(),2,'.','');
168
- $currency = $this->_order->getBaseCurrencyCode();
169
- }
170
-
171
- // check transaction amount
172
  if ($price != $request['authAmount'])
173
- Mage::throwException('Transaction currency doesn\'t match.');
174
 
175
- // check transaction currency
176
  if ($currency != $request['authCurrency'])
177
- Mage::throwException('Transaction currency doesn\'t match.');
178
 
179
  // save transaction ID and AVS info
180
  $this->_order->getPayment()->setLastTransId($request['transId']);
@@ -187,10 +202,10 @@ class Phoenix_Worldpay_ProcessingController extends Mage_Core_Controller_Front_A
187
  $invoice->register()->capture();
188
  $this->_order->addRelatedObject($invoice);
189
  }
190
- $this->_order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, Mage::helper('worldpay')->__('authorize: Customer returned successfully'));
191
  break;
192
  case 'E':
193
- $this->_order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, Mage::helper('worldpay')->__('preauthorize: Customer returned successfully'));
194
  break;
195
  }
196
 
71
  */
72
  public function responseAction()
73
  {
74
+ try {
75
  $request = $this->_checkReturnedPost();
76
  if ($request['transStatus'] == 'Y') {
77
  $this->_processSale($request);
80
  } else {
81
  Mage::throwException('Transaction was not successfull.');
82
  }
83
+ } catch (Mage_Core_Exception $e) {
84
+ $this->getResponse()->setBody(
85
+ $this->getLayout()
86
+ ->createBlock($this->_failureBlockType)
87
+ ->setOrder($this->_order)
88
+ ->toHtml()
89
+ );
90
+ }
91
  }
92
 
93
  /**
98
  try {
99
  $session = $this->_getCheckout();
100
  $quoteId = $session->getWorldpayQuoteId();
101
+ $session->unsWorldpayRealOrderId();
102
+ $session->setQuoteId($quoteId);
103
+ $session->setLastSuccessQuoteId($quoteId);
104
+ $session->getQuote()->setIsActive(false)->save();
105
  $this->_redirect('checkout/onepage/success');
106
  return;
107
  } catch (Mage_Core_Exception $e) {
129
  */
130
  protected function _checkReturnedPost()
131
  {
132
+ // check request type
133
  if (!$this->getRequest()->isPost())
134
+ Mage::throwException('Wrong request type.');
135
+
136
+ // validate request ip coming from WorldPay/RBS subnet
137
+ $helper = Mage::helper('core/http');
138
+ if (method_exists($helper, 'getRemoteAddr')) {
139
+ $remoteAddr = $helper->getRemoteAddr();
140
+ } else {
141
+ $request = $this->getRequest()->getServer();
142
+ $remoteAddr = $request['REMOTE_ADDR'];
143
+ }
144
+ if (substr($remoteAddr,0,11) != '155.136.16.') {
145
+ Mage::throwException('IP can\'t be validated as WorldPay-IP.');
146
+ }
147
 
148
+ // get request variables
149
  $request = $this->getRequest()->getPost();
150
  if (empty($request))
151
+ Mage::throwException('Request doesn\'t contain POST elements.');
152
 
153
+ // check order id
154
  if (empty($request['MC_orderid']) || strlen($request['MC_orderid']) > 50)
155
+ Mage::throwException('Missing or invalid order ID');
156
 
157
+ // load order for further validation
158
  $this->_order = Mage::getModel('sales/order')->loadByIncrementId($request['MC_orderid']);
159
  if (!$this->_order->getId())
160
+ Mage::throwException('Order not found');
161
 
162
  $this->_paymentInst = $this->_order->getPayment()->getMethodInstance();
163
 
164
+ // check transaction password
165
  if ($this->_paymentInst->getConfigData('transaction_password') != $request['callbackPW'])
166
+ Mage::throwException('Transaction password wrong');
167
 
168
 
169
  return $request;
176
  {
177
  // check transaction amount and currency
178
  if ($this->_paymentInst->getConfigData('use_store_currency')) {
179
+ $price = number_format($this->_order->getGrandTotal(),2,'.','');
180
+ $currency = $this->_order->getOrderCurrencyCode();
181
+ } else {
182
+ $price = number_format($this->_order->getBaseGrandTotal(),2,'.','');
183
+ $currency = $this->_order->getBaseCurrencyCode();
184
+ }
185
+
186
+ // check transaction amount
187
  if ($price != $request['authAmount'])
188
+ Mage::throwException('Transaction currency doesn\'t match.');
189
 
190
+ // check transaction currency
191
  if ($currency != $request['authCurrency'])
192
+ Mage::throwException('Transaction currency doesn\'t match.');
193
 
194
  // save transaction ID and AVS info
195
  $this->_order->getPayment()->setLastTransId($request['transId']);
202
  $invoice->register()->capture();
203
  $this->_order->addRelatedObject($invoice);
204
  }
205
+ $this->_order->addStatusToHistory($this->_paymentInst->getConfigData('order_status'), Mage::helper('worldpay')->__('authorize: Customer returned successfully'));
206
  break;
207
  case 'E':
208
+ $this->_order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, $this->_paymentInst->getConfigData('order_status'), Mage::helper('worldpay')->__('preauthorize: Customer returned successfully'));
209
  break;
210
  }
211
 
app/code/community/Phoenix/Worldpay/etc/config.xml CHANGED
@@ -21,7 +21,7 @@
21
  <config>
22
  <modules>
23
  <Phoenix_Worldpay>
24
- <version>1.2.0</version>
25
  </Phoenix_Worldpay>
26
  </modules>
27
  <global>
21
  <config>
22
  <modules>
23
  <Phoenix_Worldpay>
24
+ <version>1.2.2</version>
25
  </Phoenix_Worldpay>
26
  </modules>
27
  <global>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Phoenix_Worldpay</name>
4
- <version>1.2.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
@@ -19,15 +19,11 @@ Notice: This extension is still beta. We recommend to test all transactions in y
19
  The extension is developed and maintained by the German Magento Silver Partner Phoenix Medien (http://www.phoenix-medien.de).
20
 
21
  The development was sponsored by liaison dangereuse (http://www.liaison-dangereuse.de).</description>
22
- <notes>- Remote admin functionalities for capture and refund in the backend
23
- - Rework of the complete controller
24
- - Cancel now reloads shopping cart correctly
25
- - Fixes session issue during callback
26
- - AVS Status is now visible in the backend</notes>
27
  <authors><author><name>Phoenix Medien</name><user>auto-converted</user><email>info@phoenix-medien.de</email></author></authors>
28
- <date>2010-02-04</date>
29
- <time>18:21:10</time>
30
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="worldpay"><dir name="pdf"><file name="info.phtml" hash="3a92c60f5c05a3e51df366cee651edd6"/></dir><file name="info.phtml" hash="d70ad71aa960ce0c6d4ec8609dadf7e3"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="worldpay.xml" hash="ac4191773623ae2ad6170f363866ed43"/></dir><dir name="template"><dir name="worldpay"><file name="blank.phtml" hash="8b7d8aa0521878b2dd796acfd4d655b6"/><file name="cancel.phtml" hash="350348b8fecb9b7c2b1045d1a8edd9c7"/><file name="failure.phtml" hash="77b202de38902c9e6458218bdce07de8"/><file name="form.phtml" hash="8c7184cbaffc115349de415d12273528"/><file name="info.phtml" hash="d33c7ffde885e4953a975201562cba8e"/><file name="redirect.phtml" hash="84d38770a43262c890094c132dc2bd5c"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Phoenix_Worldpay.csv" hash="8a41fe546b9f6fb3d18c0ccf727ea082"/></dir><dir name="en_US"><file name="Phoenix_Worldpay.csv" hash="d5ff38bb74afd4e7715cfa54134fd57d"/></dir></target><target name="mageetc"><dir name="modules"><file name="Phoenix_Worldpay.xml" hash="52b9dc5cd0d94ab43d8691438f090617"/></dir></target><target name="magecommunity"><dir name="Phoenix"><dir name="Worldpay"><dir name="Block"><file name="Cancel.php" hash="b0f213ee8e45d0b8b48a6fad48f05017"/><file name="Failure.php" hash="5add6ed9890109ba624b7a16bc0504f5"/><file name="Form.php" hash="d279b2d502e875e155101007eef7ebc5"/><file name="Info.php" hash="24bc51b1b86cd3a020982b09e8695c22"/><file name="Processing.php" hash="0f495f4f01f213d999291164d8d6a0c6"/><file name="Redirect.php" hash="c17fea696a1900eef85226022efe4670"/><file name="Success.php" hash="0c072e272d53a0b24e5157201cd65877"/></dir><dir name="controllers"><file name="ProcessingController.php" hash="22d14717383048a6ec1c57ca3ea9d7d0"/></dir><dir name="etc"><file name="config.xml" hash="d75b8d2203cb2331d5cee474b8aa4f21"/><file name="system.xml" hash="5361e90063e729e4c01ae95a074d0fc4"/></dir><dir name="Helper"><file name="Data.php" hash="354473f472247a9dae11a1fac0cef407"/></dir><dir name="Model"><dir name="Config"><dir name="Backend"><file name="Instid.php" hash="20c846f756ccc1edc0673e6c9ab464bf"/></dir></dir><dir name="Source"><file name="RequestType.php" hash="795d51b4c3f04bb00cf6cca5a3180cd7"/><file name="TransactionMode.php" hash="da4cadb5df1213edc34f22b67235d374"/></dir><file name="Cc.php" hash="cf6b3bff52b5aedd85ff94cc59a0fc8e"/><file name="Config.php" hash="9098369b245a824396354e1b64cd47ab"/></dir></dir></dir></target></contents>
31
  <compatible/>
32
  <dependencies/>
33
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Phoenix_Worldpay</name>
4
+ <version>1.2.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
19
  The extension is developed and maintained by the German Magento Silver Partner Phoenix Medien (http://www.phoenix-medien.de).
20
 
21
  The development was sponsored by liaison dangereuse (http://www.liaison-dangereuse.de).</description>
22
+ <notes>- Minor fix for Magento 1.4</notes>
 
 
 
 
23
  <authors><author><name>Phoenix Medien</name><user>auto-converted</user><email>info@phoenix-medien.de</email></author></authors>
24
+ <date>2010-04-06</date>
25
+ <time>13:22:02</time>
26
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="worldpay"><dir name="pdf"><file name="info.phtml" hash="3a92c60f5c05a3e51df366cee651edd6"/></dir><file name="info.phtml" hash="d70ad71aa960ce0c6d4ec8609dadf7e3"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="worldpay.xml" hash="ac4191773623ae2ad6170f363866ed43"/></dir><dir name="template"><dir name="worldpay"><file name="blank.phtml" hash="8b7d8aa0521878b2dd796acfd4d655b6"/><file name="cancel.phtml" hash="350348b8fecb9b7c2b1045d1a8edd9c7"/><file name="failure.phtml" hash="77b202de38902c9e6458218bdce07de8"/><file name="form.phtml" hash="8c7184cbaffc115349de415d12273528"/><file name="info.phtml" hash="d33c7ffde885e4953a975201562cba8e"/><file name="redirect.phtml" hash="84d38770a43262c890094c132dc2bd5c"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Phoenix_Worldpay.csv" hash="8a41fe546b9f6fb3d18c0ccf727ea082"/></dir><dir name="en_US"><file name="Phoenix_Worldpay.csv" hash="d5ff38bb74afd4e7715cfa54134fd57d"/></dir></target><target name="mageetc"><dir name="modules"><file name="Phoenix_Worldpay.xml" hash="52b9dc5cd0d94ab43d8691438f090617"/></dir></target><target name="magecommunity"><dir name="Phoenix"><dir name="Worldpay"><dir name="Block"><file name="Cancel.php" hash="b0f213ee8e45d0b8b48a6fad48f05017"/><file name="Failure.php" hash="5add6ed9890109ba624b7a16bc0504f5"/><file name="Form.php" hash="d279b2d502e875e155101007eef7ebc5"/><file name="Info.php" hash="24bc51b1b86cd3a020982b09e8695c22"/><file name="Redirect.php" hash="ee8eb2b8cdabaf9ae0dea66fd7362777"/><file name="Success.php" hash="0c072e272d53a0b24e5157201cd65877"/></dir><dir name="controllers"><file name="ProcessingController.php" hash="a3e931feef3d7a76cf2c6fa8d330708d"/></dir><dir name="etc"><file name="config.xml" hash="d75be225c9a212c0c92751d84ff185c6"/><file name="system.xml" hash="5361e90063e729e4c01ae95a074d0fc4"/></dir><dir name="Helper"><file name="Data.php" hash="354473f472247a9dae11a1fac0cef407"/></dir><dir name="Model"><dir name="Config"><dir name="Backend"><file name="Instid.php" hash="07147ceac69c3c19593b4a24873f15cc"/></dir></dir><dir name="Source"><file name="RequestType.php" hash="795d51b4c3f04bb00cf6cca5a3180cd7"/><file name="TransactionMode.php" hash="da4cadb5df1213edc34f22b67235d374"/></dir><file name="Cc.php" hash="cf6b3bff52b5aedd85ff94cc59a0fc8e"/><file name="Config.php" hash="9098369b245a824396354e1b64cd47ab"/></dir></dir></dir></target></contents>
27
  <compatible/>
28
  <dependencies/>
29
  </package>