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

CheckoutPaymentCommentHistoryHandler.php 2.41 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 30
<?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 CheckoutPaymentCommentHistoryHandler implements HandlerInterface
{

31 32 33 34 35 36 37 38
    /**
     * @param array $handlingSubject
     * @param array $response
     * @return $this
     */
    public function handle(array $handlingSubject, array $response)
    {
        $payment = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($handlingSubject);
39

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

43
		$comment = __("Adyen Result response:");
44

45 46 47 48 49 50 51 52 53 54
        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 = "";
            }
        }
55

56 57 58 59 60
        if (isset($response['pspReference'])) {
            $pspReference = $response['pspReference'];
        } else {
            $pspReference = "";
        }
61

62
        if ($responseCode) {
63
			$comment .= '<br /> ' . __('authResult:') . ' ' . $responseCode;
64 65
            $payment->getOrder()->setAdyenResulturlEventCode($responseCode);
        }
66

67
        if ($pspReference) {
68
			$comment .= '<br /> ' . __('pspReference:') . ' ' . $pspReference;
69
        }
70

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

73 74
        return $this;
    }
75
}