EcommerceBundle/Factory/Providers/PayPalDirectPaymentProvider.php
public function cancelation(Request $request)
    {
        $em = $this->container->get('doctrine')->getManager();
        if( $request->get('token') != '' ){
            //Search on transaction paymentDetails the $paymentId
            $token = $request->get('token');
            $transaction = $em->getRepository('EcommerceBundle:Transaction')->findOnPaymentDetails($token);
            //UPDATE TRANSACTION
            if($transaction instanceof Transaction){
                $transaction->setStatus(Transaction::STATUS_CANCELLED);
                $em->flush();
            }

            $this->container->get('session')->getFlashBag()->add(
                'danger',
                'transaction.cancel'
            );
            
            return $this->redirect($this->generateUrl('core_profile_index', array('transactions' => true)));
            
        }
    }
public function cancelation(Request $request)
    {
        $em = $this->container->get('doctrine')->getManager();
        if( $request->get('token') != '' ){
            //Search on transaction paymentDetails the $paymentId
            $token = $request->get('token');
            $transaction = $em->getRepository('EcommerceBundle:Transaction')->findOnPaymentDetails($token);
            //UPDATE TRANSACTION
            if($transaction instanceof Transaction){
                $transaction->setStatus(Transaction::STATUS_CANCELLED);
                $em->flush();
            }

            $this->container->get('session')->getFlashBag()->add(
                'danger',
                'transaction.cancel'
            );
            
            return $this->redirect($this->generateUrl('core_profile_index', array('transactions' => true)));
            
        }
    }
public function cancelation ( Request $ request ) { $ em = $ this -> container -> get ( 'doctrine' ) -> getManager ( ) ; if ( $ request -> get ( 'token' ) != '' ) { //Search on transaction paymentDetails the $paymentId $ token = $ request -> get ( 'token' ) ; $ transaction = $ em -> getRepository ( 'EcommerceBundle:Transaction' ) -> findOnPaymentDetails ( $ token ) ; //UPDATE TRANSACTION if ( $ transaction instanceof Transaction ) { $ transaction -> setStatus ( Transaction :: STATUS_CANCELLED ) ; $ em -> flush ( ) ; } $ this -> container -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'danger' , 'transaction.cancel' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'core_profile_index' , array ( 'transactions' => true ) ) ) ; } }
Cancelation payment OK

@param Request $request

@return stdClass
Cancelation payment OK