diff --git a/Controller/tpay/Create.php b/Controller/tpay/Create.php index d006e28..9d2e992 100644 --- a/Controller/tpay/Create.php +++ b/Controller/tpay/Create.php @@ -82,7 +82,11 @@ public function execute(): ResponseInterface if (6 === strlen($additionalPaymentInformation['blik_code'] ?? '') && $this->tpay->checkBlikLevel0Settings()) { if (true === $this->transaction->isOpenApiUse()) { - return $this->_redirect('magento2basic/tpay/success'); + if (isset($transaction['payments']['errors']) && count($transaction['payments']['errors']) > 0) { + return $this->_redirect('magento2basic/tpay/error'); + } else { + return $this->_redirect('magento2basic/tpay/success'); + } } $result = $this->blikPay($transaction['title'], $additionalPaymentInformation['blik_code']); $this->checkoutSession->unsQuoteId(); @@ -93,7 +97,7 @@ public function execute(): ResponseInterface 'User has typed wrong blik code and has been redirected to transaction panel in order to finish payment' ); - return $this->_redirect($transactionUrl); + return $this->_redirect('magento2basic/tpay/error'); } return $this->_redirect('magento2basic/tpay/success'); @@ -135,7 +139,7 @@ private function prepareTransaction($orderId, array $additionalPaymentInformatio } } - if ($data['channel']) { + if (isset($data['channel']) && $data['channel']) { return $this->transaction->createWithInstantRedirection($data); } @@ -149,6 +153,11 @@ private function handleBlikData(array &$data, string $blikCode) 'blikToken' => $blikCode, ]; } + if (!$this->transaction->isOpenApiUse()) { + unset($data['channel']); + unset($data['currency']); + unset($data['language']); + } } private function handleOpenApiTrId(array &$paymentData, array $transaction) diff --git a/Model/ApiFacade/OpenApi.php b/Model/ApiFacade/OpenApi.php index 8b97662..eea6e68 100755 --- a/Model/ApiFacade/OpenApi.php +++ b/Model/ApiFacade/OpenApi.php @@ -85,11 +85,11 @@ private function handleDataStructure(array $data): array } if ($data['group']) { - $paymentData['pay'] = ['groupId' => $data['group']]; + $paymentData['pay']['groupId' ] = $data['group']; } if ($data['channel']) { - $paymentData['pay'] = ['channelId' => $data['channel']]; + $paymentData['pay']['channelId'] = $data['channel']; } return $paymentData;