Action/CaptureAction.php
public function execute($request)
    {
        /** @var $request Capture */
        RequestNotSupportedException::assertSupports($this, $request);

        $model = ArrayObject::ensureArrayObject($request->getModel());

        if ( false == $model['token'] ) 
		{
			$this->payment->execute(new Log('No token. First....', $this));

            if (false == $model['return_url'] && $request->getToken()) {
                $model['return_url'] = $request->getToken()->getTargetUrl();
            }

            if (false == $model['cancel_url'] && $request->getToken()) {
                $model['cancel_url'] = $request->getToken()->getTargetUrl();
            }

			$model['state'] = StateInterface::STATE_WAITING;
			$this->payment->execute(new Log('Waiting for reply when calling SetExpressCheckout', $this));
            $this->payment->execute(new SetExpressCheckout($model));

            if ( isset($model['error_code']) && $model['error_code'] === Errors::ERRCODE_NO_ERROR )
			{
		        if (isset($model['checkout_url'])) 
				{
					$model['state'] = StateInterface::STATE_REPLIED;
					$this->payment->execute(new Log('checkout_url='.$model['checkout_url'], $this));
		            throw new HttpRedirect($model['checkout_url']);
		        }
				else
				{
					$model['state'] = StateInterface::STATE_ERROR;
					$this->payment->execute(new Log('No checkout_url returned.', $this));
				}
            }
		}

		else
		{
			$this->payment->execute(new Log('Before calling GetTransactionDetails', $this));
			$this->logAllModel($model);
			
	        $copiedModel = new ArrayObject(array(
	            'token' => $model['token'],
	        ));
			
            $this->payment->execute(new GetTransactionDetails($copiedModel));

			$this->payment->execute(new Log('After calling GetTransactionDetails', $this));
			$this->logAllModel($copiedModel);
			
			if ( $copiedModel['error_code'] === Errors::ERRCODE_NO_ERROR )
			{
				$model['bank_code'] = $copiedModel['bank_code'];
				$model['transaction_id'] = $copiedModel['transaction_id'];
				$model['transaction_status'] = $copiedModel['transaction_status'];
				
				if ( $copiedModel['transaction_status'] == TransactionStatus::PAID )
				{
					$model['state'] = StateInterface::STATE_CONFIRMED;
					$this->payment->execute(new Log('Order paid. OK. OK. OK.', $this));
				}
				else if ( $copiedModel['transaction_status'] == TransactionStatus::NOT_PAID )
				{
					$model['state'] = StateInterface::STATE_ERROR;
					$this->payment->execute(new Log('Payer decided to avoid payment', $this));
				}
				else if ( $copiedModel['transaction_status'] == TransactionStatus::PAID_WAITING_FOR_PROCESS )
				{
					$model['state'] = StateInterface::STATE_NOTIFIED;
					$this->payment->execute(new Log('Payment process notified but not captured.', $this));
				}
				else
				{
					$model['state'] = StateInterface::STATE_ERROR;
					$this->payment->execute(new Log('Payment process return OK but transaction status is not invalid. Unknown error !!!', $this));
				}
			}
			else
			{
				$model['state'] = StateInterface::STATE_ERROR;
				$this->payment->execute(new Log('Error after calling GetTransactionDetails', $this));
			}
		}
    }
public function execute($request)
    {
        /** @var $request Capture */
        RequestNotSupportedException::assertSupports($this, $request);

        $model = ArrayObject::ensureArrayObject($request->getModel());

        if ( false == $model['token'] ) 
		{
			$this->payment->execute(new Log('No token. First....', $this));

            if (false == $model['return_url'] && $request->getToken()) {
                $model['return_url'] = $request->getToken()->getTargetUrl();
            }

            if (false == $model['cancel_url'] && $request->getToken()) {
                $model['cancel_url'] = $request->getToken()->getTargetUrl();
            }

			$model['state'] = StateInterface::STATE_WAITING;
			$this->payment->execute(new Log('Waiting for reply when calling SetExpressCheckout', $this));
            $this->payment->execute(new SetExpressCheckout($model));

            if ( isset($model['error_code']) && $model['error_code'] === Errors::ERRCODE_NO_ERROR )
			{
		        if (isset($model['checkout_url'])) 
				{
					$model['state'] = StateInterface::STATE_REPLIED;
					$this->payment->execute(new Log('checkout_url='.$model['checkout_url'], $this));
		            throw new HttpRedirect($model['checkout_url']);
		        }
				else
				{
					$model['state'] = StateInterface::STATE_ERROR;
					$this->payment->execute(new Log('No checkout_url returned.', $this));
				}
            }
		}

		else
		{
			$this->payment->execute(new Log('Before calling GetTransactionDetails', $this));
			$this->logAllModel($model);
			
	        $copiedModel = new ArrayObject(array(
	            'token' => $model['token'],
	        ));
			
            $this->payment->execute(new GetTransactionDetails($copiedModel));

			$this->payment->execute(new Log('After calling GetTransactionDetails', $this));
			$this->logAllModel($copiedModel);
			
			if ( $copiedModel['error_code'] === Errors::ERRCODE_NO_ERROR )
			{
				$model['bank_code'] = $copiedModel['bank_code'];
				$model['transaction_id'] = $copiedModel['transaction_id'];
				$model['transaction_status'] = $copiedModel['transaction_status'];
				
				if ( $copiedModel['transaction_status'] == TransactionStatus::PAID )
				{
					$model['state'] = StateInterface::STATE_CONFIRMED;
					$this->payment->execute(new Log('Order paid. OK. OK. OK.', $this));
				}
				else if ( $copiedModel['transaction_status'] == TransactionStatus::NOT_PAID )
				{
					$model['state'] = StateInterface::STATE_ERROR;
					$this->payment->execute(new Log('Payer decided to avoid payment', $this));
				}
				else if ( $copiedModel['transaction_status'] == TransactionStatus::PAID_WAITING_FOR_PROCESS )
				{
					$model['state'] = StateInterface::STATE_NOTIFIED;
					$this->payment->execute(new Log('Payment process notified but not captured.', $this));
				}
				else
				{
					$model['state'] = StateInterface::STATE_ERROR;
					$this->payment->execute(new Log('Payment process return OK but transaction status is not invalid. Unknown error !!!', $this));
				}
			}
			else
			{
				$model['state'] = StateInterface::STATE_ERROR;
				$this->payment->execute(new Log('Error after calling GetTransactionDetails', $this));
			}
		}
    }
{@inheritDoc}