Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a Magento event Observer AFTER payment capture

Tags:

php

magento

Im trying to call an Observer after the order has been created, and AFTER payment has been captured. So far I've tried; checkout_submit_all_after, sales_order_payment_place_end, sales_order_place_after, sales_order_payment_pay, sales_order_payment_capture, sales_order_payment_transaction_save_after

Just to name the main ones. I've also logged all Event Dispaches inside dispatchEvent() but found nothing that stands out and is only fired when i need it. the issue i'm having is that the status of the order is always ether 'Payment Pending' or something that predated this; meaning that i don't know whether the order will fail or succeed.

My aim, is to fire a function only on successful orders. thanks.

like image 871
rhif wervl Avatar asked Jan 13 '23 03:01

rhif wervl


1 Answers

after much more testing i found the following Observer to do the trick;

checkout_onepage_controller_success_action

This returns just the order id, so;

$order_id = $observer->getData('order_ids');
$order = Mage::getModel('sales/order')->load($order_id);

and you see that the order status is 'processing' and the payment is aproved (or not).

like image 73
rhif wervl Avatar answered Jan 29 '23 23:01

rhif wervl