-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PW-7169] Create order with PBL from rest api (#1762)
* Initiate PBL from rest api * Refactor naming * Fix code smells * Code smell fixes * Resolve suggestions Co-authored-by: system-mr <systemmr@adyen.com>
- Loading branch information
1 parent
55960b7
commit df47757
Showing
5 changed files
with
87 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment module (https://www.adyen.com/) | ||
* | ||
* Copyright (c) 2022 Adyen NV (https://www.adyen.com/) | ||
* See LICENSE.txt for license details. | ||
* | ||
* Author: Adyen <magento@adyen.com> | ||
*/ | ||
|
||
namespace Adyen\Payment\Observer; | ||
|
||
use Adyen\Service\Validator\DataArrayValidator; | ||
use Magento\Framework\Event\Observer; | ||
use Magento\Payment\Observer\AbstractDataAssignObserver; | ||
use Magento\Quote\Api\Data\PaymentInterface; | ||
|
||
class AdyenPayByLinkDataAssignObserver extends AbstractDataAssignObserver | ||
{ | ||
const PBL_EXPIRY_DATE = 'adyen_pbl_expires_at'; | ||
|
||
/** | ||
* Approved root level keys from additional data array | ||
* | ||
* @var array | ||
*/ | ||
private static $approvedAdditionalDataKeys = [ | ||
self::PBL_EXPIRY_DATE | ||
]; | ||
|
||
/** | ||
* @param Observer $observer | ||
* @return void | ||
*/ | ||
public function execute(Observer $observer) | ||
{ | ||
// Get request fields | ||
$data = $this->readDataArgument($observer); | ||
$paymentInfo = $this->readPaymentModelArgument($observer); | ||
|
||
// Get additional data array | ||
$additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA); | ||
if (!is_array($additionalData)) { | ||
return; | ||
} | ||
|
||
// Get a validated additional data array | ||
$additionalData = DataArrayValidator::getArrayOnlyWithApprovedKeys( | ||
$additionalData, | ||
self::$approvedAdditionalDataKeys | ||
); | ||
|
||
// Set additional data in the payment | ||
foreach ($additionalData as $key => $data) { | ||
$paymentInfo->setAdditionalInformation($key, $data); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters