Think

Read the inside scoop about working on the web and running a tech company.



117
Comments

Magento: Create New Payment Method -> Cash On Delivery


About: How To Create a Magento Custom Module and A “Cash On Delivery” Payment Method
Who’s Interested: Informative to the semi-technically savvy
What: Custom Magento Payment Method

 

So I’ve seen more and more people raising awareness about desire to create a new payment method that allows orders to be paid via “cash on delivery” or “on pickup” by customer. Is this helpful to companies who sell to local clients? Absolutely.

 

So in offering a solution, I’ll go ahead and outline what files need to be created and why with hopes to help educate the intigued learner in how to create a Magento Custom Module as well. The benefit in knowing how to do this is modifying existing Magento functionality in a way that it will not be overwritten upon a successful Magento upgrade.

 

Thus, I’ll jump in. The following 5 files will be created (relative to one’s Magento root folder):
 

  • confix.xml
  • system.xml
  • PaymentMethod.php
  • mysql4-install-0.1.0.php
  • NewModule.xml

Here are their contents (with comments) and relative paths:

 

app/code/local/Mage/NewModule/etc/config.xml (below)

<?xml version="1.0"?>
<!--
/**
* Elias Interactive
*
* @title	  Magento -> Custom Payment Module for Cash On Delivery
* @category   Mage
* @package    Mage_Local
* @author	  Lee Taylor / Elias Interactive -> lee [at] eliasinteractive [dot] com
* @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*/

-->

<config>
<global>
<!-- declare model group for new module -->
<models>
<!-- model group alias to be used in Mage::getModel('newmodule/...') -->
<newmodule>
<!-- base class name for the model group -->
<class>Mage_NewModule_Model</class>
</newmodule>
</models>

<!-- declare resource setup for new module -->
<resources>
<!-- resource identifier -->
<newmodule_setup>
<!-- specify that this resource is a setup resource and used for upgrades -->
<setup>
<!-- which module to look for install/upgrade files in -->
<module>Mage_NewModule</module>
</setup>
<!-- specify database connection for this resource -->
<connection>
<!-- do not create new connection, use predefined core setup connection -->
<use>core_setup</use>
</connection>
</newmodule_setup>
<newmodule_write>
<use>core_write</use>
</newmodule_write>
<newmodule_read>
<use>core_read</use>
</newmodule_read>
</resources>
</global>

<!-- declare default configuration values for this module -->
<default>
<!-- 'payment' configuration section (tab) -->
<payment>
<!-- 'newmodule' configuration group (fieldset) -->
<newmodule>
<!-- by default this payment method is inactive -->
<active>1</active>
<!-- model to handle logic for this payment method -->
<model>newmodule/paymentMethod</model>
<!-- order status for new orders paid by this payment method -->
<order_status>1</order_status>
<!-- default title for payment checkout page and order view page -->
<title>Cash On Delivery</title>
</newmodule>
</payment>
</default>
</config>

app/code/local/Mage/NewModule/etc/system.xml (below)

<?xml version="1.0"?>
<!--
/**
* Elias Interactive
*
* @title	  Magento -> Custom Payment Module for Cash On Delivery
* @category   Mage
* @package    Mage_Local
* @author	  Lee Taylor / Elias Interactive -> lee [at] eliasinteractive [dot] com
* @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*/

-->

<config>
<sections>
<!-- payment tab -->
<payment>
<groups>
<!-- newmodule fieldset -->
<newmodule translate="label" module="paygate">
<!-- will have title 'Cash On Delivery' -->
<label>Cash On Delivery</label>
<!-- position between other payment methods -->
<sort_order>670</sort_order>
<!-- do not show this 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>
<!-- is this payment method active for the website? -->
<active translate="label">
<!-- label for the field -->
<label>Enabled</label>
<!-- input type for configuration value -->
<frontend_type>select</frontend_type>
<!-- model to take the option values from -->
<source_model>adminhtml/system_config_source_yesno</source_model>
<!-- field position -->
<sort_order>1</sort_order>
<!-- do not show this field in store scope -->
<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</source_model>
<!--<source_model>adminhtml/system_config_source_order_status_new</source_model>-->
<!--<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>
<allowspecific translate="label">
<label>Payment from applicable countries</label>
<frontend_type>allowspecific</frontend_type>
<sort_order>50</sort_order>
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</allowspecific>
<specificcountry translate="label">
<label>Payment from Specific countries</label>
<frontend_type>multiselect</frontend_type>
<sort_order>51</sort_order>
<source_model>adminhtml/system_config_source_country</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</specificcountry>

<title translate="label">
<label>Title</label>
<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>
</title>
</fields>
</newmodule>
</groups>
</payment>
</sections>
</config>

app/code/local/Mage/NewModule/Model/PaymentMethod.php (below)

<?php
/**
* Elias Interactive
*
* @title	  Magento -> Custom Payment Module for Cash On Delivery
* @category   Mage
* @package    Mage_Local
* @author	  Lee Taylor / Elias Interactive -> lee [at] eliasinteractive [dot] com
* @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*/

class Mage_NewModule_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstract
{
protected $_code  = 'newmodule';
//protected $_formBlockType = 'payment/form_checkmo';
//protected $_infoBlockType = 'payment/info_cod';

/**
* Assign data to info model instance
*
* @param   mixed $data
* @return  Mage_Payment_Model_Method_Checkmo
*/
public function assignData($data)
{
$details = array();
if ($this->getPayableTo()) {
$details['payable_to'] = $this->getPayableTo();
}
if ($this->getMailingAddress()) {
$details['mailing_address'] = $this->getMailingAddress();
}
if (!empty($details)) {
$this->getInfoInstance()->setAdditionalData(serialize($details));
}
return $this;
}

public function getPayableTo()
{
return $this->getConfigData('payable_to');
}

public function getMailingAddress()
{
return $this->getConfigData('mailing_address');
}

}

app/code/local/Mage/NewModule/sql/newmodule_setup/mysql4-install-0.1.0.php (below)

<?php
// here are the table creation/updates for this module

app/etc/modules/NewModule.xml (below)

<?xml version="1.0"?>
<!--
/**
* Elias Interactive
*
* @title	  Magento -> Custom Payment Module for Cash On Delivery
* @category   Mage
* @package    Mage_Local
* @author	  Lee Taylor / Elias Interactive -> lee [at] eliasinteractive [dot] com
* @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*/
-->
<config>
<modules>
<!-- declare Mage_NewModule module -->
<mage_NewModule>
<!-- this is an active module -->
<active>true</active>
<!-- this module will be located in app/code/local code pool -->
<codePool>local</codePool>
<!-- specify dependencies for correct module loading order -->
<depends>
<mage_Payment />
</depends>
<!-- declare module's version information for database updates -->
<version>0.1.0</version>
</mage_NewModule>
</modules>
</config>

Again, this serves as a basic configuration for a new payment method that allows Cash On Delivery and is written as a Magento Custom Module. Modifying these files may be necessary, though this should be a good outline to get you started. Any help needed, post here and we’ll get some dialogue going to find solutions for your needs.

Or simply download the files here:

Elias: Cash On Delivery (Magento Payment Method)

 

 







  • http://activecodeline.com Branko Ajzele

    Great work, nice article. Informative and educational. Thank you for sharing it with community.

  • timothyleetaylor

    Branko,

    We’ve been excited about Magento for some time now. We’ve also had a chance to dialogue with you some and gain a better appreciation for your involvement in the Magento community.

    Let us both keep up making progress with Magento on behalf of the community!

    Thanks for the encouragement.

    Hope to connect again soon,
    Lee

  • http://inchoo.net Tomislav Bilic

    Hey man,
    Many thanks for this tutorial. Looks very helpful to get started.

  • timothyleetaylor

    Thanks Tomislav,

    Great to hear from you, and I do hope this tutorial is beneficial in your endeavor to write a custom payment module.

    I was wondering, would you suggest any other topics about Magento that you’d like to hear or know more about?

    Let’s get a list rolling and begin writing on the most valuable topics the Magento community can benefit from.

    Thanks for your input,
    Lee Taylor

  • http://inchoo.net Tomislav Bilic

    Hehe. It was a coincidence that I found your article on Google, especially because Branko made the 1st comment. Two of us work at the same office in one small town in Osijek, Croatia and both of us came your way via separate paths :)

  • timothyleetaylor

    That coincidence is fun to hear about :)

    In that case since you’re working alongside Branko,I recognize much-needed topics that will benefit the Magento community have already been approached in an ongoing manner here: http://activecodeline.com/

    We’re excited for your community involvement, and are glad for the opportunity to contribute as well.

    Feel free to jot down thoughts on topics you’d like to hear about as they come to mind. Nonetheless, we’ll keep on blogging about the design, development, and marketing of Magento!

    Lee

  • http://www.dowhiletrue.net/blog/ osdave

    hi timothy,
    As Tomislav has no suggestion I have one, if I may :)
    I’ve learned php with osc: I realize then now that I’m programing in a XXth century way. I’ve discovered Magento and love it and see this an oportunity for me for learning he XXIth century way of programing.

    I’m studying now all I can find about OOP and Zend framework: that isn’t easy but surely worth it.
    Here comes my request: where to start in order to discover Magento’s code? Is there some logic I should keep in mind when I need to find some piece of code I want to see/change?
    You know, a tutorial about Magento’s code for beginers.

    Thanks in advance. Cheers.
    david

  • http://activecodeline.com Branko Ajzele

    Hi there “osdave”… In my modest opinion, Zend Framework is the way to go, especialy if you are interested in Magento. I too am on the path of learning and hopefully mastering Zend.

    There are people who will say Zend is fat as framework, use CodeIgniter, or PHPCake or Symphony or… Whatever the case may be, Zend is recognized as Enterprise ready, it comes with full certification program, it’s documentation is great and so on… in short; you can’t go wrong if you choose to go with Zend.

  • http://www.dowhiletrue.net/blog/ osdave

    hi Branko, thanks for your comment. Let’s go for Zend then :)
    Your blog will also certainly helps me in this journey, see you there

  • timothyleetaylor

    Hi @osdave and Branko,

    So great to have you both interacting here. I’m just catching onto the dialogue, and think Branko’s got a great perspective on jumping into Magento by initially learning the Zend framework.

    I recognize a couple ways of going about Magento customization. For theme customizations, one can often l learn by comparing the code with the frontend of the theme (via Magento theme notes AND Firefox Firebug tool). In this manner, learning theme customization techniques can be self-learned automatically by adjusting the visual part of the Magento theme.

    But I think you’re referring to Magento core code customization more specifically. And with our combined experience, we agree that learning the Zend Framework (which has made available some great tutorials and videos) is key.

    As you get familiar more with Object Oriented Programming, I believe you’re going to see GREAT value in utilizing the concepts it has to offer. Here’s a link that might get you started actually: http://devzone.zend.com/node/view/id/627

    As I understand it, Magento is written with the intention of not just utilizing the basic OOP concepts, but enhancing code re-usability and efficiency with the Zend Framework.

    They’re still making changes, as we’re all growing alongside them. Let’s keep the dialogue up, and post all kinds of thoughts/questions here and there so we can help each other out.

    All the best,
    Lee

  • http://www.dowhiletrue.net/blog/ osdave

    hi Lee, thanks for answering.
    The link to the devzone seems very interesting for me right now, as I’m revising the base of PHP. I’ll focus on parts 7 and 11 (OOP and XML) as these are both concept I am less confident with and very important for Magento (and I guess for good PHP programing).
    So, thanks again for your time and I’ll check your future posts, keep up the good work :)
    cheers, dave

  • http://url Tonitobleroni

    Hi,
    Thanks a lot for your work, but unfortunately the payment option doesn’s show up in frontend. It does in Admin->Configuration->Payment methods and I have enabled it. Also, I have refresed cache. Any idea what I did wrong? Thanks in advance!

  • timothyleetaylor

    Hi @Tonitobleroni,

    Thanks for your inquiry. Can I ask what version of Magento you are using? Also, you can try to manually refresh the cache by removing all contents from the following path: var/cache/

    Try that and mention what version of Magento you are using. Make sure the payment option is enabled, and we’ll see what we can troubleshoot from there.

    Thanks,
    Lee

  • timothyleetaylor

    @osdave,

    That sounds like a great plan for getting started. Also, once you do get an idea for the architecture of Magento (and better seeing at a high-level how everything fits together), you can attempt to go through this payment module piece by piece to see why the code is there and how it interacts with the other files inside the module.

    If you have any questions, post them here. Understanding the module may not seem as overwhelming, and it also plugs right into the Magento code with OOP concenpts (like overriding controllers with OOP practices in mind). Thanks, and all the best with your learning – as I’m doing it right with you every day =) It never stops!

    - Lee

  • http://url Tonitobleroni

    Hello Lee,
    Thanks a lot for your response. I manually removed all content from the cache folder. I am using 1.1.6. I have enabled the payment option in Admin.
    Thanks in advance!

  • http://url Tonitobleroni

    …and, needless to say, it still doesn’t show up in frontend…

  • timothyleetaylor

    Hey @Tonitobleroni,

    Please visit this post and read up about some solutions others have found when dealing with this type of issue: http://www.magentocommerce.com/boards/viewthread/832/P45/#t10489

    Unfortunately, without being able to look into the code you have (as various setup options can be prohibiting this from showing up on the frontend), it is hard for me to troubleshoot. Also, some questions I might cover with you are already located within the forum post mentioned.

    Lastly, if you don’t find any solution there, you may try a quick install of another Magento store and see if the module works from the fresh install.

    I haven’t had time to go in and verify that the code be relevant for Magento version 1.1.6 yet, though I haven’t seen anyone else having a problem with this – so it’s not likely there is any upgrade issues involved.

    Thanks,
    Lee

  • http://url Tonitobleroni

    Thanks Lee, I will dig through the post you provided. Thanks for your help!

  • http://url sirvash

    Hi,

    Could you suggest me how to configure the this module in own magento application. when i putted the all files in my local system this is not overriding the default shipping method of magento.

  • timothyleetaylor

    Hi @sirvash,

    I’d love to recommend how to configure this module in your own Magento application, though with all the possibilities, it would probably turn into a small project rather than a couple discussions.

    In reference to the issue you mentioned, make sure you haven’t changed the name of the default shipping method of Magento. Also, I’d recommend going back and make double-checking that the files were copied into the correct folders (reference the paths in the download we have available).

    Please contact us via our contact form below if you’d like help on a project, and we’d be glad to assist you.

    Thanks!
    Lee

  • http://url Sirvash

    Hi @Lee,

    Special Thanks for quick solutions i am trying to update the title of ‘Cash on Delivery’ and updated the system.xml and config.xml but modification not visible on front.

    Please assist me.
    module working fine now can i update the shipping method i just wanna to save and extra value instead of the ‘Flat Tax’ on sales order table.

    Thanks
    Sirvash Sharma

  • timothyleetaylor

    Hi @Sirvash,

    We’ve had someone else inquire as to a similar issue. My response can be found here: http://eliasinteractive.com/blog/magento-create-new-payment-method-cash-on-delivery/#comment-64

    Thanks,
    Lee

  • http://url Leslie

    Hi Folks,

    I see that this thread is for COD but I’m also attempting to create a Magento payment module for USAePay payment module using the Magento create payment gateway instructions.

    I am having a parser error issue with the
    app/code/local/Mage/Usaepay/Model/PaymentMethod.php file and I wonder if you could help me fix it. If yes, could I send you the php code for this file? Here is the error:

    Warning: simplexml_load_string() [function.simplexml-load-string]: Entity:
    line 133: parser error : Opening and ending tag mismatch: usaepayach line 107 and payeach in
    /home/the/domains/silverborn.com/public_html/lib/Varien/Simplexml/Config.php
    on line 500

    Thank you,
    Leslie

  • http://url Pankaj

    I have made this but it is looking in the advanced section but not in the payment method in the Admin panel.I need it with the credit card details.

  • http://local Thirupathi

    I had created Payment Module as it is in my local system
    Magento: Create New Payment Method -> Cash On Delivery

    but the new module is not displaying in admin/system/configuration

    same as another one created fallowed by

    http://www.magentocommerce.com/wiki/how-to/create-payment-method-module

    it is also same problem

    please any one suggest me what is the problem

  • http://url Nishant

    hi can u tell me how can i add another field to new product addition(Create product setting.)..m using version 3.0

  • http://url nishant

    hi!
    i just want to know how can i know which file is showing the current page content of magento so that if i want to modify it then i can do it….
    And yes dear m just a beginner…

  • http://url Younus

    Hi Lee,

    I’m using magento-1.1.8. I’ve followed your steps creating 5 files in appropriate directories. But unfortunately in Admin->Configuration->Payment methods, I can’t see any update. I have refreshed cache but no results. Can you say please where I’m doing wrong ?
    Thanks in advance.

  • timothyleetaylor

    Hi All,

    As I see, there’s been a bit of activity that I haven’t had time to get to. My apologies here. I haven’t needed to update this for Magento’s new 1.2 version, so I haven’t tested it against the upgrades Magento has made. Unfortunately, I haven’t had time to update it – though I assume there’s some adjusting to the “system.xml” file regarding displaying correctly within the Admin->Payment Methods.

    I’ll post again when time opens up. Until then, keep testing and post your successful findings on the blog here!

    Thanks for all community contributions,
    Lee

  • Pingback: Anton Olsen.com » Blog Archive » Bookmarks for February 10th

  • http://url neo

    Hi, I just tried your post, but it’s not shown in configuration->payment methods tab but in configuration->advanced tab. My magento version is 1.2.1.
    Can u show me the solution.
    Thanks in advance.

  • http://url neo

    I had some wrong but I fixed it and now it’s shown in payment methods tab. It’s really great work. Thank you very much, Lee!

  • http://www.freshwebservices.com Eddie

    Hi,
    Thanks for this tutorial. However, when I do an order from within admin, the COD payment method is not available, even tho’ I’ve enabled in Configuration.

    I’m running ver 1.2.0.3. Any suggestions?

    Thanks,
    Eddie

  • http://url Ela

    Hola,

    Thank you very much for this tutorial! It works fantastic! Just a little question: The new payment is the first one in the frontend now. How can I change the sort order? Thanks! ela :)

  • http://url Sabarish

    hi timothyleetaylor,

    I am New to this both Magento and Zend Framework. I Just tried ur Steps to create a payment module. Unfortunately i cant able to succeed in it. its throwing me a warning…

    Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : XML declaration allowed only at the start of the document in E:\magento\lib\Varien\Simplexml\Config.php on line 500

    can u please tell me wr i did a mistake and how to resolve this.

    Thanks & Regards,
    Sabarish V

  • Lee Taylor

    Hey there @Sabarish,

    That error tends to be a result of something going wrong within your config.xml or system.xml file inside the module directory. Be sure to check unnecessary whitespace and invalid characters (which happens sometimes if copying and pasting).

    Hope you find a solution that results from digging around those two files.

    Cheers!
    Lee

  • http://url Younus

    Hi Sabarish,

    You can go through the following link to integrate the New Payment Method.

    http://www.magentocommerce.com/boards/viewthread/832/P195

    I’ve integrate the method with magento 1.1.8.
    Its also working with ver-1.2.0.3.

    Thanks
    Younus

  • Lee Taylor

    Thanks for the input here all!

  • http://url Sabarish

    HiYounus,

    Thanks for the Input Its works fine for me. Sorry for the late response Bcoz i was struck with other works. Again i need another input from u all guys. How to integrate the new Module with the Existing Modules. Do u have any reference link kindly let me know

    Thanks & Regards,
    Sabarish

  • Pingback: Welche Extensions nutzt Ihr? - rack::SPEED Support-Forum

  • http://www.eshban.com eshban

    thanks for this tutorial, i need a little guidance.

    I need to create a magento module that sends variables to a payment gateway page.

    Can you please guide me in this regard?

  • http://url Marcio

    Hy

    I create a field

    In

    class Cerebrum_Visa_Block_Standard_Form extends Mage_Payment_Block_Form

    Ok, appear in Font-End in E-commerce

    ————
    But

    How to get the variable “visa_type” content, to Show in the E-commerce

  • http://url dan

    What about giving only special customers the option of cash on delivery?

  • http://url dan

    What I mean is, say I have a list of user accounts maintained through the admin panel. What then if I create a group called “vips” and then only when they are logged in they can see the payment option “Cash on Delivery”.

    We would not want to deliver a heavy valuable package to someone whom we did not trust to give them the COD treatment!

  • http://url Linus

    This is great if it works, can´t you release it on magento connect?

  • http://url vas

    Hi, all

    I have created new payment module. it display on admin panel as well as on frontend. now i want that when user click on place order user will redirect to new window like any iframe and in that user will enter all the details and continue….

    pls anyone help me how to do this….. pls..pls…

    thanks,

  • http://url anonymousmagentonewbie

    does this work with magento 1.3+ ?

  • http://url vas

    No one has answer of my question??? regarding redirect to new iframe for payment.

  • http://url Helen

    This is somewhat off topic, but I haven’t been able to get any help at the Magento forums.

    Sounds like you know what you’re doing, maybe you know the deal with this?

    Thanks in advance!

    Here’s my issue:

    - I added a new module using ModuleCreator.

    - Was able to activate it via Configuration -> Advanced.

    - The new module MENU tab shows up in the Admin section, but when I click on the button, it takes me to a blank page.

    - I’m using “default” theme for the backend, and a custom theme for the frontend. However, this new button takes me to a blank page styled using my custom theme.

    So my question is—where can I see this custom module admin page? Is it a php, xml or phtml file?

    I want to add content to it, and if possible, change it to “default” theme like the rest of the admin section.

  • http://url mushir

    how can i add one new form before registration page on front-end for magento ?

    when customer can click on registration first of all open new form where customer can enter city name and that city will be in system then register form will appear otherwise display sorry msg.

    pls help me

    http://mushirkureshi.blogspot.com

  • http://www.ozthongs.com.au khushwant

    Hello Lee,

    I m new to magento. Can u give me a good and easy resource to get started with magento and zend.

    Thanks
    khush

  • http://sendmailnotification alp

    Thanks for this great tutorial! How can i set up the script to send notification mail which informs customer after “cash on delivery” order. Briefly, i need custom mail template and the required mail script for cash on delivery. I also want to be in bcc as an admin.
    Any help will be appreciated

  • http://url jazkat

    Heya guys,
    first I must say I really appreciate your effort in serving Magento community! That goes for Croatian team as well!

    I am also interested in knowing whether this module works in 1.3.x. I am gonna try it anyway and let you know the results.

    However, I am still kinda confused about Magento updates. The thing is I am modifying the system quite a bit plus thinking of using lots of extensions. I mean, I am aware the system needs to stay safe, however, the possibility of having to modify code after every update makes me, well, not happy.
    Anyway, I know this is a different topic, it just bothers me extensively.

  • http://www.freshwebservices.com freshwebservices

    Hi jazkat,
    If you use your own modules to modify Mage behaviour/functionality, then you have less to worry about when upgrading. However, if you modify core code, then this is a problem when upgrading – you’ll have to use a diff tool to compare the new code against your modified version and then merge the 2 if you can.
    So if possible, figure out how to create your own module to do modifications – often ‘all’ you have to do is copy the file you want to modify into app/code/local/yourfolder and then publish it as a module, having informed Mage to use your module rather than the default.
    Best wishes,
    Eddie

  • http://url jazkat

    Hi Eddie,
    thanks a lot, this makes sense. I was actually going to create my own modules and not change core files, so that means I was on the right path not to complicate my life :-)
    You put my mind at ease :-)

  • http://url Abdul

    Hi all,

    This is great tutorial to get started. I’ve an assignments. I need to build a custom module in magento. I’m new to magento. I need to build a clone of http://www.brooksbrothers.com/selectshirts/selectshirts.tem#. Can anybody guide me how to start this kind of module/functionality in magento. Hope to hear from you people. Thanks in advance.

  • Lee Taylor

    Hi All,

    Glad all is well and things are getting sorted. Thanks for helping out everyone. We have been busy working on a few internal projects that we’ll look forward to presenting to the Magento community soon.

    Keep up the progress!

    Cheers!
    Lee

  • Lee Taylor

    Hi @Abdul,

    From the link you gave us, it looks like this kind of functionality is more related to a “product configurator” rather than an actual payment gateway. The payment gateway would need to happen once the products are added to the cart and the user is sent to the checkout process.

    All the best in finding the right solution!

    Cheers,
    Lee

  • http://url Abdul

    Hi @Lee Taylor,

    Thanks for reply.

  • Pingback: How to: Magento eCommerce help and tutorials |

  • http://url pippo

    hi! i configured the module and works fine, but i would like that my country selection for the cash on delivery availability, refers to shipping country, not the billing one. someone can help me? thanks in advance

  • http://url Juan Siesquen

    Hi Men!

    I want to create a payment module which can communicate to a web service. I have problems displaying lists of coins recovered dynamically. Any idea?

    When ending the develop I publish… excuse me my english. :P

    Regards Friends!

  • http://url Peter Money Maker

    Great idea, thanks for this tip!

  • http://url Vishnu Bhatia

    Dear Timothy,

    First of all thanks a lot for the module. I have installed it on Magento 1.3.1 and it work great. We have added an additional fee as COD charges and it works great on front end. However, the problem comes when I have to modify an existing order or create a new order. It simply does not count the additional charges and the total of the order is having only the shipping charges added. Can anyone who has faced the similar issue, guide me how to solve this issue?

    Regards.

  • http://url Pavel

    Thank you so much for valuable information.

    Is there some easy way to add suplemental fee for this payment method.

  • http://www.activoinc.com/ Ron Peled

    I think your post does a better job explaining how to create a payment module for magento that the wiki page they have on the magento community site. Good job!

  • http://www.creativelifeform.com Rohan

    Totally agree with Ron above. The Magento wiki is complete crap by comparison.

    One question I have which is confusing the hell out of me, is about the PaymentMethod.php file.

    How does this file get referenced by the payment method?

    The only reference I can find to it is in the config.xml file which says:

    newmodule/paymentMethod

    there is a folder called

    app\code\local\Mage\NewModule\Model

    and inside of that there is PaymentMethod.php

    is this the same file that is referenced in config.xml ??

  • http://url yogesh

    Hello,
    This is nice tutorial but can you please provide me any help on how to create credit card accepting payment module for magento.
    I followed some url’s but they all are very basic and not even with any information like how to pass hidden values from client side while checkout..How to change fields name etc…
    Please help me asap…

  • http://url Rianti

    Hi, thanks for this. I’ve implemented it on v 1.2.1.2 and it works great! :-) I’ve also added a new “message” field to this module (“Please call xxxxxxx to arrange delivery time”). It shows up in admin but doesn’t show the message when I choose this payment method on checkout. Anyone can help me with this?

    Much appreciated,

    Rianti

  • http://url momleepost

    We like to know how to the custom payment redirect to the payment process url when we submit the place order button.

  • http://www.blaineehrhart.com/ Ajax and PHP Developer

    Hey,

    I was building a checkout module and this helped figure out some dearly needed stuff. It is just a bit off from what I need but I learned a lot. Thank you.

  • http://url Aryan-Ali

    Great work dear
    can any one guide me about ?
    how can i add the realted data base tables?
    or how many tables are required for this module ?

    please anser me as soon as posible ………..!

  • http://url ertarunz7

    Hello All,

    I’m new to Magento .. and i want to develop a module
    “Vendor rating system like that of ebay”.. In Magento .. can any when suggest me where to start from .. As i had no idea regarding this .

    Any help will be great ..

    Thanks a lot in advance.

  • http://balexandre.com Bruno Alexandre

    Can you please make downloadable file available.

    Thank you and Congrats for the article.

  • http://url Thillai

    Hi

    I downloaded the module its working fine in magento with single admin site. When i use the module with multiple websites , am getting an error message in the backend . But the module is working fine in the frontend.Update me and let me know the what the issue is and how can i resolve this issue.

  • http://akashr.wordpress.com Maz

    Hello, I am new on this. I created a module using your tutorial but after creating the module I couldn’t enter to my admin panel..it shows following error.

    Module “mage_PaymentModule” requires module “mage_Payment”

    Help is highly appreciated! Thanks!

  • http://straightnorth.com Bill Thomas

    Maz:
    The problem is probably in the app/etc/modules/Mage_NewModule.xml

    mage_Payment needs to be Mage_Payment. Capital M

  • http://url optical

    I’m trying to create multiple modules using the same template but I notice the subsequesnt ones are not showing. It’s enabled and I get no errors. Is it a sort number value issue?

  • http://url optical

    let me rephrase my question. If I need to create multiple new methods, which variable will I need to change? I changed the NewModule variable but I can only get one method to show up in the backend. The other new method shows it’s enabled in Advanced but I dont’ see it on the Payment Methods.

  • http://url ben

    Although I am writing a custom payment module for Magento (what a learning curve!) which is a bit more complicated stuff, I would appreciate some advice. After creating the module I can setup my custom setting of the created payment method in the Payment Methods Magento admin section, but when I enable the payment method and go to the checkout, the Payment Information doesn’t contain the option for my enabled payment option. I have disabled the cache while debugging, so it can’t be the fault. cheers

  • http://url Charles G

    Hello Lee,

    Many thanks for this contibution.
    I have managed to add a new payment method based on your tutorial and I am very happy with it.
    The only problem I have with any new payement modules I write from scratch is that they will cause an error in the admin panel when you attempt to check an order/change the status of an order that was placed using this payement.
    So In the admin section , if I go to sales/orders and try to edit the last order made with the newpayement I get this error:

    Warning: include(/home1/……/app/design/adminhtml/default/default/template/POD1/info.phtml) [function.include]: failed to open stream: No such file or directory in /home1/… …//app/code/core/Mage/Core/Block/Template.php on line 144

    Any idea how I can resolve that little bugger ? Is the module missing some template files in the adminhtml ?

    Thanks

    Charles G

  • http://url Jose

    Hello Elias,

    Do you konw if is posible disable this option of payment for downloadable and Virtual products?

    Thanks :-)

  • http://www.jcsl.nl J.S. Coolen

    The download link doesn’t wotk anymore, does anyone has the files for me?

  • http://url rover

    Hi,

    Everyone, I’m new here and in Magento. Can you give me an idea how to integrate or create new payment module mehod PesoPay. Like what I said, I’m new in Magento and I really can’t caught an idea where and how to start creating this module. Thank you very much for the help.

  • http://url rover

    Hi,

    I just want to ask that how and where is the module of paypal payment method where it send the buyers information and total amount of the customer’s bought product. Please help me with this. Thank you in advance.

  • http://url rover

    Hi,

    Guys, I having a problem when I clicked “Checkout: in my magento.

    Fatal error: Call to a member function setStore() on a non-object in C:\xampp\htdocs\magento\app\code\core\Mage\Payment\Helper\Data.php on line 72

    anyone can help? Thank you

  • http://url jeet

    I need to integrate a new payment module called ‘MegaPos’ . Dont know how to move. any help would be highly appreciated.

  • http://url Sunil Mohapatra

    I desperately need the multi payment gateway module called ‘Megapos’.Please need some help.

    Thanks…

  • http://topmagento.com/ kivin

    my modudle going error, here show:
    Module “mage_NewModule” requires module “mage_Payment”
    Trace:
    #0 D:\Program Files\Zend\Apache2\htdocs\magento1324\app\code\core\Mage\Core\Model\Config.php(680): Mage::throwException(‘Module “mage_Ne…’)
    #1 D:\Program Files\Zend\Apache2\htdocs\magento1324\app\code\core\Mage\Core\Model\Config.php(645): Mage_Core_Model_Config->_sortModuleDepends(Array)
    #2 D:\Program Files\Zend\Apache2\htdocs\magento1324\app\code\core\Mage\Core\Model\Config.php(233): Mage_Core_Model_Config->_loadDeclaredModules()
    #3 D:\Program Files\Zend\Apache2\htdocs\magento1324\app\code\core\Mage\Core\Model\App.php(263): Mage_Core_Model_Config->init(Array)
    #4 D:\Program Files\Zend\Apache2\htdocs\magento1324\app\Mage.php(434): Mage_Core_Model_App->init(”, ‘store’, Array)
    #5 D:\Program Files\Zend\Apache2\htdocs\magento1324\app\Mage.php(455): Mage::app(”, ‘store’, Array)
    #6 D:\Program Files\Zend\Apache2\htdocs\magento1324\index.php(65): Mage::run()
    #7 {main}

  • http://ww.plazamalang.com nabler

    Yeah i got the pretty error after i follow your tutorial….I use magento 1.4.0.1

  • Vasashiner

    Module “mage_NewModule” requires module “mage_Payment”
    Trace:
    #0 E:xampphtdocsvasa_magentoappcodecoreMageCoreModelConfig.php(680): Mage::throwException(‘Module “mage_Ne…’)
    #1 E:xampphtdocsvasa_magentoappcodecoreMageCoreModelConfig.php(645): Mage_Core_Model_Config->_sortModuleDepends(Array)
    #2 E:xampphtdocsvasa_magentoappcodecoreMageCoreModelConfig.php(233): Mage_Core_Model_Config->_loadDeclaredModules()
    #3 E:xampphtdocsvasa_magentoappcodecoreMageCoreModelApp.php(263): Mage_Core_Model_Config->init(Array)
    #4 E:xampphtdocsvasa_magentoappMage.php(434): Mage_Core_Model_App->init(”, ‘store’, Array)
    #5 E:xampphtdocsvasa_magentoappMage.php(455): Mage::app(”, ‘store’, Array)
    #6 E:xampphtdocsvasa_magentoindex.php(65): Mage::run()
    #7 {main}

  • Vsven

    Hi Guys,

    This works PERFECT!! Just one thing, you have to change the title of “NewModule.xml” to “Mage_NewModule” otherwise it doesn’t work ;)

    cheers
    vsven

  • Mage_New

    Hi there.. nice module. But i’m unable to get these to show up on my multilingual site.. I can only see this in the payment methods when Current Configuration scope to Default Config or Main website. When I switch to the rest of the 3 languages, I can’t see any.

    Any help?

    Using magento 1.1.4 and modern theme.

  • Ssankarsiva

    Greate work

  • Mahesh Umarane

    great work

  • Phumlani Nyati

    I am new to this but I have disabled the cash on delivery module on my admin dashboard but it still appears on my site, how can I solve this problem? please help!!!

  • Bharat Paghadal

    woww, great work.

    but i want to implement this module with paymentgateway,
    so how can i implement???

  • Zekia

    This is a very helpful post but could you also explain which tags and file-names should be changed in order to create a second new payment method?

  • Daisy

    I have to place the order details to the Warehouse server using the Web-service functions, when ever a new order is placed. I want to write a module to call web-service functions. Please suggest the solution.

  • http://www.magento-themes.jextn.com/ magento themes

    Very good idea………Thanks for adding this topic. We are also working on Magento.No w it will help to add this feature.

  • http://www.oztek.in Kiran

    Great and Thanx but small correction….
    mage_Payment Should be Mage_Payment
    mage_NewModule Should be Mage_NewModule

  • Ronniee

    It helps me a lot, thanks, great work.

  • Mit

    HI dear it works but can i make separate table for this module and how plz tell me.. 

  • Vivekasc

    Hello Friends,
    I am looking for a prestashop module to integrate in magento.
    Prestashop module in here
    http://socolissimo.prestashop.common-services.com/
    Please guid me how i can integrate this in magento.

    Thanks in Adavance
    Vivek Shrivastava

  • http://www.mactonweb.com web development bangalore

    Great work.Very helpful post.Thanks for  sharing

  • http://www.apptha.com/category/extension/Magento/OneStepCheckout Magento One Page Checkout

    This is an excellent post! Thanks for the information! If anyone needs  Magento Stores  one page checkout  Module , let me know

  • http://www.facebook.com/OmerBohoussou Omer Bohoussou

    I don’t see any thing , I do not know where to go to see if it work. help me please

  • http://www.marathonm2m.com/about-m2m/management-information-system.aspx management information system

    I want to know more about majento ..can u share with me some knowledge

  • Manish Prakash

    I have written a detailed blog post here on how to create payment method in magento
    http://www.excellencemagentoblog.com/magento-create-custom-payment-method

  • Vahan403

    Hi I am new in magento and will be appreciate if you will help me.
    My question is which method executes when checkout button is pressed? 
    I am trying develop new online payment module and need redirect user to the payment gateway site when checkout is made

  • Denisa

    Thanks for posting! I have a question: did you create a cash in advance module? It should be something similar with this, isn’t it?
    Thanks

  • Omar Farooq

    Not worked. Can you please available the download files link

  • http://www.apptha.com/category/extension/Magento/OneStepCheckout Magento One Page Checkout

    Hello Lee, I came on your blog for the first and I have seen your work. I must say you have maintained your Blog really well. Good on you.  

  • Omar Farooq

    i need to add cash handeling fee how can i add this

  • Shaima Arshad

    Module “mage_NewModule” requires module “mage_Payment”. i m finding this error

  • Russel adword

    eCommerce businesses work hard to win the attention of shoppers and bring them to their websites. At the same time, they have invested substantial budget and effort to present the most compelling shopping experience possible. From Web2.0 and social media features to engaging video ads and product configurations, each eCommerce business strives to stand out from the competition to boost sales and maintain consumer loyalty.

    http://www.cloudways.com/en/magento-managed-cloud-hosting.php

  • magentony

    My only discrepancy is that the COD option will be available for downloadable and virtual products, which is not logical since there is no address to deliver a virtual product to. Can you specify COD based on product type?