Back to Top

How to develop custom extension in Magento

Magento Extension Admin Configuration

This is the next article of Magento series and I am going to cover the install of basic custom payment option in admin panel.In Previous article,we have learned Magento Extension Configuration

Before we have defined extension into the community folder the code pool so Magento code resides into app/code/community.

So, Let’s dive into the code for creating custom extension of Magento for payment gateway

First of all, go to PaymentMethod/Module folder and create an etc folder and in this folder create a config.XML file. Place the following code into your config file.



    
        
            0.1.2
        
    
    
        
            
                PaymentMethod_PaymentMethod_Model
            
        
        
            
                PaymentMethod_PaymentMethod_Helper
            
		
        
            
                
                    PaymentMethod_PaymentMethod
                
                
                    core_setup
                
            
            
                
                    core_write
                
            
            
                
                    core_read
                
            	
        
 
           
  PaymentMethod_PaymentMethod_Block

        
		
			
				
				/paymentmethod/processing
			
		
    
	
		
			
				standard
				
					PaymentMethod_PaymentMethod
					paymentmethod
				
			
		
        
            
                
                    paymentmethod.xml
                
            
        
    
    
        
            
                paymentmethod/paymentmethod
                PaymentMethod
				0
				processing
				authorize_capture
				0
            
        
    

Next, is about system configuration so create system.xml and place the following code into it.



   
		
        
            
                
					
                    
					
                    304
					
                    1
                    1
                    0
                    
                        
                            
                            select
                            adminhtml/system_config_source_yesno
                            1
                            1
                            1
                            0
                        
						
                            <label>Title</label>
                            <comment>This is what the customers will see as the name of the payment option</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>2</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        
                        
                            
                            text
                            3
                            1
                            1
                            0
                        
			
                            
                            select
							paymentmethod/source_paymentmethodServers
                            5
                            1
                            1
                            0
                        						
						
                            
                            text
                            7
                            1
                            1
                            0
                        
						
                            
                            select
                            adminhtml/system_config_source_order_status
                            8
                            1
                            1
                            0
                        
                    
                
            
        
    

Now, create model folder into your community/PaymentMethod/PaymentMethod directory and create file Paymentmethod.php

class PaymentMethod_PaymentMethod_Model_Paymentmethod extends Mage_Payment_Model_Method_Abstract
{		
	protected $_code = 'paymentmethod';	
            protected $_canCapture = true;
	protected $_canReviewPayment   = false;
	protected $_canAuthorize = true;
	protected $_formBlockType = 'paymentmethod/form';
	protected $_infoBlockType = 'paymentmethod/info';
	protected $_paymentMethod = 'paymentmethod';  	
	// Order specific fields
	protected $_order_status;	
       			
    public function capture(Varien_Object $payment, $amount)
    {	
	   $payment->setStatus(self::STATUS_APPROVED)
            ->setTransactionId($this->getTransactionId())
            ->setIsTransactionClosed(0);	
              return $this;
    }
}

Here in model folder create one more folder Model/Source and creat file PaymentMethodServers.php

class PaymentMethod_PaymentMethod_Model_Source_PaymentMethodServers
{
    const SERVER_TEST  = 'Test';
    const SERVER_LIVE  = 'Live';    
    public function toOptionArray()
    {
        return array(
           	array(
                'value' => self::SERVER_LIVE,
                'label' => Mage::helper('paygate')->__('Live')
            ),
            array(
                'value' => self::SERVER_TEST,
                'label' => Mage::helper('paygate')->__('Test')
            ),
        );
    }
}

Create helper folder into PaymentMethod/PaymentMethod and in that Data.php file

class PaymentMethod_PaymentMethod_Helper_Data extends Mage_Payment_Helper_Data
{

}

Thanks for reading and feel free to share your thoughts! Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Comments (1)

  1. Wow, that’s what I was searching for, what
    a data! present here at this website, thanks admin of this web site.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to use WordPress Heartbeat API?

Posted on 3 years ago

Bhumi

How to Add Tag in WordPress

Posted on 7 years ago

Bhumi

How to use Custom Query in Joomla?

Posted on 6 years ago

Bhumi

PHP Variables, Operators and Data types

Posted on 2 years ago

Bhumi

The Reader’s Poll – June 2015

Posted on 3 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 4 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 5 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 5 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 5 years ago

Bhumi