问题描述:

Please let me know how to find the payment success or failed information on the payment success screen itself. Kindly Send me the Code snippet.

They above request is for after completing the payment, we need to provide downloadable link to customer without changing the order status in admin interface.

Thanks in advance,

P.Karthikeyan

网友答案:

Create the structure and the files:

app/etc/modules/Myproyect_Mymodule.xml
app/code/local/Myproyect/Mymodule
app/code/local/Myproyect/Mymodule/etc/config.xml
app/code/local/Myproyect/Mymodule/Model/Mymodel.php

Create the xml file to setup the module: app/etc/modules/Myproyect_Mymodule.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Myproyect_Mymodule>
            <active>true</active>
            <codePool>local</codePool>
        </Myproyect_Mymodule>
    </modules>
</config>

Here you will see the hook configuration. At the "events" tab you can add any observer to any event by setting the name of the event (line 21), you module (line 23) and the method of the class (line 26).

app/code/local/Myproyect/Mymodule/etc/config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Myproyect_Mymodule>
            <version>0.0.1</version>
        </Myproyect_Mymodule>
    </modules>
    <global>
        <helpers>
            <mymodule>
                <class>Myproyect_Mymodule_Helper</class>
            </mymodule>
        </helpers>
        <models>
            <mymodule>
                <class>Myproyect_Mymodule_Mymodel</class>
            </mymodule>
        </models>
        <events>
            <!-- here the event to hook: -->
            <checkout_onepage_controller_success_action>
                <observers>
                    <mymodule_model_mymodel>
                        <type>model</type>
                        <class>Myproyect_Mymodule_Model_Mymodel</class>
                        <method>myModelMethod</method>
                    </mymodule_model_mymodel>
                </observers>
            </checkout_onepage_controller_success_action>
       </events>
    </global>
</config>

Here at the line 6 you must create the method to execute for the especified event. app/code/local/MyProject/MyModulo/Model/MyModel.php:

class Myproyect_Mymodule_Model_Mymodel extends Mage_Core_Model_Abstract
{

    public function myModelMethod()
    {
         // acciones.
    }

}
相关阅读:
Top