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

AdyenHppConfigProvider.php 3.04 KB
Newer Older
1 2
<?php
/**
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 *                       ######
 *                       ######
 * ############    ####( ######  #####. ######  ############   ############
 * #############  #####( ######  #####. ######  #############  #############
 *        ######  #####( ######  #####. ######  #####  ######  #####  ######
 * ###### ######  #####( ######  #####. ######  #####  #####   #####  ######
 * ###### ######  #####( ######  #####. ######  #####          #####  ######
 * #############  #############  #############  #############  #####  ######
 *  ############   ############  #############   ############  #####  ######
 *                                      ######
 *                               #############
 *                               ############
 *
 * 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>
22
 */
23

24
namespace Adyen\Payment\Model\Ui;
25 26 27

use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Payment\Helper\Data as PaymentHelper;
28
use Magento\Directory\Helper\Data;
29 30 31 32

class AdyenHppConfigProvider implements ConfigProviderInterface
{

33 34
    const CODE = 'adyen_hpp';

35 36 37 38 39 40 41 42 43 44
    /**
     * @var PaymentHelper
     */
    protected $_paymentHelper;

    /**
     * @var \Adyen\Payment\Helper\Data
     */
    protected $_adyenHelper;

45
    /**
46 47 48
     * Request object
     *
     * @var \Magento\Framework\App\RequestInterface
49
     */
50
    protected $_request;
51 52

    /**
53
     * @var \Magento\Framework\UrlInterface
54
     */
55
    protected $_urlBuilder;
56 57

    /**
58 59
     * AdyenHppConfigProvider constructor.
     *
60
     * @param PaymentHelper $paymentHelper
61
     * @param \Adyen\Payment\Helper\Data $adyenHelper
62 63
     */
    public function __construct(
64
        PaymentHelper $paymentHelper,
65 66 67
        \Adyen\Payment\Helper\Data $adyenHelper,
        \Magento\Framework\App\RequestInterface $request,
        \Magento\Framework\UrlInterface $urlBuilder
68
    ) {
69 70
        $this->_paymentHelper = $paymentHelper;
        $this->_adyenHelper = $adyenHelper;
71 72
        $this->_request = $request;
        $this->_urlBuilder = $urlBuilder;
73 74
    }

75
    /**
76 77
     * Set configuration for AdyenHPP payemnt method
     *
78 79
     * @return array
     */
80 81
    public function getConfig()
    {
82
        // set to active
83 84
        $config = [
            'payment' => [
85 86 87 88
                self::CODE => [
                    'isActive' => true,
                    'redirectUrl' => $this->_urlBuilder->getUrl(
                        'adyen/process/redirect', ['_secure' => $this->_getRequest()->isSecure()])
89 90 91
                ]
            ]
        ];
92

93 94 95 96
        $paymentMethodSelectionOnAdyen =
            $this->_adyenHelper->getAdyenHppConfigDataFlag('payment_selection_on_adyen');
        $config['payment'] ['adyenHpp']['isPaymentMethodSelectionOnAdyen'] = $paymentMethodSelectionOnAdyen;

97 98
        return $config;
    }
99 100 101 102 103 104 105 106 107 108

    /**
     * Retrieve request object
     *
     * @return \Magento\Framework\App\RequestInterface
     */
    protected function _getRequest()
    {
        return $this->_request;
    }
109
}