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

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

24 25 26 27 28 29 30
namespace Adyen\Payment\Gateway\Request;

use Magento\Payment\Gateway\Request\BuilderInterface;

class RecurringDataBuilder implements BuilderInterface
{
    /**
attilak's avatar
[WIP]  
attilak committed
31
     * @var \Magento\Framework\App\State
32
     */
attilak's avatar
[WIP]  
attilak committed
33
    private $appState;
34 35

    /**
attilak's avatar
[WIP]  
attilak committed
36
     * @var \Adyen\Payment\Helper\Requests
37
     */
attilak's avatar
[WIP]  
attilak committed
38
    private $adyenRequestsHelper;
39 40 41 42 43

    /**
     * RecurringDataBuilder constructor.
     *
     * @param \Magento\Framework\Model\Context $context
attilak's avatar
[WIP]  
attilak committed
44
     * @param \Adyen\Payment\Helper\Requests $adyenRequestsHelper
45 46
     */
    public function __construct(
attilak's avatar
[WIP]  
attilak committed
47 48
        \Magento\Framework\Model\Context $context,
        \Adyen\Payment\Helper\Requests $adyenRequestsHelper
49 50
    ) {
        $this->appState = $context->getAppState();
attilak's avatar
[WIP]  
attilak committed
51
        $this->adyenRequestsHelper = $adyenRequestsHelper;
52 53 54 55 56
    }

    /**
     * @param array $buildSubject
     * @return array
57
     * @throws \Magento\Framework\Exception\LocalizedException
58 59 60
     */
    public function build(array $buildSubject)
    {
attilak's avatar
[WIP]  
attilak committed
61 62 63 64 65
        /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
        $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
        $payment = $paymentDataObject->getPayment();
        $storeId = $payment->getOrder()->getStoreId();
        $areaCode = $this->appState->getAreaCode();
66
        $additionalInformation = $payment->getAdditionalInformation();
67 68 69 70 71 72
        $request['body'] = $this->adyenRequestsHelper->buildRecurringData(
            $areaCode,
            $storeId,
            $additionalInformation,
            []
        );
73
        return $request;
74
    }
75
}