public function getPaymentStatus()
 {
     // Get the payment ID before session clear
     $payment_id = Session::get('paypal_payment_id');
     // clear the session payment ID
     Session::forget('paypal_payment_id');
     if (empty(Input::get('PayerID')) || empty(Input::get('token'))) {
         return Redirect::route('original.route')->with('error', 'Payment failed');
     }
     $payment = Payment::get($payment_id, $this->_api_context);
     // PaymentExecution object includes information necessary
     // to execute a PayPal account payment.
     // The payer_id is added to the request query parameters
     // when the user is redirected from paypal back to your site
     $execution = new PaymentExecution();
     $execution->setPayerId(Input::get('PayerID'));
     //Execute the payment
     $result = $payment->execute($execution, $this->_api_context);
     echo '<pre>';
     print_r($result);
     echo '</pre>';
     exit;
     // DEBUG RESULT, remove it later
     if ($result->getState() == 'approved') {
         // payment made
         return Redirect::route('original.route')->with('success', 'Payment success');
     }
     return Redirect::route('original.route')->with('error', 'Payment failed');
 }
 public static function execute($paymentId, $payerId, PayPal\Rest\ApiContext $apiContext)
 {
     #Logger
     CLogger::getInstance()->add(__LINE__, __CLASS__, 'payment_id', $paymentId);
     CLogger::getInstance()->add(__LINE__, __CLASS__, 'payer_id', $payerId);
     $payment = \PayPal\Api\Payment::get($paymentId, $apiContext);
     self::_setIndent($payment);
     $execution = PaymentExecution::execute($payerId);
     return self::_process($payment, $apiContext, $execution);
 }