From 1bff87bbb2d5fc42880dce7312dd9dc8b3af5617 Mon Sep 17 00:00:00 2001 From: Karol Wojciechowski Date: Tue, 16 Apr 2024 15:05:37 +0200 Subject: [PATCH] fix --- Model/Resolver/CreateTransaction.php | 29 ++++++++++++++-------------- Model/TpayDataProvider.php | 4 ++-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Model/Resolver/CreateTransaction.php b/Model/Resolver/CreateTransaction.php index 3981b59..3fa0b30 100644 --- a/Model/Resolver/CreateTransaction.php +++ b/Model/Resolver/CreateTransaction.php @@ -27,15 +27,14 @@ class CreateTransaction implements ResolverInterface private StoreManagerInterface $storeManager; public function __construct( - TpayInterface $tpay, - TransactionApiFacade $transactionApiFacade, - TpayConfigInterface $tpayConfig, - Session $checkoutSession, + TpayInterface $tpay, + TransactionApiFacade $transactionApiFacade, + TpayConfigInterface $tpayConfig, + Session $checkoutSession, OrderRepositoryInterface $orderRepository, - TpayService $tpayService, - StoreManagerInterface $storeManager - ) - { + TpayService $tpayService, + StoreManagerInterface $storeManager + ) { $this->transactionApiFacade = $transactionApiFacade; $this->tpay = $tpay; $this->tpayConfig = $tpayConfig; @@ -65,13 +64,13 @@ public function resolve(Field $field, $context, ResolveInfo $info, ?array $value $order = $this->orderRepository->get($orderId); /** @var \Magento\Sales\Model\Order\Payment $payment */ $payment = $order->getPayment(); - if ($payment->getMethod() !== TpayInterface::CODE) { + if (TpayInterface::CODE !== $payment->getMethod()) { return; } $paymentData = $payment->getData(); - if ($paymentData['additional_information']['accept_tos'] !== true) { - throw new \Exception('Tpay terms of service not accepted'); + if (true !== $paymentData['additional_information']['accept_tos']) { + throw new Exception('Tpay terms of service not accepted'); } if ('PLN' !== $this->storeManager->getStore()->getCurrentCurrencyCode()) { return ['transaction' => null, 'redirectUrl' => null]; @@ -82,13 +81,13 @@ public function resolve(Field $field, $context, ResolveInfo $info, ?array $value if (isset($transaction['transactionId'])) { $paymentData['additional_information']['transaction_id'] = $transaction['transactionId']; } - $this->tpayService->addCommentToHistory($orderId, 'Transaction title ' . $transaction['title']); + $this->tpayService->addCommentToHistory($orderId, 'Transaction title '.$transaction['title']); if (true === $this->tpayConfig->redirectToChannel()) { $transactionUrl = str_replace('gtitle', 'title', $transactionUrl); } - $this->tpayService->addCommentToHistory($orderId, 'Transaction link ' . $transactionUrl); + $this->tpayService->addCommentToHistory($orderId, 'Transaction link '.$transactionUrl); $paymentData['additional_information']['transaction_url'] = $transactionUrl; $payment->setData($paymentData); $this->tpayService->saveOrderPayment($payment); @@ -103,8 +102,8 @@ private function prepareTransaction($orderId, array $additionalPaymentInformatio { $data = $this->tpay->getTpayFormData($orderId); - $data['group'] = (int)($additionalPaymentInformation['group'] ?? null); - $data['channel'] = (int)($additionalPaymentInformation['channel'] ?? null); + $data['group'] = (int) ($additionalPaymentInformation['group'] ?? null); + $data['channel'] = (int) ($additionalPaymentInformation['channel'] ?? null); if ($this->tpayConfig->redirectToChannel()) { $data['direct'] = 1; diff --git a/Model/TpayDataProvider.php b/Model/TpayDataProvider.php index 6a47c4e..837e1e1 100644 --- a/Model/TpayDataProvider.php +++ b/Model/TpayDataProvider.php @@ -12,10 +12,10 @@ class TpayDataProvider implements AdditionalDataProviderInterface public function getData(array $data): array { $code = $data['code']; - if($code === TpayInterface::CODE) { + if (TpayInterface::CODE === $code) { $data['tpay'][TpayInterface::TERMS_ACCEPT] ??= false; } + return $data['tpay']; } } -