How to get order id and other details of order for sales_order_payment_cancel event observer. i know how to get them for checkout_onepage_controller_success_action. But that method is not working in it. And showing this error.
Fatal error: Call to a member function getId() on a non-object in /home/orderitonline/public_html/includes/src/Barcatsia_Smsntf_Model_Observer.php on line 108
<sales_order_payment_cancel>
<observers>
<Barcatsia_Smsntf_Model_Observer_cancelOrder>
<type>singleton</type>
<class>Barcatsia_Smsntf_Model_Observer</class>
<method>smsntf_cancel_order</method>
</Barcatsia_Smsntf_Model_Observer_cancelOrder>
</observers>
</sales_order_payment_cancel>
-
public function smsntf_cancel_order($observer){
$order = $observer->getEvent()->getOrder();
$orderIds = $order->getId();
if(Mage::getStoreConfig
('testsection/cancel_order/Smsntf_module_activation')){
$layout = Mage::app()->getLayout();
$order = Mage::getModel('sales/order')->load($orderIds);
$message_for_send = Mage::getStoreConfig
('testsection/cancel_order/Smsntf_text_field_msg');
$http_url = Mage::getStoreConfig
('testsection/cancel_order/Smsntf_text_field_api_calling_url');
$arr_params = array('Smsntf_text_field_authkey', 'Smsntf_text_field_mobile',
'Smsntf_text_field_senderid', 'Smsntf_text_field_routeid', 'Smsntf_text_field_additional',
'Smsntf_text_field_additional', 'Smsntf_text_field_additional1',
'Smsntf_text_field_additional2', 'Smsntf_text_field_additional3',
'Smsntf_text_field_additional4');
//replaceing %O% with Order Number
$message_for_send = str_replace('%O%',100000000+intval($orderIds[0]),
$message_for_send);
//replaceing %N% with Mobile Number
$message_for_send = str_replace('%N%',$order->getdata
('customer_firstname'),$message_for_send);
//replaceing %A% with Grand Total
$message_for_send = str_replace('%A%',$order->getdata('grand_total'),
$message_for_send);
$http_url .='?'. Mage::getStoreConfig
('testsection/cancel_order/Smsntf_text_field_Msg_prm').'='.urlencode($message_for_send);
for($a=0; $a<sizeof($arr_params); $a++){
if(trim(Mage::getStoreConfig('testsection/cancel_order/'.
$arr_params[$a]))!=''){
if(trim($arr_params[$a])!='Smsntf_text_field_mobile')
$http_url .= '&'.Mage::getStoreConfig
('testsection/cancel_order/'.$arr_params[$a]);
else
$http_url .= '&'.Mage::getStoreConfig
('testsection/cancel_order/'.$arr_params[$a]).'='.$order->getBillingAddress()->getData
('telephone');
}
}
//printing system->configuration inputs value
// echo Mage::getStoreConfig
('testsection/cancel_order/active');
$this->send_sms($http_url);
}else{
return false;
}
}
Barcatsia_Smsntf_Model_Observer
$Observer->getPayment()->getOrder()->getId()