3

Amazon payments api requires to send session post variable, grand total and increment id. How to get order data in salesPlaceOrderAfter observer

class Amazon_Payments_Model_Observer extends Varien_Object
{

public function salesPlaceOrderAfter($observer)
{
    $post = Mage::app()->getRequest()->getPost();
        Mage::log('post salesPlaceOrderAfter');
        Mage::log($post);
        //$orderData = $observer->getQuote()->getData();
       $orderData = $observer->getEvent()->getOrder();
        Mage::log('orderData');
        Mage::log($orderData);
        //$checkout = Mage::getSingleton('checkout/session')->getQuote();
        //Mage::log($checkout);




    $payment_method = $post['payment']['method'];
    if($payment_method=='pay'){
        $session = $post['billing']['session'];
        $access_token = $post['billing']['access_token'];
    }


}
10

The event is dispatched like this:

Mage::dispatchEvent('sales_order_place_after', array('order'=>$this));

So check first that you are observing the correct event: sales_order_place_after

(your method naming could indicate you have the name the other way around, salesPlaceOrderAfter)

I would suggest logging the debug output with

$orderData = $observer->getEvent()->getOrder();
Mage::log('orderData');
Mage::log($orderData->debug());

and getting the data with (or adjust to order currency by removing base)

$orderData->getIncrementId();
$orderData->getBaseGrandTotal();
6

we have to access the grand total and increment id then you can also use below one

class Amazon_Payments_Model_Observer extends Varien_Object
{
 public function salesPlaceOrderAfter($observer)
 {
  /*your code*/
   Mage::log('order Grand Total:'.$observer->getOrder()->getBaseGrandTotal());
   Mage::log('increment id:'.$observer->getOrder()->getIncrementId());
  /*your code*/
 }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.