-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement asynchronous POS cloud for in-person payments (#2565)
* [ECP-8912] Make Pos payments flow async (#2498) * ECP-8912/Make-POS-payments-flow-async * refactor * Make POS async * pos async * pos async * fix TypeError: Magento\Payment\Gateway\Data\PaymentDataObject::__construct(): Argument #1 ($order) must be of type Magento\Payment\Gateway\Data\OrderAdapterInterface, Magento\Sales\Model\Order\Interceptor given, called in /var/www/html/vendor/adyen/module-payment/Model/Api/AdyenPosCloud.php on line 54 and defined in /var/www/html/app/code/Magento/Payment/Gateway/Data/PaymentDataObject.php:26 * tuning backend of async * fix FE call * fixes * clean up * Refactor SubmitQuoteObserver * Refactor adyen-pos-cloud-method.js * put the correct status * Add test coverage for AdyenPosCloud & GuestAdyenPosCloud * Add test coverage for PaymentPosCloudHandlerTest * Add test coverage for SetOrderStateAfterPaymentObserverTest * Comments refactor * rename handleFaildResponse to handleFailedResponse * Terminal API does not return Authorised result code. * Update Plugin/GuestPaymentInformationResetOrderId.php * Update Plugin/PaymentInformationResetOrderId.php * Update events.xml --------- Co-authored-by: Peter Ojo <[email protected]> Co-authored-by: Can Demiralp <[email protected]> * [ECP-9064] Make asynchronous POS flow configurable (#2566) * [ECP-9064] Define new configuration field and getter for payment action * [ECP-9064] Pass payment_action config to frontend * [ECP-9064] Use POS payment action value on frontend and observers logic * [ECP-9064] Use constant definition for payment action field * [ECP-9064] Fix unit tests * [ECP-9064] Fix unit tests * [ECP-9064] Formatting * [ECP-9064] Update unit tests --------- Co-authored-by: Can Demiralp <[email protected]> * Update the tooltip and the label of the configuration field * Update unit tests --------- Co-authored-by: hossam-adyen <[email protected]> Co-authored-by: Peter Ojo <[email protected]> Co-authored-by: Can Demiralp <[email protected]> Co-authored-by: Rok Popov Ledinski <[email protected]>
- Loading branch information
1 parent
2274f78
commit cbf8bb5
Showing
27 changed files
with
832 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment module (https://www.adyen.com/) | ||
* | ||
* Copyright (c) 2024 Adyen N.V. (https://www.adyen.com/) | ||
* See LICENSE.txt for license details. | ||
* | ||
* Author: Adyen <[email protected]> | ||
*/ | ||
|
||
namespace Adyen\Payment\Api; | ||
interface AdyenPosCloudInterface | ||
{ | ||
/** | ||
* @param int $orderId | ||
* @return void | ||
*/ | ||
public function pay(int $orderId): void; | ||
} |
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,21 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment module (https://www.adyen.com/) | ||
* | ||
* Copyright (c) 2024 Adyen N.V. (https://www.adyen.com/) | ||
* See LICENSE.txt for license details. | ||
* | ||
* Author: Adyen <[email protected]> | ||
*/ | ||
|
||
namespace Adyen\Payment\Api; | ||
|
||
interface GuestAdyenPosCloudInterface | ||
{ | ||
/** | ||
* @param string $cartId | ||
* @return void | ||
*/ | ||
public function payByCart(string $cartId): void; | ||
} |
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,54 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment module (https://www.adyen.com/) | ||
* | ||
* Copyright (c) 2024 Adyen N.V. (https://www.adyen.com/) | ||
* See LICENSE.txt for license details. | ||
* | ||
* Author: Adyen <[email protected]> | ||
*/ | ||
|
||
namespace Adyen\Payment\Model\Api; | ||
|
||
use Adyen\Payment\Api\AdyenPosCloudInterface; | ||
use Adyen\Payment\Logger\AdyenLogger; | ||
use Adyen\Payment\Model\Sales\OrderRepository; | ||
use Magento\Payment\Gateway\Command\CommandPoolInterface; | ||
use Magento\Sales\Api\Data\OrderInterface; | ||
use Magento\Payment\Gateway\Data\PaymentDataObjectFactoryInterface; | ||
|
||
class AdyenPosCloud implements AdyenPosCloudInterface | ||
{ | ||
private CommandPoolInterface $commandPool; | ||
protected AdyenLogger $adyenLogger; | ||
protected OrderRepository $orderRepository; | ||
protected PaymentDataObjectFactoryInterface $paymentDataObjectFactory; | ||
|
||
public function __construct( | ||
CommandPoolInterface $commandPool, | ||
OrderRepository $orderRepository, | ||
PaymentDataObjectFactoryInterface $paymentDataObjectFactory, | ||
AdyenLogger $adyenLogger | ||
) | ||
{ | ||
$this->commandPool = $commandPool; | ||
$this->orderRepository = $orderRepository; | ||
$this->paymentDataObjectFactory = $paymentDataObjectFactory; | ||
$this->adyenLogger = $adyenLogger; | ||
} | ||
|
||
public function pay(int $orderId): void | ||
{ | ||
$order = $this->orderRepository->get($orderId); | ||
$this->execute($order); | ||
} | ||
|
||
protected function execute(OrderInterface $order): void | ||
{ | ||
$payment = $order->getPayment(); | ||
$paymentDataObject = $this->paymentDataObjectFactory->create($payment); | ||
$posCommand = $this->commandPool->get('authorize'); | ||
$posCommand->execute(['payment' => $paymentDataObject]); | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment module (https://www.adyen.com/) | ||
* | ||
* Copyright (c) 2024 Adyen N.V. (https://www.adyen.com/) | ||
* See LICENSE.txt for license details. | ||
* | ||
* Author: Adyen <[email protected]> | ||
*/ | ||
|
||
namespace Adyen\Payment\Model\Api; | ||
|
||
use Adyen\Payment\Api\GuestAdyenPosCloudInterface; | ||
use Adyen\Payment\Logger\AdyenLogger; | ||
use Adyen\Payment\Model\Sales\OrderRepository; | ||
use Magento\Payment\Gateway\Command\CommandPoolInterface; | ||
use Magento\Payment\Gateway\Data\PaymentDataObjectFactoryInterface; | ||
use Magento\Quote\Model\QuoteIdMaskFactory; | ||
|
||
|
||
class GuestAdyenPosCloud extends AdyenPosCloud implements GuestAdyenPosCloudInterface | ||
{ | ||
protected AdyenLogger $adyenLogger; | ||
protected OrderRepository $orderRepository; | ||
protected PaymentDataObjectFactoryInterface $paymentDataObjectFactory; | ||
private QuoteIdMaskFactory $quoteIdMaskFactory; | ||
|
||
public function __construct( | ||
CommandPoolInterface $commandPool, | ||
OrderRepository $orderRepository, | ||
PaymentDataObjectFactoryInterface $paymentDataObjectFactory, | ||
AdyenLogger $adyenLogger, | ||
QuoteIdMaskFactory $quoteIdMaskFactory | ||
) | ||
{ | ||
parent::__construct( | ||
$commandPool, | ||
$orderRepository, | ||
$paymentDataObjectFactory, | ||
$adyenLogger | ||
); | ||
$this->quoteIdMaskFactory = $quoteIdMaskFactory; | ||
} | ||
|
||
/** | ||
* @param string $cartId | ||
* @return void | ||
*/ | ||
public function payByCart(string $cartId): void | ||
{ | ||
$quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id'); | ||
$quoteId = $quoteIdMask->getQuoteId(); | ||
$order = $this->orderRepository->getOrderByQuoteId($quoteId); | ||
$this->execute($order); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment module (https://www.adyen.com/) | ||
* | ||
* Copyright (c) 2024 Adyen N.V. (https://www.adyen.com/) | ||
* See LICENSE.txt for license details. | ||
* | ||
* Author: Adyen <[email protected]> | ||
*/ | ||
|
||
namespace Adyen\Payment\Model\Config\Source; | ||
|
||
use Magento\Framework\Data\OptionSourceInterface; | ||
use Magento\Payment\Model\MethodInterface; | ||
|
||
class PaymentAction implements OptionSourceInterface | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
public function toOptionArray() | ||
{ | ||
return [ | ||
['value' => MethodInterface::ACTION_AUTHORIZE, 'label' => __('After payment')], | ||
['value' => MethodInterface::ACTION_ORDER, 'label' => __('Before payment')], | ||
]; | ||
} | ||
} |
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
Oops, something went wrong.