12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- declare(strict_types=1);
- namespace Magento\AuthorizenetAcceptjs\Observer;
- use Magento\Framework\Event\Observer;
- use Magento\Payment\Observer\AbstractDataAssignObserver;
- use Magento\Quote\Api\Data\PaymentInterface;
- /**
- * Adds the payment info to the payment object
- */
- class DataAssignObserver extends AbstractDataAssignObserver
- {
- /**
- * @var array
- */
- private $additionalInformationList = [
- 'opaqueDataDescriptor',
- 'opaqueDataValue',
- 'ccLast4'
- ];
- /**
- * @inheritdoc
- */
- 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);
- foreach ($this->additionalInformationList as $additionalInformationKey) {
- if (isset($additionalData[$additionalInformationKey])) {
- $paymentInfo->setAdditionalInformation(
- $additionalInformationKey,
- $additionalData[$additionalInformationKey]
- );
- }
- }
- }
- }
|