We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Validate3d.php 3.54 KB
Newer Older
1
<?php
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/**
 *                       ######
 *                       ######
 * ############    ####( ######  #####. ######  ############   ############
 * #############  #####( ######  #####. ######  #############  #############
 *        ######  #####( ######  #####. ######  #####  ######  #####  ######
 * ###### ######  #####( ######  #####. ######  #####  #####   #####  ######
 * ###### ######  #####( ######  #####. ######  #####          #####  ######
 * #############  #############  #############  #############  #####  ######
 *  ############   ############  #############   ############  #####  ######
 *                                      ######
 *                               #############
 *                               ############
 *
 * Adyen Payment module (https://www.adyen.com/)
 *
 * Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
 * See LICENSE.txt for license details.
 *
 * Author: Adyen <magento@adyen.com>
 */

rikterbeek's avatar
rikterbeek committed
24
namespace Adyen\Payment\Block\Redirect;
25 26 27 28

class Validate3d extends \Magento\Payment\Block\Form
{

29 30 31
    /**
     * @var \Magento\Sales\Model\OrderFactory
     */
32
    protected $_orderFactory;
33

34 35 36 37 38
    /**
     * @var \Magento\Checkout\Model\Session
     */
    protected $_checkoutSession;

39 40 41
    /**
     * @var \Magento\Checkout\Model\Order
     */
42
    protected $_order;
43 44 45 46 47
    
    /**
     * @var \Magento\Framework\App\RequestInterface
     */
    protected $_request;
48 49

    /**
50 51
     * Validate3d constructor.
     *
52
     * @param \Magento\Framework\View\Element\Template\Context $context
53
     * @param array $data
54 55
     * @param \Magento\Sales\Model\OrderFactory $orderFactory
     * @param \Magento\Checkout\Model\Session $checkoutSession
56 57 58 59 60
     */
    public function __construct(
        \Magento\Framework\View\Element\Template\Context $context,
        array $data = [],
        \Magento\Sales\Model\OrderFactory $orderFactory,
61
        \Magento\Checkout\Model\Session $checkoutSession
62
    ) {
63 64
        $this->_orderFactory = $orderFactory;
        $this->_checkoutSession = $checkoutSession;
65
        $this->_request = $context->getRequest();
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
        parent::__construct($context, $data);
        $this->_getOrder();
    }

    /**
     * Get order object
     *
     * @return \Magento\Sales\Model\Order
     */
    protected function _getOrder()
    {
        if (!$this->_order) {
            $incrementId = $this->_getCheckout()->getLastRealOrderId();
            $this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
        }
        return $this->_order;
    }

    /**
     * Get frontend checkout session object
     *
     * @return \Magento\Checkout\Model\Session
     */
    protected function _getCheckout()
    {
        return $this->_checkoutSession;
    }

94 95 96
    /**
     * @return mixed
     */
97 98 99 100 101
    public function getIssuerUrl()
    {
        return $this->_order->getPayment()->getAdditionalInformation('issuerUrl');
    }

102 103 104
    /**
     * @return mixed
     */
105 106 107 108 109
    public function getPaReq()
    {
        return $this->_order->getPayment()->getAdditionalInformation('paRequest');
    }

110 111 112
    /**
     * @return mixed
     */
113 114 115 116 117
    public function getMd()
    {
        return $this->_order->getPayment()->getAdditionalInformation('md');
    }

118 119 120
    /**
     * @return string
     */
121 122
    public function getTermUrl()
    {
123 124
        return $this->getUrl('adyen/process/validate3d',
            ['_secure' => $this->_getRequest()->isSecure()]);
125 126
    }

127 128 129 130 131 132 133 134 135
    /**
     * Retrieve request object
     *
     * @return \Magento\Framework\App\RequestInterface
     */
    protected function _getRequest()
    {
        return $this->_request;
    }
136

137
}