Skip to content

Commit

Permalink
Blik fix
Browse files Browse the repository at this point in the history
  • Loading branch information
krzGablo committed Jan 17, 2024
1 parent 7e9cd37 commit fcb2ff1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions Controller/tpay/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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');
Expand Down Expand Up @@ -135,7 +139,7 @@ private function prepareTransaction($orderId, array $additionalPaymentInformatio
}
}

if ($data['channel']) {
if (isset($data['channel']) && $data['channel']) {
return $this->transaction->createWithInstantRedirection($data);
}

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Model/ApiFacade/OpenApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fcb2ff1

Please sign in to comment.