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

VaultDataBuilder.php 2.09 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 23 24 25 26 27 28 29
<?php
/**
 *                       ######
 *                       ######
 * ############    ####( ######  #####. ######  ############   ############
 * #############  #####( ######  #####. ######  #############  #############
 *        ######  #####( ######  #####. ######  #####  ######  #####  ######
 * ###### ######  #####( ######  #####. ######  #####  #####   #####  ######
 * ###### ######  #####( ######  #####. ######  #####          #####  ######
 * #############  #############  #############  #############  #####  ######
 *  ############   ############  #############   ############  #####  ######
 *                                      ######
 *                               #############
 *                               ############
 *
 * Adyen Payment module (https://www.adyen.com/)
 *
 * Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
 * See LICENSE.txt for license details.
 *
 * Author: Adyen <magento@adyen.com>
 */

namespace Adyen\Payment\Gateway\Request;

use Magento\Payment\Gateway\Request\BuilderInterface;

class VaultDataBuilder implements BuilderInterface
{
attilak's avatar
[WIP]  
attilak committed
30 31 32 33
    /**
     * @var \Adyen\Payment\Helper\Requests
     */
    private $adyenRequestsHelper;
34 35

    /**
attilak's avatar
[WIP]  
attilak committed
36 37 38
     * VaultDataBuilder constructor.
     *
     * @param \Adyen\Payment\Helper\Requests $adyenRequestsHelper
39
     */
attilak's avatar
[WIP]  
attilak committed
40 41 42 43
    public function __construct(\Adyen\Payment\Helper\Requests $adyenRequestsHelper)
    {
        $this->adyenRequestsHelper = $adyenRequestsHelper;
    }
44 45 46 47 48 49 50 51

    /**
     * @param array $buildSubject
     * @return array
     */
    public function build(array $buildSubject)
    {
        // vault is enabled and shopper provided consent to store card this logic is triggered
attilak's avatar
[WIP]  
attilak committed
52 53 54 55
        /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
        $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
        $payment = $paymentDataObject->getPayment();
        $additionalInformation = $payment->getAdditionalInformation();
56

57 58 59
        $request['body'] = $this->adyenRequestsHelper->buildVaultData([], $additionalInformation);

        return $request;
60
    }
attilak's avatar
[WIP]  
attilak committed
61
}