0

I am creating a module to save the errors response of shipping method and payment method on checkout page through observer

Like when its say user submit his/her billing/shipping and they get :

the shipping method is currently unavailable

save this error into table. and on when they "place order" and get the error :

Gateway error: Unable to read response, or response is empty

save it also in db

my code is config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Paras_Ordertrack>
      <version>0.1.0</version>
    </Paras_Ordertrack>
  </modules>
  <frontend>
        <events>
            <controller_action_predispatch_checkout_onepage_saveBilling>
                <observers>
                    <checkout_order>
                        <type>singleton</type>
                        <class>Paras_Ordertrack_Model_Observer</class>
                        <method>saveorder</method>
                    </checkout_order>
                </observers>
            </controller_action_predispatch_checkout_onepage_saveBilling>
             <sales_model_service_quote_submit_success>
                <observers>
                    <checkout_order>
                        <type>singleton</type>
                        <class>Paras_Ordertrack_Model_Observer</class>
                        <method>orderPlace</method>
                    </checkout_order>
                </observers>
            </sales_model_service_quote_submit_success>        
        </events>
    </frontend>
    --------
    --------
</config> 

Observer.php

<?php 
class Paras_Ordertrack_Model_Observer
{

    public function saveorder($observer)
    {
        // how to get shipping response error here ??
    }



    public function orderPlace($observer){      

        // how to get payment method response error here ??
    }

}
0

Instead of observing sales_model_service_quote_submit_success, you want to observe sales_model_service_quote_submit_failure. This event is fired when there is an error. Then, you'll want to use PHP's Exception class to get the previously thrown exception with the getPrevious() method.

On the first one, you're currently observing the preDispatch method of the controller. At that point, the controller action won't have been run, so you'll want to change that event to another that will happen after the error occurs.

Please let me know if you have any questions!

| improve this answer | |

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.