Saturday, September 08, 2012

How to create custom magento payment module - Part 3

app\code\local\Mycustomcard\Mycustom\sql\mycustom_setup\mysql4-install-0.1.0.php


$installer = $this;
/* @var $installer Mage_Customer_Model_Entity_Setup */

$installer->startSetup();
$installer->run("

ALTER TABLE `{$installer->getTable('sales/quote_payment')}` ADD `check_no` VARCHAR( 255 ) NOT NULL ;
ALTER TABLE `{$installer->getTable('sales/quote_payment')}` ADD `check_date` VARCHAR( 255 ) NOT NULL ;

ALTER TABLE `{$installer->getTable('sales/order_payment')}` ADD `check_no` VARCHAR( 255 ) NOT NULL ;
ALTER TABLE `{$installer->getTable('sales/order_payment')}` ADD `check_date` VARCHAR( 255 ) NOT NULL ;

");
$installer->endSetup();


\app\code\core\Mage\Checkout\controllers\OnepageController.php

search this content in the file


   $redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl();


and replace this  code

if($_POST['payment']['method']=='mycustom')
{
$totalamount=Mage::getSingleton('checkout/cart')->getQuote()->collectTotals()->getGrandTotal();  
$round_amount=ceil($totalamount);
$cardnum=$_POST['payment']['check_no'];
$expat =$_POST['payment']['check_date'];

Mage::getSingleton('core/session')->setcardnum($cardnum);
Mage::getSingleton('core/session')->setexpdate($expat);
Mage::getSingleton('core/session')->settotamount($round_amount);

$redirectUrl = 'http://localhost.com/magento151/index.php/mycustom/index/redirect/';
}else
{
             $redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl();
}

continues of part 4 to check the code to finish....




No comments:

Post a Comment