예제 #1
0
 /**
  * @return Json
  */
 public function execute()
 {
     $response = ['success' => false];
     $storeId = $this->_request->getParam('store');
     /** @var Store $store */
     $store = $this->_storeManager->getStore($storeId);
     if (!is_null($store)) {
         $metaData = $this->_oauthMetaBuilder->build($store);
         $client = new \NostoOAuthClient($metaData);
         $response['success'] = true;
         $response['redirect_url'] = $client->getAuthorizationUrl();
     }
     return $this->_result->setData($response);
 }
예제 #2
0
 /**
  * @return Json
  */
 public function execute()
 {
     $response = ['success' => false];
     $storeId = $this->_request->getParam('store');
     /** @var Store $store */
     $store = $this->_storeManager->getStore($storeId);
     if (!is_null($store)) {
         try {
             $emailAddress = $this->_request->getParam('email');
             $metaData = $this->_accountMetaBuilder->build($store);
             // todo: how to handle this class, DI?
             if (\Zend_Validate::is($emailAddress, 'EmailAddress')) {
                 /** @var \NostoOwner $owner */
                 $owner = $metaData->getOwner();
                 $owner->setEmail($emailAddress);
             }
             $account = $this->_accountService->create($metaData);
             if ($this->_accountHelper->saveAccount($account, $store)) {
                 // todo
                 //$this->_accountHelper->updateCurrencyExchangeRates($account, $store);
                 $response['success'] = true;
                 $response['redirect_url'] = $this->_accountHelper->getIframeUrl($store, $account, ['message_type' => \NostoMessage::TYPE_SUCCESS, 'message_code' => \NostoMessage::CODE_ACCOUNT_CREATE]);
             }
         } catch (\NostoException $e) {
             $this->_logger->error($e, ['exception' => $e]);
         }
     }
     if (!$response['success']) {
         $response['redirect_url'] = $this->_accountHelper->getIframeUrl($store, null, ['message_type' => \NostoMessage::TYPE_ERROR, 'message_code' => \NostoMessage::CODE_ACCOUNT_CREATE]);
     }
     return $this->_result->setData($response);
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function setData($data, $cycleCheck = false, $options = array())
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'setData');
     if (!$pluginInfo) {
         return parent::setData($data, $cycleCheck, $options);
     } else {
         return $this->___callPlugins('setData', func_get_args(), $pluginInfo);
     }
 }
예제 #4
0
 /**
  * @return Json
  */
 public function execute()
 {
     $response = ['success' => false];
     $storeId = $this->_request->getParam('store');
     /** @var Store $store */
     $store = $this->_storeManager->getStore($storeId);
     $account = !is_null($store) ? $this->_accountHelper->findAccount($store) : null;
     if (!is_null($store) && !is_null($account)) {
         if ($this->_accountHelper->deleteAccount($account, $store)) {
             $response['success'] = true;
             $response['redirect_url'] = $this->_accountHelper->getIframeUrl($store, null, ['message_type' => \NostoMessage::TYPE_SUCCESS, 'message_code' => \NostoMessage::CODE_ACCOUNT_DELETE]);
         }
     }
     if (!$response['success']) {
         $response['redirect_url'] = $this->_accountHelper->getIframeUrl($store, $account, ['message_type' => \NostoMessage::TYPE_ERROR, 'message_code' => \NostoMessage::CODE_ACCOUNT_DELETE]);
     }
     return $this->_result->setData($response);
 }
예제 #5
0
 /**
  * Return when fails
  *
  * @param $message
  * @return \Magento\Framework\Controller\Result\Json
  */
 protected function whenError($message)
 {
     return $this->_result->setData(['success' => false, 'payload' => ['error' => $message]]);
 }
예제 #6
0
 /**
  * Return when fails
  *
  * @param $message
  * @return $this
  */
 private function whenError($message)
 {
     return $this->result->setData(['success' => false, 'payload' => ['error' => $message, 'redirect' => sprintf('%s%s', $this->baseUrl(), 'pagseguro/payment/failure')]]);
 }