We will be off on April 7th (Monday) for public holiday in our country

  • 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
PaymentCommentHistoryHandler.php 2.39 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\Gateway\Response;

use Magento\Payment\Gateway\Response\HandlerInterface;

class PaymentCommentHistoryHandler implements HandlerInterface
{
    /**
     * @param array $handlingSubject
     * @param array $response
     * @return $this
     */
    public function handle(array $handlingSubject, array $response)
    {
        $payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);

        /** @var OrderPaymentInterface $payment */
        $payment = $payment->getPayment();

        if (isset($response['resultCode'])) {
            $responseCode = $response['resultCode'];
        } else {
            // try to get response from response key (used for modifications
            if (isset($response['response'])) {
                $responseCode = $response['response'];
            } else {
                $responseCode = "";
            }
        }

        if (isset($response['pspReference'])) {
            $pspReference = $response['pspReference'];
        } else {
            $pspReference = "";
        }

        $type = 'Adyen Result response:';
        $comment = __(
            '%1 <br /> authResult: %2 <br /> pspReference: %3 ',
            $type,
            $responseCode,
            $pspReference
        );

        if ($responseCode) {
            $payment->getOrder()->setAdyenResulturlEventCode($responseCode);
        }

        $payment->getOrder()->addStatusHistoryComment($comment);

        return $this;
    }
}