Пример #1
0
 /**
  * Send request to PayfloPro gateway for get Secure Token
  *
  * @return ResultInterface
  */
 public function execute()
 {
     $this->sessionTransparent->setQuoteId($this->sessionManager->getQuote()->getId());
     $token = $this->secureTokenService->requestToken($this->sessionManager->getQuote());
     $result = [];
     $result[$this->transparent->getCode()]['fields'] = $token->getData();
     $result['success'] = $token->getSecuretoken() ? true : false;
     if (!$result['success']) {
         $result['error'] = true;
         $result['error_messages'] = __('Secure Token Error. Try again.');
     }
     return $this->resultJsonFactory->create()->setData($result);
 }
Пример #2
0
 /**
  * Send request to PayfloPro gateway for get Secure Token
  *
  * @return ResultInterface
  */
 public function executeInternal()
 {
     /** @var Quote $quote */
     $quote = $this->sessionManager->getQuote();
     if (!$quote or !$quote instanceof Quote) {
         return $this->getErrorResponse();
     }
     $this->sessionTransparent->setQuoteId($quote->getId());
     try {
         $token = $this->secureTokenService->requestToken($quote);
         if (!$token->getData('securetoken')) {
             throw new \LogicException();
         }
         return $this->resultJsonFactory->create()->setData([$this->transparent->getCode() => ['fields' => $token->getData()], 'success' => true, 'error' => false]);
     } catch (\Exception $e) {
         return $this->getErrorResponse();
     }
 }