Magento News
Magento Observer not being called on order payment pay
I am new to magento and trying to create an observer that will be triggered upon the payment of an order. For now the observer just sends an email however i will be extending upon this in the future, however i need to get the code working first.
I am using Magento 1.5.1.0 and having looked at the event hooks cheatsheat @ http://www.nicksays.co.uk/magento_events_cheat_sheet/ i can see that the event i want to hook onto is
‘sales_order_payment_pay’
that is dispatched from
'app/code/core/Mage/Sales/Model/Order/Payment.php'.
After reading numerous articles i understand i need to create 3 files which are as follows
-
app/etc/modules/PackageName_ModuleName.xml – > contains the xml file stating where the module can be found
-
app/code/local/PackageName/ModuleName/etc/config.xml -> which
attaches the observer to the dispatched ‘sales_order_payment_pay’ event -
app/code/local/PackageName/ModuleName/Model/Observer.php -> consists of a class which contains a method that is called by config.xml when the ‘sales_order_payment_pay event is fired.
Here are the files i have created and the directory’s the files live in, the code will be extended to do more than send an email when ‘sales_order_payment_pay’ is triggered, i am just debugging at the minuite.
My code is as follows, No email is being recived on payment of orders
app/etc/modules/Juno_Finalise.xml
<?xml version="1.0"?>
<config>
<modules>
<Juno_Finalise>
<active>true</active>
<codePool>local</codePool>
</Juno_Finalise>
</modules>
</config>
app/code/local/Juno/Finalise/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Juno_Finalise>
<version>0.1.0</version>
</Juno_Finalise>
</modules>
<global>
<models>
<junofinalise>
<class>Juno_Finalise_Model</class>
</junofinalise>
</models>
<events>
<sales_order_payment_pay>
<observers>
<juno_finalise_order_observer>
<type>singleton</type>
<class>junofinalise/order_observer</class>
<method>finaliseJunoOrder</method>
</juno_finalise_order_observer>
</observers>
</sales_order_payment_pay>
</events>
</global>
</config>
app/code/local/Juno/Finalise/Model/Order/Observer.php
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class Juno_Finalise_Model_Observer
{
public function finaliseJunoOrder($event)
{
mail('ian.cassidy1404@gmail.com','call_juno_api','now call juno api');
/*
Sale has now been processed and is paid for, function needs modifying to call juno api
*/
}
}
?>
Any help would be much appreciated.
Many thanks
Ian
Magento Observer not being called on order payment pay
Possibly Related Posts:
- Database query different results
- Menu highlight in magento under admin
- magento disable a banner on certain category pages or have a banner with multiple links
- Magento, using ACL for frontend. Possible?
- Magento IE-7 Fix In Windows XP
RSS Feed