Payment Gateway is most important section of any eCommerce or Shopping website. Where user can purchase and pay by using Credit Cards online. Magento base code developed in Zend Framework Module structure. Here developer can developed modules and extensions as per there requirement and use or re-use.
1. Custom Payment Gateway Module inMagento
Payment Gateway is most important section of any eCommerce or Shopping website.
Where user can purchase and pay by using Credit Cards online.
Magento base code developed in Zend Framework Module structure. Here developer can
developed modules and extensions as per there requirement and use or re-use. A payment
gateway system mostly do :
A. valid and accept credit card detail
B. autherise payment detail when submit order detail
C. Save Transaction ID along with user detail in Order
So lets create a Custom Payment Gateway Module in Magento in below steps, here our
module name is EzeePayment :
1. Create xml file in app/etc/modules/CompanyName_EzeePayment.xml for Module
declarate:
<config>
<modules>
<CompanyName_EzeePayment>
<active>true</active>
<codePool>local</codePool>
<depends>
4. <!-- default title for payment checkout page and order view page -->
<title>Credit Card (Authorize.net)</title>
<cctypes>AE,VI,MC,DI</cctypes>
<payment_action>authorize</payment_action>
<allowspecific>0</allowspecific>
</ezeepayment>
</payment>
</default>
</config>
3. Now create EzeePayment Model php file in
app/code/local/CompanyName/EzeePayment/Model/PaymentMethod.php :
<?php
class CompanyName_EzeePayment_Model_PaymentMethod extends Mage_Payment_Model_Method_Cc
{
protected $_code = 'ezeepayment';
//payment method (online auth/charge) ?
protected $_isGateway = true;
//authorize online?
protected $_canAuthorize = true;
//capture funds online?
protected $_canCapture = true;
//capture partial amounts online?
protected $_canCapturePartial = false;
//Can refund online?
protected $_canRefund = false;
5. //Can void transactions online?
protected $_canVoid = true;
//Can use payment method internal in admin panel?
protected $_canUseInternal = true;
//Can show payment method as an option on checkout payment page?
protected $_canUseCheckout = true;
//Is this payment method for multiple shipping checkout?
protected $_canUseForMultishipping = true;
//Save credit card detail for future processing?
protected $_canSaveCc = false;
//Here you will need to code for authorize, capture and void public methods payment gateway
}
?>
In this above class now we have to do actual code for communicating payment gateway. If
in admin panel you have selected “Authorize Only”, then authorize method will be
called. If you have chosen “Authorize and Capture then only the capture method will be
called
4. Now create system xml file
app/code/local/CompanyName/EzeePayment/etc/system.xml for Declare configuration
options in magento admin panel :
<?xml version="1.0"?>
<config>
<sections>
<!-- payment tab -->
<payment>
6. <groups>
<!-- ezeepayment fieldset -->
<ezeepayment translate="label" module="paygate">
<!-- For title 'Ezee Payment' -->
<label>Ezee Payment</label>
<sort_order>670</sort_order>
<!-- not to show configuration options in store scope -->
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<fields>
<!-- active for website? -->
<active translate="label">
<label>Enabled</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</active>
<order_status translate="label">
<label>New order status</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_order_status_processing</source_model>
<sort_order>4</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</order_status>
<title translate="label">
8. <?php
$this->startSetup();
$this->run("UPDATE SQL HERE");
$this->endSetup();
Note :
1. Make sure in your system app/code/local is in include_path.
2. Dont put your module in Root Mage folder
3. Your module first letter should be capitalized (eg. EzeePayment).
4. If your module is not showing in admin congiguration section then check and config.xml
file.
5. Clear your system cache.
Hope above example will help you to create custom module in magento. If you face any
problem in existing code or any magento related please fill free to contact or comment us.
We will feel proud to help you.
Ezeelive Technologies (Magento Development Company in India )has expert team in
custom magento theme design, reponsive magento ecommerce portal development and
magento customization india. We developed and implement custom module, extension
and plugin as per project or client requirement.
Written By : Ezeelive Technologies