/** * 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); }
/** * Before generate Xml * * @param \Magento\Framework\View\LayoutInterface $subject * @return array */ public function beforeGenerateXml(\Magento\Framework\View\LayoutInterface $subject) { if ($this->depersonalizeChecker->checkIfDepersonalize($subject)) { $this->customerGroupId = $this->customerSession->getCustomerGroupId(); $this->formKey = $this->session->getData(\Magento\Framework\Data\Form\FormKey::FORM_KEY); } return []; }
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()); }
/** * Before generate Xml * * @param \Magento\Framework\View\LayoutInterface $subject * @return array */ public function beforeGenerateXml(\Magento\Framework\View\LayoutInterface $subject) { if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && !$this->request->isAjax() && $subject->isCacheable()) { $this->customerGroupId = $this->customerSession->getCustomerGroupId(); $this->formKey = $this->session->getData(\Magento\Framework\Data\Form\FormKey::FORM_KEY); } return array(); }
/** * Return validation state model * * @param string $cardType * @return \Magento\Centinel\Model\AbstractState */ protected function _getValidationState($cardType = null) { $type = $cardType ? $cardType : $this->_centinelSession->getData('card_type'); if (!$this->_validationState && $type) { $model = $this->_stateFactory->createState($type); if (!$model) { return false; } $model->setDataStorage($this->_centinelSession); $this->_validationState = $model; } return $this->_validationState; }
/** * Get captcha word * * @return string */ public function getWord() { $sessionData = $this->_session->getData($this->_getFormIdKey(self::SESSION_WORD)); return time() < $sessionData['expires'] ? $sessionData['data'] : null; }
/** * @return bool */ public function isPresent() { return (bool) $this->session->getData(self::FORM_KEY); }
/** * 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; }