I need to get order id after payment is successfully completed. Is there observer to do this?
2 Answers
You can use the sales_order_payment_pay
event to get the order id after payment is completed successfully.
below code in etc/config.xml
<?xml version="1.0"?>
<config>
<global>
<events>
<sales_order_payment_pay>
<observers>
<Namespace_Module>
<type>singleton</type>
<class>Namespace_Module/Observer</class>
<method>getOrder</method>
</Namespace_Module>
</observers>
</sales_order_payment_pay>
</events>
</global>
</config>
and Model/Observer.php
public function getOrder($observer) {
$orderId = $observer->getPayment()->getOrder()->getId();
$orderNumber = $observer->getPayment()->getOrder()->getIncrementId();
}
Just to clarify; The order ID is used internally in the database. The order number is what's displayed on screen and looks like #100000153
Yes there are few events related to payment.
I would suggest to use this one: sales_order_payment_pay
.
I believe you already know how to use observer.