0

I have just created one module after checkout success event in Magento.

etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Tech_Paymentinfo>
            <version>0.1.0</version>
        </Tech_Paymentinfo>
    </modules>
    <global>
        <helpers>
            <paymentinfo>
                <class>Tech_Paymentinfo_Helper</class>
            </paymentinfo>
        </helpers>
        <models>
            <paymentinfo>
                <class>Tech_Paymentinfo_Model</class>
                <resourceModel>paymentinfo_mysql4</resourceModel>
            </paymentinfo>
        </models>
        <events>
            <sales_order_place_after> <!-- identifier of the event we want to catch -->
                <observers>
                    <sales_order_place_after_handler> <!-- identifier of the event handler -->
                        <type>singleton</type> <!-- class method call type; valid are model, object and singleton -->
                        <class>paymentinfo/observer</class> <!-- observers class alias -->
                        <method>savePayment</method>  <!-- observer's method to be called -->
                        <args></args> <!-- additional arguments passed to observer -->
                    </sales_order_place_after_handler>
                </observers>
            </sales_order_place_after>
        </events>
    </global>
</config>

And here is my Observer.php file

class Tech_Paymentinfo_Model_Observer
{
    public function savePayment(Varien_Event_Observer $observer)
        {
            //Mage::dispatchEvent('admin_session_user_login_success', array('user'=>$user));
            //$user = $observer->getEvent()->getUser();
            //$user->doSomething();
        }
}

Now I want my custom payment method data after order success.

Can any one help me to sort it out issue.

  • so what is the goal of your custom module ? I'm not sure if i understood fully you issue here – Attila Naghi Mar 25 at 13:01
  • i want payment method name into gift message field in sales order in admin section. – Nikul Mar 25 at 13:07
  • Rakesh Thank you as per above code also working fine for me. Now i want my payment method name update into Gift message field in sales order in admin. Means if i have checkmo payment method so i have update this into Gift message field into admin. – Anil Mar 25 at 13:45
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – Jai Mar 25 at 14:06
  • Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review – Sukumar Gorai Mar 25 at 15:10
2

try this way...

using create event this way..

<checkout_onepage_controller_success_action> <!-- identifier of the event we want to catch -->
                <observers>
                    <sales_order_place_after_handler> <!-- identifier of the event handler -->
                        <type>singleton</type> <!-- class method call type; valid are model, object and singleton -->
                        <class>paymentinfo/observer</class> <!-- observers class alias -->
                        <method>savePayment</method>  <!-- observer's method to be called -->
                        <args></args> <!-- additional arguments passed to observer -->
                    </sales_order_place_after_handler>
                </observers>
</checkout_onepage_controller_success_action>

and using observer get specific payment method like
i have get check method

public function savePayment(Varien_Event_Observer $observer)
{
            $order = new Mage_Sales_Model_Order();
            $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();

            $order->loadByIncrementId($incrementId);

            $payment_method_code = $order->getPayment()->getMethodInstance()->getCode(); //Fetch the payment method code from order

            if($payment_method_code == "checkmo"){
                // your logic
            }
}
  • Thanks it's working fine... :) – Nikul Mar 25 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.