Skip to content

Commit

Permalink
add cc data
Browse files Browse the repository at this point in the history
  • Loading branch information
Usik2203 committed Jun 21, 2020
1 parent d29468d commit e798f75
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
39 changes: 39 additions & 0 deletions app/code/Magento/PaypalGraphQl/Observer/PayflowProSetCcData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\PaypalGraphQl\Observer;

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

/**
* Class PayflowProSetCcData set CcData to quote payment
*/
class PayflowProSetCcData extends AbstractDataAssignObserver
{
/**
* Set CcData
*
* @param Observer $observer
*/
public function execute(Observer $observer)
{
$dataObject = $this->readDataArgument($observer);
$additionalData = $dataObject->getData(PaymentInterface::KEY_ADDITIONAL_DATA);

if (!isset($additionalData['cc_details'])) {
return;
}

$paymentModel = $this->readPaymentModelArgument($observer);
foreach ($additionalData['cc_details'] as $ccKey => $ccValue) {
$paymentModel->setData($ccKey, $ccValue);
}
}
}
3 changes: 3 additions & 0 deletions app/code/Magento/PaypalGraphQl/etc/graphql/events.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
<event name="payment_method_assign_data_payflow_advanced">
<observer name="payflow_advanced_data_assigner" instance="Magento\PaypalGraphQl\Observer\PayflowLinkSetAdditionalData"/>
</event>
<event name="payment_method_assign_data_payflowpro">
<observer name="payflowpro_cc_data_assigner" instance="Magento\PaypalGraphQl\Observer\PayflowProSetCcData" />
</event>
</config>

0 comments on commit e798f75

Please sign in to comment.