Onecard_Paymentmethod - Version 1.0.1

Version Notes

Fix issues related to invoices ( automatically create invoices and change orders states )

Download this release

Release Info

Developer Moe
Extension Onecard_Paymentmethod
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/code/local/Onecard/Onecardpay/controllers/PaymentController.php CHANGED
@@ -64,7 +64,46 @@ class Onecard_Onecardpay_PaymentController extends Mage_Core_Controller_Front_Ac
64
 
65
  $order = Mage::getModel('sales/order');
66
  $order->loadByIncrementId($orderId);
67
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  $order->sendNewOrderEmail();
70
  $order->setEmailSent(true);
64
 
65
  $order = Mage::getModel('sales/order');
66
  $order->loadByIncrementId($orderId);
67
+ //$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
68
+
69
+ /** trying to create invoice **/
70
+ try {
71
+
72
+
73
+ if(!$order->canInvoice()):
74
+
75
+ //Mage::throwException(Mage::helper('core')->__('cannot create invoice !'));
76
+ Mage::throwException(Mage::helper('core')->__('cannot create an invoice !'));
77
+
78
+ else:
79
+
80
+ /** create invoice **/
81
+ //$invoiceId = Mage::getModel('sales/order_invoice_api')->create($order->getIncremenetId(), array());
82
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
83
+
84
+ if(!$invoice->getTotalQty()):
85
+ Mage::throwException(Mage::helper('core')->__('cannot create an invoice without products !'));
86
+ endif;
87
+
88
+ $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
89
+ $invoice->register();
90
+ $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
91
+ $transactionSave->save();
92
+
93
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
94
+ /** load invoice **/
95
+ //$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceId);
96
+ /** pay invoice **/
97
+ //$invoice->capture()->save();
98
+
99
+
100
+
101
+ endif;
102
+ }
103
+ catch(Mage_Core_Exception $e){
104
+ Mage::throwException(Mage::helper('core')->__('cannot create an invoice !'));
105
+ }
106
+
107
 
108
  $order->sendNewOrderEmail();
109
  $order->setEmailSent(true);
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Onecard_Paymentmethod</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Onecard integration for magento</summary>
10
  <description>it allow users to use Onecard payment gateway in magento</description>
11
- <notes>First onecard extension release</notes>
12
  <authors><author><name>Moe</name><user>Ghashim</user><email>moe@shopgo.me</email></author></authors>
13
- <date>2012-08-02</date>
14
- <time>11:30:28</time>
15
- <contents><target name="magelocal"><dir name="Onecard"><dir name="Onecardpay"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Currencyoptions.php" hash="fc83780f82046c35823e74b1cd05b3f0"/><file name="Languageoptions.php" hash="c133d13eb64e99d7677bc817182c6c6c"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="50e632324654e42c438a831d96863bce"/></dir><dir name="Model"><file name="Pay.php" hash="fa02a9eaf39a0dab41874e1f919b788c"/></dir><dir name="controllers"><file name="PaymentController.php" hash="45217d3fc2d2a1bb9b63b85442fb3491"/></dir><dir name="etc"><file name="config.xml" hash="016825c62621241a5a1a7fd7998e0242"/><file name="system.xml" hash="bb99cdc5e10da236c6183996a2863f36"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="onecard"><file name="redirect.phtml" hash="b07cc83face7508d89c52daf11502067"/><file name="success.phtml" hash="857f02535c3b6908da9de15013cf4df5"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Onecard_Onecardpay.xml" hash="9104f0d72530a39a89284678fa446130"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Onecard_Paymentmethod</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Onecard integration for magento</summary>
10
  <description>it allow users to use Onecard payment gateway in magento</description>
11
+ <notes>Fix issues related to invoices ( automatically create invoices and change orders states )</notes>
12
  <authors><author><name>Moe</name><user>Ghashim</user><email>moe@shopgo.me</email></author></authors>
13
+ <date>2012-08-16</date>
14
+ <time>12:51:08</time>
15
+ <contents><target name="magelocal"><dir name="Onecard"><dir name="Onecardpay"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Currencyoptions.php" hash="fc83780f82046c35823e74b1cd05b3f0"/><file name="Languageoptions.php" hash="c133d13eb64e99d7677bc817182c6c6c"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="50e632324654e42c438a831d96863bce"/></dir><dir name="Model"><file name="Pay.php" hash="fa02a9eaf39a0dab41874e1f919b788c"/></dir><dir name="controllers"><file name="PaymentController.php" hash="167001210de55740127c747a87ea282f"/></dir><dir name="etc"><file name="config.xml" hash="016825c62621241a5a1a7fd7998e0242"/><file name="system.xml" hash="bb99cdc5e10da236c6183996a2863f36"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="onecard"><file name="redirect.phtml" hash="b07cc83face7508d89c52daf11502067"/><file name="success.phtml" hash="857f02535c3b6908da9de15013cf4df5"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Onecard_Onecardpay.xml" hash="9104f0d72530a39a89284678fa446130"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>