Version Notes
Fix issues related to invoices ( automatically create invoices and change orders states )
Download this release
Release Info
| Developer | Moe |
| Extension | Cashu_Paymentmethod |
| Version | 1.0.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.0 to 1.0.1
app/code/local/Cashu/Paymentmethod/controllers/PaymentController.php
CHANGED
|
@@ -33,7 +33,45 @@ class Cashu_Paymentmethod_PaymentController extends Mage_Core_Controller_Front_A
|
|
| 33 |
// Payment was successful, so update the order's state, send order email and move to the success page
|
| 34 |
$order = Mage::getModel('sales/order');
|
| 35 |
$order->loadByIncrementId($orderId);
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
$order->sendNewOrderEmail();
|
| 39 |
$order->setEmailSent(true);
|
| 33 |
// Payment was successful, so update the order's state, send order email and move to the success page
|
| 34 |
$order = Mage::getModel('sales/order');
|
| 35 |
$order->loadByIncrementId($orderId);
|
| 36 |
+
//$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
|
| 37 |
+
|
| 38 |
+
/** trying to create invoice **/
|
| 39 |
+
try {
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
if(!$order->canInvoice()):
|
| 43 |
+
|
| 44 |
+
//Mage::throwException(Mage::helper('core')->__('cannot create invoice !'));
|
| 45 |
+
Mage::throwException(Mage::helper('core')->__('cannot create an invoice !'));
|
| 46 |
+
|
| 47 |
+
else:
|
| 48 |
+
|
| 49 |
+
/** create invoice **/
|
| 50 |
+
//$invoiceId = Mage::getModel('sales/order_invoice_api')->create($order->getIncremenetId(), array());
|
| 51 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
| 52 |
+
|
| 53 |
+
if(!$invoice->getTotalQty()):
|
| 54 |
+
Mage::throwException(Mage::helper('core')->__('cannot create an invoice without products !'));
|
| 55 |
+
endif;
|
| 56 |
+
|
| 57 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
| 58 |
+
$invoice->register();
|
| 59 |
+
$transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
|
| 60 |
+
$transactionSave->save();
|
| 61 |
+
|
| 62 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
|
| 63 |
+
/** load invoice **/
|
| 64 |
+
//$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceId);
|
| 65 |
+
/** pay invoice **/
|
| 66 |
+
//$invoice->capture()->save();
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
endif;
|
| 71 |
+
}
|
| 72 |
+
catch(Mage_Core_Exception $e){
|
| 73 |
+
Mage::throwException(Mage::helper('core')->__('cannot create an invoice !'));
|
| 74 |
+
}
|
| 75 |
|
| 76 |
$order->sendNewOrderEmail();
|
| 77 |
$order->setEmailSent(true);
|
app/design/frontend/default/default/template/cashu/redirect.phtml
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
// Retrieve order
|
| 3 |
-
$_order = new Mage_Sales_Model_Order();
|
| 4 |
-
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
| 5 |
-
$_order->loadByIncrementId($orderId);
|
| 6 |
-
|
| 7 |
-
//var_dump($_order->getAllItems());
|
| 8 |
-
$items_description = '';
|
| 9 |
-
|
| 10 |
-
$items = $_order->getAllItems();
|
| 11 |
-
|
| 12 |
-
foreach($items as $item){
|
| 13 |
-
|
| 14 |
-
$items_description .= $item->getName();
|
| 15 |
-
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
//var_dump($items_description);
|
| 19 |
-
|
| 20 |
-
$encryption_keyword = Mage::getStoreConfig('payment/paymentmethod/encryption_keyword',Mage::app()->getStore());
|
| 21 |
-
$payment_gateway_url = Mage::getStoreConfig('payment/paymentmethod/payment_gateway_url',Mage::app()->getStore());
|
| 22 |
-
$language = Mage::getStoreConfig('payment/paymentmethod/language',Mage::app()->getStore());
|
| 23 |
-
$currency = Mage::getStoreConfig('payment/paymentmethod/currency',Mage::app()->getStore());
|
| 24 |
-
$merchant_id = Mage::getStoreConfig('payment/paymentmethod/merchant_id',Mage::app()->getStore());
|
| 25 |
-
|
| 26 |
-
//exit();
|
| 27 |
-
?>
|
| 28 |
-
<form name="cashupaymentform" action="<?php echo $payment_gateway_url;?>" method="post">
|
| 29 |
-
<input type="hidden" name="merchant_id" value="<?php echo $merchant_id;?>">
|
| 30 |
-
<input type="hidden" name="token" value="<?php echo md5($merchant_id.':'.round($_order->getBaseGrandTotal(),2).':'.$currency.':'.$encryption_keyword);?>">
|
| 31 |
-
<input type="hidden" name="display_text" value="<?php echo $items_description;?>">
|
| 32 |
-
<input type="hidden" name="currency" value="<?php echo $currency;?>">
|
| 33 |
-
<input type="hidden" name="amount" value="<?php echo round($_order->getBaseGrandTotal(),2);?>">
|
| 34 |
-
<input type="hidden" name="language" value="<?php echo $language;?>">
|
| 35 |
-
<input type="hidden" name="session_id" value="asdasd-234-asdasd">
|
| 36 |
-
<input type="hidden" name="txt1" value="<?php echo $orderId; ?>">
|
| 37 |
-
</form>
|
| 38 |
-
<script type="text/javascript">
|
| 39 |
-
document.cashupaymentform.submit();
|
| 40 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/default/default/template/cashu/success.phtml
DELETED
|
@@ -1,39 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/*
|
| 3 |
-
$_order = new Mage_Sales_Model_Order();
|
| 4 |
-
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
| 5 |
-
$_order->loadByIncrementId($orderId);
|
| 6 |
-
*/
|
| 7 |
-
$orderId = $this->getOrder();
|
| 8 |
-
$home_url = Mage::helper('core/url')->getHomeUrl();
|
| 9 |
-
|
| 10 |
-
//$checkout_order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
| 11 |
-
$current_order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
| 12 |
-
|
| 13 |
-
?>
|
| 14 |
-
<?php if($this->helper('customer')->isLoggedIn()): ?>
|
| 15 |
-
<div class="col-main">
|
| 16 |
-
<div class="page-title">
|
| 17 |
-
<h1>Your order has been received.</h1>
|
| 18 |
-
</div>
|
| 19 |
-
<h2 class="sub-title">Thank you for your purchase!</h2>
|
| 20 |
-
<p>Your order # is: <a href="<?php echo $home_url;?>sales/order/view/order_id/<?php echo $current_order->getId();?>"><?php echo $orderId;?></a>.</p>
|
| 21 |
-
<p>You will receive an order confirmation email with details of your order and a link to track its progress.</p>
|
| 22 |
-
<p>Click <a href="<?php echo $home_url;?>sales/order/print/order_id/<?php echo $current_order->getId();?>" onclick="this.target='_blank'">here to print</a> a copy of your order confirmation. </p>
|
| 23 |
-
<div class="buttons-set">
|
| 24 |
-
<button type="button" class="button" title="Continue Shopping" onclick="window.location='<?php echo $home_url;?>'"><span><span>Continue Shopping</span></span></button>
|
| 25 |
-
</div>
|
| 26 |
-
</div>
|
| 27 |
-
<?php else: ?>
|
| 28 |
-
<div class="col-main">
|
| 29 |
-
<div class="page-title">
|
| 30 |
-
<h1>Your order has been received.</h1>
|
| 31 |
-
</div>
|
| 32 |
-
<h2 class="sub-title">Thank you for your purchase!</h2>
|
| 33 |
-
<p>Your order # is: <?php echo $orderId;?>.</p>
|
| 34 |
-
<p>You will receive an order confirmation email with details of your order and a link to track its progress.</p>
|
| 35 |
-
<div class="buttons-set">
|
| 36 |
-
<button type="button" class="button" title="Continue Shopping" onclick="window.location='<?php echo $home_url;?>'"><span><span>Continue Shopping</span></span></button>
|
| 37 |
-
</div>
|
| 38 |
-
</div>
|
| 39 |
-
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Cashu_Paymentmethod</name>
|
| 4 |
-
<version>1.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>OSL</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Cashu integration for magento</summary>
|
| 10 |
<description>it allow users to use Cashu payment gateway in magento</description>
|
| 11 |
-
<notes>
|
| 12 |
<authors><author><name>Moe</name><user>Ghashim</user><email>moe@shopgo.me</email></author></authors>
|
| 13 |
-
<date>2012-
|
| 14 |
-
<time>
|
| 15 |
-
<contents><target name="magelocal"><dir name="Cashu"><dir name="Paymentmethod"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Currencyoptions.php" hash="8dcf73dc698c933a22682b12bff67983"/><file name="Languageoptions.php" hash="4e58fddaae9cccce1850d8dfe2ff28c7"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="627c69e6846849f116c17f179be4bb86"/></dir><dir name="Model"><file name="Pay.php" hash="23ba17975e2836e0e582d4430e4bbab7"/></dir><dir name="controllers"><file name="PaymentController.php" hash="
|
| 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>Cashu_Paymentmethod</name>
|
| 4 |
+
<version>1.0.1</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>OSL</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Cashu integration for magento</summary>
|
| 10 |
<description>it allow users to use Cashu 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:52:09</time>
|
| 15 |
+
<contents><target name="magelocal"><dir name="Cashu"><dir name="Paymentmethod"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Currencyoptions.php" hash="8dcf73dc698c933a22682b12bff67983"/><file name="Languageoptions.php" hash="4e58fddaae9cccce1850d8dfe2ff28c7"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="627c69e6846849f116c17f179be4bb86"/></dir><dir name="Model"><file name="Pay.php" hash="23ba17975e2836e0e582d4430e4bbab7"/></dir><dir name="controllers"><file name="PaymentController.php" hash="ed7a5f74d5472a23ab48e10e23ae1c9e"/></dir><dir name="etc"><file name="config.xml" hash="2f89ffe89a66e2211efd6892f61a3dcd"/><file name="system.xml" hash="f060d0c076da9b6854c434a2d443672f"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><file name="cashu" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cashu_Paymentmethod.xml" hash="5182f969b96434d61f9047f849443b44"/></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
</package>
|
