/** * Retrieve Session Form Key * * @return string A 16 bit unique key for forms */ public function getFormKey() { if (!$this->session->getData(self::FORM_KEY)) { $this->session->setData(self::FORM_KEY, $this->mathRandom->getRandomString(16)); } return $this->session->getData(self::FORM_KEY); }
public function testDestroy() { $data = array('key' => 'value'); $this->_model->setData($data); $this->assertEquals($data, $this->_model->getData()); $this->_model->destroy(); $this->assertEquals(array(), $this->_model->getData()); }
/** * After generate Xml * * @param \Magento\Framework\View\LayoutInterface $subject * @param \Magento\Framework\View\LayoutInterface $result * @return \Magento\Framework\View\LayoutInterface */ public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result) { if ($this->depersonalizeChecker->checkIfDepersonalize($subject)) { $this->visitor->setSkipRequestLogging(true); $this->visitor->unsetData(); $this->session->clearStorage(); $this->customerSession->clearStorage(); $this->session->setData(\Magento\Framework\Data\Form\FormKey::FORM_KEY, $this->formKey); $this->customerSession->setCustomerGroupId($this->customerGroupId); $this->customerSession->setCustomer($this->customerFactory->create()->setGroupId($this->customerGroupId)); } return $result; }
/** * After generate Xml * * @param \Magento\Framework\View\LayoutInterface $subject * @param \Magento\Framework\View\LayoutInterface $result * @return \Magento\Framework\View\LayoutInterface */ public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result) { if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && !$this->request->isAjax() && $subject->isCacheable()) { $this->visitor->setSkipRequestLogging(true); $this->visitor->unsetData(); $this->session->clearStorage(); $this->customerSession->clearStorage(); $this->session->setData(\Magento\Framework\Data\Form\FormKey::FORM_KEY, $this->formKey); $this->customerSession->setCustomerGroupId($this->customerGroupId); $this->customer->setGroupId($this->customerGroupId); $this->customerSession->setCustomer($this->customer); } return $result; }
/** * Set captcha word * * @param string $word * @return $this */ protected function _setWord($word) { $this->_session->setData($this->_getFormIdKey(self::SESSION_WORD), ['data' => $word, 'expires' => time() + $this->getTimeout()]); $this->_word = $word; return $this; }
/** * @param string $value * @return void */ public function set($value) { $this->session->setData(self::FORM_KEY, $value); }
/** * Send request with new payment to gateway during partial authorization process * * @param \Magento\Payment\Model\Info $payment * @param float $amount * @param string $requestType * @return $this * @throws \Magento\Payment\Model\Info\Exception * @throws \Magento\Framework\Model\Exception */ protected function _partialAuthorization($payment, $amount, $requestType) { $payment->setAnetTransType($requestType); /* * Try to build checksum of first request and compare with current checksum */ if ($this->getConfigData('partial_authorization_checksum_checking')) { $payment->setAmount($amount); $firstPlacingRequest = $this->_buildRequest($payment); $newChecksum = $this->_generateChecksum($firstPlacingRequest, $this->_partialAuthorizationChecksumDataKeys); $previosChecksum = $this->_session->getData($this->_partialAuthorizationChecksumSessionKey); if ($newChecksum != $previosChecksum) { $quotePayment = $payment->getOrder()->getQuote()->getPayment(); $this->cancelPartialAuthorization($payment); $this->_clearAssignedData($quotePayment); $this->setPartialAuthorizationLastActionState(self::PARTIAL_AUTH_DATA_CHANGED); $quotePayment->setAdditionalInformation($payment->getAdditionalInformation()); throw new \Magento\Payment\Model\Info\Exception(__('The shopping cart contents and/or address has been changed.')); } } $amount = $amount - $this->getCardsStorage()->getProcessedAmount(); if ($amount <= 0) { throw new \Magento\Framework\Model\Exception(__('This is an invalid amount for partial authorization.')); } $payment->setAmount($amount); $request = $this->_buildRequest($payment); $result = $this->_postRequest($request); $this->_processPartialAuthorizationResponse($result, $payment); switch ($requestType) { case self::REQUEST_TYPE_AUTH_ONLY: $newTransactionType = \Magento\Sales\Model\Order\Payment\Transaction::TYPE_AUTH; break; case self::REQUEST_TYPE_AUTH_CAPTURE: $newTransactionType = \Magento\Sales\Model\Order\Payment\Transaction::TYPE_CAPTURE; break; } foreach ($this->getCardsStorage()->getCards() as $card) { $this->_addTransaction($payment, $card->getLastTransId(), $newTransactionType, array('is_transaction_closed' => 0), array($this->_realTransactionIdKey => $card->getLastTransId()), $this->_authorizenetData->getTransactionMessage($payment, $requestType, $card->getLastTransId(), $card, $card->getProcessedAmount())); if ($requestType == self::REQUEST_TYPE_AUTH_CAPTURE) { $card->setCapturedAmount($card->getProcessedAmount()); $this->getCardsStorage()->updateCard($card); } } $this->_session->setData($this->_partialAuthorizationChecksumSessionKey, null); return $this; }
/** * Drop validation state model * * @return void */ protected function _resetValidationState() { $this->_centinelSession->setData(array()); $this->_validationState = false; }