Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Karol Wojciechowski committed Apr 16, 2024
1 parent ae1df73 commit 1bff87b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
29 changes: 14 additions & 15 deletions Model/Resolver/CreateTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand All @@ -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);
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Model/TpayDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
}

0 comments on commit 1bff87b

Please sign in to comment.