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.
- Just Replace all instances of “Paymentpro” with your payment module name.
- Just replace all instance of “Magik” with your company/namespace name.
- Ensure that the path of the PHP include_path is
- 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
app/etc/modules/Magik_Paymentpro.xml and create the following xml file:
The above code will tell Magento that there is a new Payment module enabled in the system. * Lean how to enable or disable a Magento module.
Configure new Magento Payment Module
To configure your newly created Magento payment module you need to create
app/code/local/Magik/Paymentpro/etc/config.xml and add the following code in it
0.1.0 Magik_Paymentpro_Block Magik_Paymentpro_Model Magik_Paymentpro 0 paymentpro/paymentMethod pending Credit Card (Authorize.net) AE,VI,MC,DI authorize 0
The above file will install all the predefined variables and values, you are open to change the default values under “defaul” parameters.
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 file
670 1 1 0 select adminhtml/system_config_source_yesno 1 1 1 0 select adminhtml/system_config_source_order_status_processing 4 1 1 0 text 2 1 1 0
Pretty cool, now your Magento store is setup to use new Payment Gateway. Just go to
Admin => System => Configuration => Payment Methods, you will notice a new payment gateway “Payment Pro”. Enable it and try to checkout. On payment methods page you should see “Payment Pro” payment method with credit card form.
Setting up Database Updates
Just create one file
app/code/local/Magik/Paymentpro/sql/paymentpro_setup/mysql4-install-0.1.0.php and add the following lines of code
startSetup(); $this->run("Your SQL QUERY"); $this->endSetup();
To accommodate these change in database you have to change the version in
app/code/local/Magik/Paymentpro/sql/paymentpro_setup/mysql4-upgrade-0.1.0-1.2.0.php and add the following lines of code
startSetup(); $this->run("SQL UPDATE Query"); $this->endSetup();
Few things to note while creating a new Magento payment gateway module
- New payment module should either be placed inside
app/code/communitynever put your new module under
- Just ensure that the module’s first letter is capitalized. paymentpro apparently will not work, it must start with a capital letter Paymentpro.
- Also make sure that the recipient folder of the module’s folder (Magik in the example) is capitalized as well.
Now, you have new payment gateway setup for your Magento store. Remaining logic of authorizing, verifying and accepting payments are out of scope as they differs from merchant to merchant. Some of the merchant requires the customer to be redirected to their site and some allows curl or HTTP_REQUEST based authentication to make purchases.
I would love to hear your views and experiences of setting up a new payment gateway. Please leave me a comment and let me know. Don't forget to subscribe our RSS to receive latest updates on Magento.