• Attila Kiss's avatar
    [PW-2499] Fix codesniffer warnings and errors and prepare Release 6.1.2 (#737) · 5dfbe4d2
    Attila Kiss authored
    * Update phpcs to validate PSR2 rules
    
    * Fix PSR2 phpcs errors with phpcbf
    
    * Fix phpcs errors with phpcbf
    
    * Fix PSR2 phpcs errors
    
    * Reapply fix for boleto lastname key
    
    * Fix Api folder
    
    * Fix phpcs warning
    
    * Fix phpcs warning
    
    * Remove unused var
    
    * Version bump 6.1.2
    
    * Fix MagentoStandard phpcs warnings
    
    * Part of fixing the code sniffer errors
    
    * Part of fixing the code sniffer errors
    
    * Fix Magento Marketplace codesniffing warnings
    
    * Fix some code sniffer errors with phpcbf
    
    * Autoformat PSR12
    
    * Fix the path string with ::class
    
    * Fix empty spaces warnings
    
    * Fix Magento marketplace codesniffing warnings
    
    * Fix Magento marketplace codesniffing warnings
    
    * Set arguments defaults values at the end of the argument list
    
    * Code sniffer fixes
    
    * Fix Magento marketplace codesniffing warnings
    
    * remove empty return statement
    
    * Fix Static method cannot be intercepted error
    
    * Fix eror: Possible useless method overriding detected
    
    * Remove private const since it is only supported since php 7.1
    
    * Fix wrong class paths
    
    * Fix sonarcloud bugs
    
    table th element should have scope attribute when possible
    
    * Fix codesmells
    
    * Fix unit test
    
    * Remove ISSUE_TEMPLATE.md
    
    * fix wrong function call for formatStreet()
    
    * Add removed _prepareLayout() function back
    
    * Update Model/Cron.php
    Co-authored-by: default avatarÁngel Campos <angel.campos@adyen.com>
    
    * Update Model/Cron.php
    Co-authored-by: default avatarÁngel Campos <angel.campos@adyen.com>
    
    * Fix request's paymentMethod field
    Co-authored-by: default avataralexandros <alexandros.moraitis@adyen.com>
    Co-authored-by: default avatarÁngel Campos <angel.campos@adyen.com>
    Unverified
    5dfbe4d2
AdyenCcDataAssignObserver.php 3.37 KB
<?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>
 */

namespace Adyen\Payment\Observer;

use Magento\Framework\Event\Observer;
use Magento\Payment\Observer\AbstractDataAssignObserver;
use Magento\Quote\Api\Data\PaymentInterface;

class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
{
    const CC_TYPE = 'cc_type';
    const NUMBER_OF_INSTALLMENTS = 'number_of_installments';
    const STORE_CC = 'store_cc';
    const ENCRYPTED_CREDIT_CARD_NUMBER = 'number';
    const ENCRYPTED_SECURITY_CODE = 'cvc';
    const ENCRYPTED_EXPIRY_MONTH = 'expiryMonth';
    const ENCRYPTED_EXPIRY_YEAR = 'expiryYear';
    const HOLDER_NAME = 'holderName';
    const VARIANT = 'variant';
    const JAVA_ENABLED = 'java_enabled';
    const SCREEN_COLOR_DEPTH = 'screen_color_depth';
    const SCREEN_WIDTH = 'screen_width';
    const SCREEN_HEIGHT = 'screen_height';
    const TIMEZONE_OFFSET = 'timezone_offset';
    const LANGUAGE = 'language';
    const GUEST_EMAIL = 'guestEmail';
    const COMBO_CARD_TYPE = 'combo_card_type';

    /**
     * @var array
     */
    protected $additionalInformationList = [
        self::CC_TYPE,
        self::NUMBER_OF_INSTALLMENTS,
        self::STORE_CC,
        self::ENCRYPTED_CREDIT_CARD_NUMBER,
        self::ENCRYPTED_SECURITY_CODE,
        self::ENCRYPTED_EXPIRY_MONTH,
        self::ENCRYPTED_EXPIRY_YEAR,
        self::HOLDER_NAME,
        self::VARIANT,
        self::JAVA_ENABLED,
        self::SCREEN_COLOR_DEPTH,
        self::SCREEN_WIDTH,
        self::SCREEN_HEIGHT,
        self::TIMEZONE_OFFSET,
        self::LANGUAGE,
        self::GUEST_EMAIL,
        self::COMBO_CARD_TYPE
    ];

    /**
     * @param Observer $observer
     * @return void
     */
    public function execute(Observer $observer)
    {
        $data = $this->readDataArgument($observer);

        $additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA);
        if (!is_array($additionalData)) {
            return;
        }

        $paymentInfo = $this->readPaymentModelArgument($observer);

        // set ccType
        if (!empty($additionalData['cc_type'])) {
            $paymentInfo->setCcType($additionalData['cc_type']);
        }

        foreach ($this->additionalInformationList as $additionalInformationKey) {
            if (isset($additionalData[$additionalInformationKey])) {
                $paymentInfo->setAdditionalInformation(
                    $additionalInformationKey,
                    $additionalData[$additionalInformationKey]
                );
            }
        }
    }
}