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

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

        if ( !isset($model['token']) || false === $model['token'] ) 
		{
/*			
            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();
            }
*/
            if (false == $model['return_url'] || false == $model['cancel_url']) 
			{
	            $notifyToken = $this->tokenFactory->createNotifyToken(
	                $request->getToken()->getPaymentName(),
	                $request->getToken()->getDetails()
	            );
				
                $model['return_url'] = false == $model['return_url'] ? $notifyToken->getTargetUrl() : $model['return_url'];
                $model['cancel_url'] = false == $model['cancel_url'] ? $notifyToken->getTargetUrl() : $model['cancel_url'];
            }

			$model['state'] = StateInterface::STATE_WAITING;
            $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']));
		            throw new HttpRedirect($model['checkout_url']);
		        }
				else
				{
					$model['state'] = StateInterface::STATE_ERROR;
					$this->execute(new Log('No checkout_url returned.'));
				}
            }
/*			
			else
			{
				$model['state'] = StateInterface::STATE_ERROR;	
				
				$errMsg = 'Error from SetExpressCheckout.';
				$errMsg .= '{error_code='.$model['error_code'].'}';
				$errMsg .= '{description='.$model['description'].'}';
				$this->payment->execute(new Log($errMsg));
			}
        }
		else
		{
	        $this->payment->execute(new GetTransactionDetails($model));
	        if ( isset($model['error_code']) && $model['error_code'] === Errors::ERRCODE_NO_ERROR )
			{
				if ( !isset($model['transaction_status']) )
				{
					$model['state'] = StateInterface::STATE_ERROR;
					$this->execute(new Log('GetTransactionDetails has no transaction status.'));
				}
				
				if ( $model['transaction_status'] === TransactionStatus::PAID)
				{
					$model['state'] = StateInterface::STATE_CONFIRMED;
					$this->execute(new Log('GetTransactionDetails -> Paid.'));
					
					return;
				}

				if ( $model['transaction_status'] === TransactionStatus::PAID_WAITING_FOR_PROCESS)
				{
					$model['state'] = StateInterface::STATE_NOTIFIED;
					$this->execute(new Log('GetTransactionDetails -> Waiting for paying.'));
					
					return;
				}
				
				if ( $model['transaction_status'] === TransactionStatus::NOT_PAID)
				{
					$model['state'] = StateInterface::STATE_ERROR;
					$this->execute(new Log('GetTransactionDetails-> Not paid'));
					
					return;
				}
			}
			else
			{
				$model['state'] = StateInterface::STATE_ERROR;
				$this->execute(new Log('Unknown error when checking payment.'));

				return;
			}
		}
*/  
    }

    /**
     * {@inheritDoc}
     */
    public function supports($request)
    {
        return
            $request instanceof Capture &&
            $request->getModel() instanceof \ArrayAccess
        ; 
    }
}
public function execute($request)
    {
        /** @var $request Capture */
        RequestNotSupportedException::assertSupports($this, $request);

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

        if ( !isset($model['token']) || false === $model['token'] ) 
		{
/*			
            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();
            }
*/
            if (false == $model['return_url'] || false == $model['cancel_url']) 
			{
	            $notifyToken = $this->tokenFactory->createNotifyToken(
	                $request->getToken()->getPaymentName(),
	                $request->getToken()->getDetails()
	            );
				
                $model['return_url'] = false == $model['return_url'] ? $notifyToken->getTargetUrl() : $model['return_url'];
                $model['cancel_url'] = false == $model['cancel_url'] ? $notifyToken->getTargetUrl() : $model['cancel_url'];
            }

			$model['state'] = StateInterface::STATE_WAITING;
            $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']));
		            throw new HttpRedirect($model['checkout_url']);
		        }
				else
				{
					$model['state'] = StateInterface::STATE_ERROR;
					$this->execute(new Log('No checkout_url returned.'));
				}
            }
/*			
			else
			{
				$model['state'] = StateInterface::STATE_ERROR;	
				
				$errMsg = 'Error from SetExpressCheckout.';
				$errMsg .= '{error_code='.$model['error_code'].'}';
				$errMsg .= '{description='.$model['description'].'}';
				$this->payment->execute(new Log($errMsg));
			}
        }
		else
		{
	        $this->payment->execute(new GetTransactionDetails($model));
	        if ( isset($model['error_code']) && $model['error_code'] === Errors::ERRCODE_NO_ERROR )
			{
				if ( !isset($model['transaction_status']) )
				{
					$model['state'] = StateInterface::STATE_ERROR;
					$this->execute(new Log('GetTransactionDetails has no transaction status.'));
				}
				
				if ( $model['transaction_status'] === TransactionStatus::PAID)
				{
					$model['state'] = StateInterface::STATE_CONFIRMED;
					$this->execute(new Log('GetTransactionDetails -> Paid.'));
					
					return;
				}

				if ( $model['transaction_status'] === TransactionStatus::PAID_WAITING_FOR_PROCESS)
				{
					$model['state'] = StateInterface::STATE_NOTIFIED;
					$this->execute(new Log('GetTransactionDetails -> Waiting for paying.'));
					
					return;
				}
				
				if ( $model['transaction_status'] === TransactionStatus::NOT_PAID)
				{
					$model['state'] = StateInterface::STATE_ERROR;
					$this->execute(new Log('GetTransactionDetails-> Not paid'));
					
					return;
				}
			}
			else
			{
				$model['state'] = StateInterface::STATE_ERROR;
				$this->execute(new Log('Unknown error when checking payment.'));

				return;
			}
		}
*/  
    }

    /**
     * {@inheritDoc}
     */
    public function supports($request)
    {
        return
            $request instanceof Capture &&
            $request->getModel() instanceof \ArrayAccess
        ; 
    }
}
{@inheritDoc}