Netpay_HostedPage_Check_Out - Version 1.0.6

Version Notes

fixed email send, fixed order status

Download this release

Release Info

Developer Udi
Extension Netpay_HostedPage_Check_Out
Version 1.0.6
Comparing to
See all releases


Code changes from version 1.0.5 to 1.0.6

app/code/community/Netpay/HostedPage/Block/Redirect.php CHANGED
@@ -8,7 +8,7 @@ class Netpay_HostedPage_Block_Redirect extends Mage_Core_Block_Abstract
8
  $form->setAction($hpp->getNetpayUrl())
9
  ->setId('pay')
10
  ->setName('pay')
11
- ->setMethod('POST')
12
  ->setUseContainer(true);
13
  foreach ($hpp->getNetpayCheckoutFormFields() as $field=>$value)
14
  $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
8
  $form->setAction($hpp->getNetpayUrl())
9
  ->setId('pay')
10
  ->setName('pay')
11
+ ->setMethod('GET')
12
  ->setUseContainer(true);
13
  foreach ($hpp->getNetpayCheckoutFormFields() as $field=>$value)
14
  $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
app/code/community/Netpay/HostedPage/controllers/RedirectController.php CHANGED
@@ -18,31 +18,38 @@ class Netpay_HostedPage_RedirectController extends Mage_Core_Controller_Front_Ac
18
  ->toHtml());
19
  }
20
 
21
- public function successAction() {
22
- $session = Mage::getSingleton('checkout/session');
23
- if ($this->getRequest()->getParam('replyCode') == self::RESPONSE_CODE_APPROVED) {
24
- $trans_id = $this->getRequest()->getParam('trans_id');
25
- /*
26
- $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
27
- $payment = Mage::getSingleton('sales/order_payment');
28
- $payment->setAdditionalData($trans_id);
29
- $session->setQuoteId($trans_id);
30
- $payment->setStatus('APPROVED');
31
- $payment->setLastTransId($trans_id);
32
- */
33
- $session->getQuote()->setIsActive(false)->collectTotals()->save();
34
- /*
35
- $order->addPayment($payment);
36
- $payment->save();
37
- $order->save();
38
- echo $payment->getAdditionalData() . ' ' . $payment->getId() . ' ' . $session->getQuote()->getId();
39
- exit();
40
- */
41
- $this->_redirect('checkout/onepage/success', array('_secure'=>true));
42
- }else{
43
- //$order->cancel()->save();
44
- $this->_redirect('checkout/cart');
 
 
 
 
 
45
  }
 
 
46
  }
47
  }
48
 
18
  ->toHtml());
19
  }
20
 
21
+ public function successAction()
22
+ {
23
+ $session = Mage::getSingleton('checkout/session');
24
+ $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
25
+ //$order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
26
+ if ($this->getRequest()->getParam('replyCode') == self::RESPONSE_CODE_APPROVED) {
27
+ $trans_id = $this->getRequest()->getParam('trans_id');
28
+ $session->setQuoteId($trans_id);
29
+ $order->sendNewOrderEmail();
30
+ $order->setEmailSent(true);
31
+ $order->setStatus('pending');
32
+ $order->save();
33
+ /*
34
+ $payment = Mage::getSingleton('sales/order_payment');
35
+ $payment->setAdditionalData($trans_id);
36
+ $payment->setStatus('APPROVED');
37
+ $payment->setLastTransId($trans_id);
38
+ $session->getQuote()->setIsActive(false)->collectTotals()->save();
39
+ $order->addPayment($payment);
40
+ $payment->save();
41
+ $order->save();
42
+ echo $payment->getAdditionalData() . ' ' . $payment->getId() . ' ' . $session->getQuote()->getId();
43
+ exit();
44
+ */
45
+ $this->_redirect('checkout/onepage/success', array('_secure'=>true));
46
+ }else{
47
+ if ($order->getId()) {
48
+ $order->setStatus('canceled');
49
+ $order->cancel()->save();
50
  }
51
+ $this->_redirect('checkout/cart');
52
+ }
53
  }
54
  }
55
 
app/code/community/Netpay/HostedPage/etc/config.xml CHANGED
@@ -58,7 +58,7 @@
58
  <HostedPage>
59
  <active>1</active>
60
  <model>HostedPage/paymentMethod</model>
61
- <order_status>pending</order_status>
62
  <title>Netpay-intl</title>
63
  <payment_action>authorize</payment_action>
64
  <allowspecific>0</allowspecific>
58
  <HostedPage>
59
  <active>1</active>
60
  <model>HostedPage/paymentMethod</model>
61
+ <order_status>pending_payment</order_status>
62
  <title>Netpay-intl</title>
63
  <payment_action>authorize</payment_action>
64
  <allowspecific>0</allowspecific>
app/code/community/Netpay/HostedPage/etc/system.xml CHANGED
@@ -30,15 +30,6 @@
30
  <show_in_website>1</show_in_website>
31
  <show_in_store>0</show_in_store>
32
  </active>
33
- <order_status translate="label">
34
- <label>New Order Status</label>
35
- <frontend_type>select</frontend_type>
36
- <source_model>adminhtml/system_config_source_order_status_newprocessing</source_model>
37
- <sort_order>2</sort_order>
38
- <show_in_default>1</show_in_default>
39
- <show_in_website>1</show_in_website>
40
- <show_in_store>0</show_in_store>
41
- </order_status>
42
  <payment_action translate="label">
43
  <label>Payment Action</label>
44
  <frontend_type>select</frontend_type>
30
  <show_in_website>1</show_in_website>
31
  <show_in_store>0</show_in_store>
32
  </active>
 
 
 
 
 
 
 
 
 
33
  <payment_action translate="label">
34
  <label>Payment Action</label>
35
  <frontend_type>select</frontend_type>
app/code/community/Netpay/HostedPage/model/PaymentMethod.php CHANGED
@@ -3,7 +3,7 @@ class Netpay_HostedPage_Model_PaymentMethod extends Mage_Payment_Model_Method_Ab
3
  {
4
  const CGI_URL = 'https://services.netpay-intl.com/hosted/';
5
  protected $_code = 'HostedPage';
6
- protected $_isGateway = false;
7
  protected $_canAuthorize = true;
8
  protected $_canCapture = true;
9
  protected $_canCapturePartial = false;
@@ -31,22 +31,22 @@ class Netpay_HostedPage_Model_PaymentMethod extends Mage_Payment_Model_Method_Ab
31
  }
32
 
33
  public function getNetpayCheckoutFormFields() {
34
- $nTransType = 0;
 
35
  $order_id = $this->getCheckout()->getLastRealOrderId();
36
  $order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
37
- $signature = base64_encode(md5($this->getConfigData('CompanyNum') . trim(round($order->getGrandTotal(), 2)) . $order->getBaseCurrencyCode() . $this->getConfigData('HashKey'), true));
38
- if ($this->getConfigData('payment_action') == 'authorize') $nTransType = 1;
39
- $params = array(
40
- 'trans_refNum' => $order_id,
41
- 'merchantID' => $this->getConfigData('CompanyNum'),
42
- 'disp_payFor' => 'Payment for order #'.$order_id,
43
- 'trans_amount' => trim(round($order->getGrandTotal(), 2)),
44
- 'trans_currency' => $order->getBaseCurrencyCode(),
45
- 'trans_type' => $nTransType,
46
- 'signature' => $signature,
47
- 'disp_lng' => $this->getConfigData('UILanguage'),
48
- 'url_redirect' => Mage::getUrl('HostedPage/Redirect/success')
49
- );
50
  if (!empty($order)) {
51
  $billing = $order->getBillingAddress();
52
  if (!empty($billing)) {
@@ -61,6 +61,8 @@ class Netpay_HostedPage_Model_PaymentMethod extends Mage_Payment_Model_Method_Ab
61
  if ($billing->getCustomerEmail()) $params['client_email'] = $billing->getCustomerEmail();
62
  }
63
  }
 
 
64
  return $params;
65
  }
66
  }
3
  {
4
  const CGI_URL = 'https://services.netpay-intl.com/hosted/';
5
  protected $_code = 'HostedPage';
6
+ protected $_isGateway = true;
7
  protected $_canAuthorize = true;
8
  protected $_canCapture = true;
9
  protected $_canCapturePartial = false;
31
  }
32
 
33
  public function getNetpayCheckoutFormFields() {
34
+ $nTransType = 0;
35
+ if ($this->getConfigData('payment_action') == 'authorize') $nTransType = 1;
36
  $order_id = $this->getCheckout()->getLastRealOrderId();
37
  $order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
38
+ $signature = base64_encode(md5($this->getConfigData('CompanyNum') . trim(round($order->getGrandTotal(), 2)) . $order->getBaseCurrencyCode() . $this->getConfigData('HashKey'), true));
39
+
40
+ $params = array();
41
+ $params['trans_refNum'] = $order_id;
42
+ $params['merchantID'] = $this->getConfigData('CompanyNum');
43
+ $params['disp_payFor'] = 'Payment for order #'.$order_id;
44
+ $params['trans_amount'] = trim(round($order->getGrandTotal(), 2));
45
+ $params['trans_currency'] = $order->getBaseCurrencyCode();
46
+ $params['trans_type'] = $nTransType;
47
+ $params['signature'] = $signature;
48
+ $params['disp_lng'] = $this->getConfigData('UILanguage');
49
+ $params['url_redirect'] = Mage::getUrl('HostedPage/Redirect/success');
 
50
  if (!empty($order)) {
51
  $billing = $order->getBillingAddress();
52
  if (!empty($billing)) {
61
  if ($billing->getCustomerEmail()) $params['client_email'] = $billing->getCustomerEmail();
62
  }
63
  }
64
+ $order->setStatus('pending_payment');
65
+ $order->save();
66
  return $params;
67
  }
68
  }
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Netpay_HostedPage_Check_Out</name>
4
- <version>1.0.5</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.netpay-intl.com">Freeware</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Netpay's HostedPage magento integration</summary>
10
  <description>This module is use to process from you magento online store</description>
11
- <notes>no comments</notes>
12
  <authors><author><name>Udi</name><user>Udi</user><email>udi@ctrlz.co.il</email></author></authors>
13
- <date>2012-01-02</date>
14
- <time>15:02:13</time>
15
- <contents><target name="magecommunity"><dir name="Netpay"><dir name="HostedPage"><dir name="Block"><file name="Redirect.php" hash="1b126ed3e8700a8b2c5b9d42bc51fa51"/></dir><dir name="controllers"><file name="RedirectController.php" hash="9757e985282dcea062328fb961eb84d9"/></dir><dir name="etc"><file name="config.xml" hash="cbfe2af0be683d14ceb39460b9a915a4"/><file name="system.xml" hash="d827edfbae7a9605c5ec2ae3418cfaef"/></dir><dir name="model"><file name="PaymentMethod.php" hash="ab841ebd9efbd16b42bd8510f924e778"/></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Netpay_HostedPage.xml" hash="946d3d21576ddac0a349b3ea1b07b13a"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>5.6.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Netpay_HostedPage_Check_Out</name>
4
+ <version>1.0.6</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.netpay-intl.com">Freeware</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Netpay's HostedPage magento integration</summary>
10
  <description>This module is use to process from you magento online store</description>
11
+ <notes>fixed email send, fixed order status</notes>
12
  <authors><author><name>Udi</name><user>Udi</user><email>udi@ctrlz.co.il</email></author></authors>
13
+ <date>2012-01-12</date>
14
+ <time>15:01:33</time>
15
+ <contents><target name="magecommunity"><dir name="Netpay"><dir name="HostedPage"><dir name="Block"><file name="Redirect.php" hash="5ec95ad443aa4fd0c864fbd04264eab9"/></dir><dir name="controllers"><file name="RedirectController.php" hash="4dfd5ff83879c6f25fc74e57d7aca426"/></dir><dir name="etc"><file name="config.xml" hash="6eed430d0cdc5211b7f050ba1790e35e"/><file name="system.xml" hash="1b5ec31bfcd5964bfa59c5d33bd0bedf"/></dir><dir name="model"><file name="PaymentMethod.php" hash="c4223c5d2a30623743ec883be6f343e8"/></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Netpay_HostedPage.xml" hash="946d3d21576ddac0a349b3ea1b07b13a"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>5.6.0</max></php></required></dependencies>
18
  </package>