Hi, I’m new to magento and i tried this module but it doesn’t work
and the problem is in the system.xml
i was wondering if there is any documentation for that file?
and what is the source_model?
Payment module tutorial in wiki has a few bugs in it.
First, in this example module declaration should be in file “app/etc/modules/Mage_Newodule.xml” not “app/etc/modules/NewModule.xml”
Second, directory name for this module should not be in camelCase. It doesn’t work like this.
“app/code/local/Mage/Newmodule/etc/...” instead of “app/code/local/Mage/NewModule/etc/...”
@Mark Robinson: I’ve tried your module and I think it works. I’ve only rename /app/etc/modules/BankTransfer.xml to /app/etc/modules/Mage_BankTransfer.xml.
I just need a simple duplicate of the Check / Money Order payment method and I want to call it say “Cash Payment”.
Everything else will remain the same.
How can I achieve that ?
The wiki and all the posts written here are too complex. Can’t i just duplicate a few files that are used for Check / Money Order payment method and rename the method to “Cash Payment” somewhere
Hi, I’m no expert on this, but believe this version you quote is wrong. There is no need to do the sql install part anymore (I saw this on another thread).
I’ve managed to get the payment method showing in admin using the latest wiki tutorial, my only change was to use name app\etc\modules\Mage_NewModule.xml not \app\etc\modules\NewModule.xml (also found on another thread).
I’ve followed the article in the wiki to create a custom payment module but i’m not getting it to work. I’ve created it several times and, for some strange reason, I can access the frontend, but the backend gets stuck into some kind of infinite loop, and I’ve no idea why that’s happening.
Here is the code:
app/etc/modules/FirstAttlantic.xml:
<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <!-- declare Mage_FacPayment module --> <Mage_FirstAttlantic> <!-- 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 modules version information for database updates --> <version>0.1.0</version> </Mage_FirstAttlantic> </modules> </config>
/app/cod/local/Mage/FirstAttlantic/etc/config.xml
<?xml version="1.0"?> <config> <global> <!-- declare model group for new module --> <models> <!-- model group alias to be used in Mage::getModel('firstattlantic/...') --> <firstattlantic> <!-- base class name for the model group --> <class>Mage_FirstAttlantic_Model</class> </firstattlantic> </models> <!-- declare resource setup for new module --> <resources> <!-- resource identifier --> <firstattlantic_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_FirstAttlantic</module> </setup> <!-- specify database connection for this resource --> <connection> <!-- do not create new connection, use predefined core setup connection --> <use>core_setup</use> </connection> </firstattlantic_setup> <firstattlantic_write> <use>core_write</use> </firstattlantic_write> <firstattlantic_read> <use>core_read</use> </firstattlantic_read> </resources> </global> <!-- declare default configuration values for this module --> <default> <!-- 'payment' configuration section (tab) --> <payment> <!-- 'firstattlantic' configuration group (fieldset) --> <firstattlantic> <!-- by default this payment method is inactive --> <active>0</active> <!-- model to handle logic for this payment method --> <model>firstattlantic/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>Credit Card Payment</title> </firstattlantic> </payment> </default> </config>
<!-- 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>
/** * Here are examples of flags that will determine functionality availability * of this module to be used by frontend and backend. * * @see all flags and their defaults in Mage_Payment_Model_Method_Abstract * * It is possible to have a custom dynamic logic by overloading * public function can* for each flag respectively */
/** * Is this payment method a gateway (online auth/charge) ? */ protected $_isGateway = true;
/** * Can authorize online? */ protected $_canAuthorize = true;
/** * Can use this payment method in administration panel? */ protected $_canUseInternal = true;
/** * Can show this payment method as an option on checkout payment page? */ protected $_canUseCheckout = true;
/** * Is this payment method suitable for multi-shipping checkout? */ protected $_canUseForMultishipping = true;
/** * Can save credit card information for future processing? */ protected $_canSaveCc = false;
/** * Here you will need to implement authorize, capture and void public methods * * @see examples of transaction specific public methods such as * authorize, capture and void in Mage_Paygate_Model_Authorizenet */ }
I’m going to start digging into the core classes now, but, in case any of you have had this same problem, please let me know.
Ok, I’ve just got it. I still don’t understand exactly why this happens, but here it goes:
After digging into the code, i’ve noticed that it was getting stuck in the following loop in app/code/core/Mage/Core/Model/Config.php (line 248):
while (!empty($unsortedModules)) { foreach ($unsortedModules as $moduleName=>$module) { if (empty($module['parents'])) { $sortedModules[$moduleName] = $unsortedConfig->getNode('modules/'.$moduleName); unset($unsortedModules[$moduleName]); if (!empty($module['children'])) { foreach ($module['children'] as $childName=>$dummy) { unset($unsortedModules[$childName]['parents'][$moduleName]); } } break; } } }
This is the code which creates an ordered array with the Modules to be loaded. The module I’ve created depends on the Mage_Payment module, so $module[’parents’] wasn’t empty, so the condition for the first if was never true and the module never get out of $unsortedModules array, so the infinite loop (while (!empty($unsortedModules)) ).
It works now because I’ve noticed that Mage_Payment was listed on Mage_All.xml and it was loaded everytime, so I’ve taken out the dependency from the FirstAttlantic.xml file.
The part I still didn’t get was: Mage_All.xml has modules which have dependencies like my module did. For example:
But, indeed, it really seems to be a bug. If I change the module definition xml file name from “FirstAttlantic.xml” to “NFirstAttlantic.xml”, then it runs smoothly, even with the dependency.
I was looking through the thread and I’ve noticed that none of the codes have a module which first letter came before “M”.
Moshe and the other guys: Can you pls confirm this?
Magento version here: 1.0.19870
PHP Version 5.2.5
OS: Windows 2003 Server (unfortunatelly)
Maybe on linux the files are being sorted by date added instead of file name.
Sorry about the infinite posts, but I’ve spent the weekend over this and I think it’s an important info in case you’re not interested on the working-while-your-friends-are-drinking thing.
If you’re doing your module based on Authorizenet, as suggested by the wiki, your config.xml need to have all tha data that’s on Autorizenet’s config.xml. So: