Skip to content

Commit

Permalink
use oxNewService
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolorenz committed Sep 20, 2024
1 parent 4648946 commit 50a98dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/Controller/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Application\Controller\PaymentController;
use OxidSolutionCatalysts\Adyen\Model\Payment;
use OxidSolutionCatalysts\Adyen\Service\OxNewService;
use OxidSolutionCatalysts\Adyen\Service\TranslationMapper;
use OxidSolutionCatalysts\Adyen\Service\OrderReturnService;
use OxidSolutionCatalysts\Adyen\Traits\ServiceContainer;
Expand Down Expand Up @@ -61,7 +62,8 @@ public function execute()
/** @var Payment $payment */
$payment = $this->getPayment();
if ($payment->isAdyenCreditCardPayment()) {
$paymentController = oxNew(PaymentController::class);
$oxNewService = $this->getServiceFromContainer(OxNewService::class);
$paymentController = $oxNewService->oxNew(PaymentController::class);

if ($paymentController->validatePayment() !== "order") {
Registry::getUtils()->redirect(Registry::getConfig()->getShopHomeUrl() . 'cl=payment');
Expand Down
12 changes: 8 additions & 4 deletions src/Core/Webhook/Handler/WebhookHandlerBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use OxidSolutionCatalysts\Adyen\Model\AdyenHistoryList;
use OxidSolutionCatalysts\Adyen\Model\Order as AdyenModel;
use OxidSolutionCatalysts\Adyen\Service\Context;
use OxidSolutionCatalysts\Adyen\Service\OxNewService;
use OxidSolutionCatalysts\Adyen\Traits\ServiceContainer;
use Psr\Log\LoggerInterface;

Expand All @@ -40,10 +41,12 @@ public function __construct(
?AdyenHistoryList $adyenHistoryList = null,
?Context $context = null
) {
$oxNewService = $this->getServiceFromContainer(OxNewService::class);

// whether getting mock objects from unit test or new objects for production
$this->payment = $payment ?? oxNew(Payment::class);
$this->order = $order ?? oxNew(Order::class);
$this->adyenHistoryList = $adyenHistoryList ?? oxNew(AdyenHistoryList::class);
$this->payment = $payment ?? $oxNewService->oxNew(Payment::class);
$this->order = $order ?? $oxNewService->oxNew(Order::class);
$this->adyenHistoryList = $adyenHistoryList ?? $oxNewService->oxNew(AdyenHistoryList::class);
$this->context = $context ?? $this->getServiceFromContainer(Context::class);
}

Expand Down Expand Up @@ -143,7 +146,8 @@ protected function setHistoryEntry(
string $action
): void {
try {
$adyenHistory = oxNew(AdyenHistory::class);
$oxNewService = $this->getServiceFromContainer(OxNewService::class);
$adyenHistory = $oxNewService->oxNew(AdyenHistory::class);
$adyenHistory->setOrderId($orderId);
$adyenHistory->setShopId($shopId);
$adyenHistory->setPrice($amount);
Expand Down

0 comments on commit 50a98dc

Please sign in to comment.