There are certain cases where you find the need to add new Payment Method (Payment Gateway) in a Magento store. Especially if the Magento store owner wishes to use a specific payment gateway not available in default Magento installation. Adding a new Magento Payment Module is not difficult but requires a little bit of programming at your end. In this article i am going to elaborate on how to add a new payment module (Payment Gateway) to your existing Magento Installation which will accept credit cards, authorize credit card when the order is placed and saves order ID in payment record.
In this example i will call it “Paymentpro” but you can change every occurrence of “Paymentpro” with the payment gateway you are integrating for e.g. “RBSDirect” or something else.
1. Just Replace all instances of “Paymentpro” with your payment module name.
2. Just replace all instance of “Magik” with your company/namespace name.
3. Ensure that the path of the PHP include_path is /app/code/local/
4. Clean your cache after modifying the config xml files.
Now, you are all set to create a new payment module of your own. Following is a step by step guide to build your own shipping module, just follow them in exact order and make sure that the above requirements are taken care of.
Define new Magento Payment Module
First of all lets create a new payment module
/Magik_Paymentpro.xml and create the following xml file:
<config> <modules> <Magik_Paymentpro> <active>true</active> <codePool>local</codePool> <depends> <Mage_Payment /> </depends> </Magik_Paymentpro> </modules> </config>
The above code will tell Magento that there is a new Payment module enabled in the system.
Configure new Magento Payment ModuleTo configure your newly created Magento payment module you needto create
app/code/local/Magik/Paymentpro/etc/config.xmland add thefollowing code in it
<?xml version="1.0"?> <config> <modules> <Magik_PaymentPro> <version>0.1.0</version>
</Magik_Paymentpro> </modules> <global> <blocks> <paymentpro> <class>Magik_Paymentpro_Block</class> </paymentpro> </blocks> <models>
<paymentpro> <class>Magik_Paymentpro_Model</class> </paymentpro> </models>
<resources> <paymentpro_setup> <setup> <module>Magik_Paymentpro</module> </setup>
</connection> </paymentpro_setup> <paymentpro_write> <connection> <use>core_write</use> </connection> </paymentpro_write> <paymentpro_read> <connection> <use>core_read</use> </connection> </paymentpro_read> </resources> </global> <default> <payment> <paymentpro> <active>0</active> <model>paymentpro/paymentMethod</model> <order_status>pending</order_status> <title>Credit Card (Authorize.net)</title> <cctypes>AE,VI,MC,DI</cctypes> <payment_action>authorize</payment_action> <allowspecific>0</allowspecific> </paymentpro> </payment> </default> </config>
Admin Panel Configuration Options
We will create another file to view the configuration options in Magento
admin panel under
System => Configuration. To do this lets create one
Setting up Database UpdatesJust create one file
the following lines of code
<modules> <Magik_Paymentpro> <version>1.2.0</version> </Magik_Paymentpro> </modules>
and add the following lines of code
<?php $this->startSetup(); $this->run("Your SQL QUERY"); $this->endSetup();
To accommodate these change in database you have to change the version in