local/modules/Klikandpay/Controller/KlikandpayFrontController.php
/**
     * Method used when an payment is accepeted
     *
     * @param  string $hash hash to retrieve order
     *
     * @throws \Exception
     *
     * @return \Thelia\Core\HttpFoundation\Response
     */
Method used when an payment is accepeted
@param  string $hash hash to retrieve order

@throws \Exception


Method used when an payment is accepeted @param string $hash hash to retrieve order @throws \ Exception
public function placedAction($hash)
    {
        $order = null;
        $allowed = array('%order_hash%', '%order_id%', '%order_ref%');
        foreach($allowed as $type)
        {
            if(strpos(ConfigQuery::read('klikandpay_retourvok'), $type) !== FALSE)
            {
                if($type === '%order_hash%')
                {
                    $return = KlikandpayReturnQuery::create()->filterByTransaction($hash)->findOne();
                    if ($return)
                    {
                        $hash = $return->getOrderId();
                        $type = '%order_id%';
                    }
                }
                $order = $this->findOrder($hash, $type);
                break; 
            }
        }
        if($order === null)
        {
            throw new \Exception("We are unable to retrieve your order.");
        }
        $cart_event = new CartEvent($this->getSession()->getCart());
        $this->dispatch(TheliaEvents::CART_CLEAR, $cart_event);
        return $this->render(
            self::ORDER_PLACED,
            array('placed_order_id' => $order->getId())
        );
    }
public function placedAction ( $ hash ) { $ order = null ; $ allowed = array ( '%order_hash%' , '%order_id%' , '%order_ref%' ) ; foreach ( $ allowed as $ type ) { if ( strpos ( ConfigQuery :: read ( 'klikandpay_retourvok' ) , $ type ) !== FALSE ) { if ( $ type === '%order_hash%' ) { $ return = KlikandpayReturnQuery :: create ( ) -> filterByTransaction ( $ hash ) -> findOne ( ) ; if ( $ return ) { $ hash = $ return -> getOrderId ( ) ; $ type = '%order_id%' ; } } $ order = $ this -> findOrder ( $ hash , $ type ) ; break ; } } if ( $ order === null ) { throw new \ Exception ( " We are unable to retrieve your order. " ) ; } $ cart_event = new CartEvent ( $ this -> getSession ( ) -> getCart ( ) ) ; $ this -> dispatch ( TheliaEvents :: CART_CLEAR , $ cart_event ) ; return $ this -> render ( self :: ORDER_PLACED , array ( 'placed_order_id' => $ order -> getId ( ) ) ) ; }
Method used when an payment is accepeted
 @param  string $hash hash to retrieve order
Method used when an payment is accepeted @param string $hash hash to retrieve order
// Retrieve the order by id or ref or hash // If order has been Paid, HASH was removed from the order table so we use the order id instead /** var \Thelia\Model\KlikandpayReturn $return **/ // will leave the foreach loop and also "break" the if statement // Empty cart