cancel
Showing results for 
Search instead for 
Did you mean: 

Custom payment method doesn't show up on checkout

SOLVED

Custom payment method doesn't show up on checkout

Hello,

 

I created a new payment method, but it doesn't show in the frontend.

I follow this tutorial, only the first part to have a simple payment method.

But it doesn't work, in \Mage_Payment_Model_Method_Abstract::isAvailable() my method isn't active, if I harcoded it:

$isActive = 1;
$checkResult->isAvailable = $isActive;

I can see the radio button but not the name. I don't know what's happend, I can see it in the backend and change the configuration successfully, I can get the method in a observer: 

$method->getCode()

But still it doesn't appear in the payment step.

 

any idea?

 

My full code:

    config.xml
    
    <?xml version="1.0" encoding="UTF-8"?>
    <config>
        <modules>
            <Namespace_ModuleName>
                <module>0.0.1</module>
            </Namespace_ModuleName>
        </modules>
        <global>
            <helpers>
                <modulename>
                    <class>Namespace_ModuleName_Helper</class>
                </modulename>
            </helpers>
            <models>
                <modulename>
                    <class>Namespace_ModuleName_Model</class>
                </modulename>
            </models>
        </global>
        <default>
            <carriers>
                <modulename>
                    <active>1</active>
                    <title>Custom Title ship</title>
                    <model>modulename/carrier_ship</model>
                    <sort_order>10</sort_order>
                </modulename>
            </carriers>
            <payment>
                <modulename>
                    <active>1</active>
                    <title>Custom Title pay</title>
                    <model>modulename/payment_pay</model>
                    <order_status>processing</order_status>
                    <payment_action>sale</payment_action>
                    <allowspecific>0</allowspecific>
                    <sort_order>1</sort_order>
                </modulename>
            </payment>
        </default>
        <frontend>
            <events>
                <payment_method_is_active>
                    <observers>
                        <modulename_payment_method_is_active>
                            <type>singleton</type>
                            <class>modulename/observer</class>
                            <method>paymentMethodIsActive</method>
                        </modulename_payment_method_is_active>
                    </observers>
                </payment_method_is_active>
            </events>
        </frontend>
    </config>
    system.xml
    
    <?xml version="1.0" encoding="UTF-8"?>
    <config>
        <sections>
            <carriers>
                <groups>
                    <modulename translate="label" module="modulename">
                        <label>Custom Label Carrier</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>
                        <fields>
                            <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>
                            <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>
                            <sort_order translate="label">
                                <label>Sort Order</label>
                                <frontend_type>text</frontend_type>
                                <sort_order>100</sort_order>
                                <show_in_default>1</show_in_default>
                                <show_in_website>1</show_in_website>
                                <show_in_store>0</show_in_store>
                            </sort_order>
                            <sallowspecific translate="label">
                                <label>Ship to Applicable Countries</label>
                                <frontend_type>select</frontend_type>
                                <sort_order>90</sort_order>
                                <frontend_class>shipping-applicable-country</frontend_class>
                                <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
                                <show_in_default>1</show_in_default>
                                <show_in_website>1</show_in_website>
                                <show_in_store>0</show_in_store>
                            </sallowspecific>
                            <specificcountry translate="label">
                                <label>Ship to Specific Countries</label>
                                <frontend_type>multiselect</frontend_type>
                                <sort_order>91</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>0</show_in_store>
                                <can_be_empty>1</can_be_empty>
                            </specificcountry>
                        </fields>
                    </modulename>
                </groups>
            </carriers>
            <payment>
    			<groups>
    				<modulename translate="label" module="modulename">
    					<label>Custom Label Payment</label>
    					<sort_order>670</sort_order>
    					<show_in_default>1</show_in_default>
    					<show_in_website>1</show_in_website>
    					<show_in_store>0</show_in_store>
    					<fields>
                            <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>2</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>40</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>0</show_in_store>
    						</allowspecific>
    						<specificcountry translate="label">
    							<label>Payment from Specific countries</label>
    							<frontend_type>multiselect</frontend_type>
    							<sort_order>50</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>0</show_in_store>
    							<can_be_empty>1</can_be_empty>
    						</specificcountry>
                            <title translate="label">
                                <label>Title</label>
                                <frontend_type>text</frontend_type>
                                <sort_order>3</sort_order>
                                <show_in_default>1</show_in_default>
                                <show_in_website>1</show_in_website>
                                <show_in_store>1</show_in_store>
                            </title>
    					</fields>
    				</modulename>
    			</groups>
    		</payment>
        </sections>
    </config>
My model

    Model/Payment/Pay.php
    
    <?php
    
    class Namespace_ModuleName_Model_Payment_Pay extends Mage_Payment_Model_Method_Abstract
    {
    	protected $_code = 'pay';
    
    
    /* I tried with and without it
        protected $canUseCheckout    = true;
        public function validate()
        {
            parent::validate();
        }*/
    }

I can see my custom payment method in the database:

path value
.../active 1

But in

 

app/code/core/Mage/Payment/Model/Method/Abstract.php
public function isAvailable($quote = null)
{
$checkResult = new StdClass;
$isActive = (bool)(int)$this->getConfigData('active', $quote ? $quote->getStoreId() : null);

Here `$isActive` isn't 1, like the payment methods I can see in the frontend

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Custom payment method doesn't show up on checkout

Can you overwrite more functions in Namespace_ModuleName_Model_Payment_Pay to confirm that this class is being loaded correctly rather than editing the core file. That core file would be used for other payment methods as well so you may end up logging for a different payment method. I've looked through all of your code and can't spot what's wrong. You've searched and replaced names, so one thing I'd recommend checking is that there isn't a capitalisation problem of classnames and filenames if you're on a case sensitive filesystem.
----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

View solution in original post

6 REPLIES 6

Re: Custom payment method doesn't show up on checkout

Strange that it wouldn't be active, do you have this section correctly in your config.xml and have you flushed cache afterwards?

 

<default>
        <payment>
            <pay>
                <active>1</active>
                <model>pay/pay</model>
                <order_status>processing</order_status>
                <title>Excellence Payment Method</title>
            </pay>
         </payment>
    </default>

Remember that you'll need to update "pay" with whatever your extension is .

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

Re: Custom payment method doesn't show up on checkout

I think this part is correct, but I put all the code so you can see it

Re: Custom payment method doesn't show up on checkout

Your system.xml seems to be in the carriers section rather than the payment section, that could be it:

 

        <sections>
            <carriers>

 

Actually, scratch that, I see the closing tag now. 

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

Re: Custom payment method doesn't show up on checkout

Can you overwrite more functions in Namespace_ModuleName_Model_Payment_Pay to confirm that this class is being loaded correctly rather than editing the core file. That core file would be used for other payment methods as well so you may end up logging for a different payment method. I've looked through all of your code and can't spot what's wrong. You've searched and replaced names, so one thing I'd recommend checking is that there isn't a capitalisation problem of classnames and filenames if you're on a case sensitive filesystem.
----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!

Re: Custom payment method doesn't show up on checkout

It was I tried, I started again with other names and it works, so, I suppouse it was a name with something wrong or maybe the code was 'contamined' with older versions, something in the database saved wrong that doesn't change with the same names but works when I change them.

 

Thanks for your help

Re: Custom payment method doesn't show up on checkout

Oh glad you got it working. Sometimes starting again is the way forward when you can't spot the bug. 

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!