Magento – How to update order data after payment from paypal

magento-1.7orderspaymentpaypalsales

I am using Magento 1.7 version and having issue while updating data of order after make payment from PayPal.

I have an event sales_order_invoice_pay which works on invoice generate. When I make a payment from PayPal, it generates an invoice of order placed then this event calls.

<sales_order_invoice_pay>
      <observers>
          <test>
              <type>singleton</type>
              <class>test/observer</class>
              <method>getInvoice</method>
           </test>
       </observers>        
</sales_order_invoice_pay>

Then, I have a field in sales_flat_order table which I want to update using

$orders = Mage::getModel('sales/order')->load($orderId);
$orders->setFieldId($fieldId);

I have value of both $orderId and $fieldId.

But it is not updating. It shows blank. I think this is due to PayPal IPN which overwrites the value of my field.

Is there any event for updating this value?

Any event which trigger after PayPal IPN received?

Any event which trigger after order detail email sent to customer?

Any idea which solves above issue?

Best Answer

Just a clue but do you $orders->save(); after your code to actually save your changes?

You can find a list of available Events here: http://www.nicksays.co.uk/magento-events-cheat-sheet-1-7/