I am trying to fire an observer code upon specific event which will write transactions from Magento into other system after the successful online payment such as Paypal.
Following is my requirement:
(1) Upon on successful payment on paypal with Paypal standard, Magento shall fire an observer.
(2) Magento shall load the page checkout success page which will show order placed.
(3) Magento shall show “Complete” as an order status in admin area.
(4) Magento shall notify user.
(5) Magento shall show order into recent orders and order history for user logged on on front end.
(6) Invoice for an order shall be generated.
When I use event “sales_order_payment_pay”, Magento successfully fires an observer and writes the transaction into external system (requirement 1) and also load the checkout page (requirement 2) but requirements (3), (4), (5) and (6) are not met. Order status is in payment pending. Invoice is not generated. Users are not notified. Order does not appear in order history or recent orders for user.
public function myObserver (Varien_Event_Observer $observer)
{
$order_id = $observer->getPayment()->getOrder()->getId();
“""""""" REST OF THE CODE HERE “"""""""
}
When I use event “checkout_controller_onepage_success_action”, Magento DOES NOT fire an observer, Checkout Success Page is BLANK whereas requirements (3), (4), (5) and (6) are met. How would I get the event to fire and the page to load?
public function myObserver (Varien_Event_Observer $observer)
{
$order_id = $observer->getEvent()->getOrder()->getId();
“""""""" REST OF THE CODE HERE “"""""""
}
When I use event “controller_action_layout_render_after_checkout_onepage_success”, Magento DOES NOT fire an observer. In this case, all other requirements are met including (2). How would I get the event to fire?
public function myObserver (Varien_Event_Observer $observer)
{
$order_id = $observer->getEvent()->getOrder()->getId();
“""""""" REST OF THE CODE HERE “"""""""
}
I am interested to know if observer needs “exit ;” or “return true ;” statements at the end of the code.
Will someone please point me here in the right direction?