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 fcb2ff1 commit a8c9531
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
23 changes: 12 additions & 11 deletions Controller/tpay/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ class Create extends Action
private $cache;

public function __construct(
Context $context,
TpayInterface $tpayModel,
TpayService $tpayService,
Session $checkoutSession,
Context $context,
TpayInterface $tpayModel,
TpayService $tpayService,
Session $checkoutSession,
CacheInterface $cache
) {
)
{
$this->tpay = $tpayModel;
$this->tpayService = $tpayService;
$this->checkoutSession = $checkoutSession;
Expand Down Expand Up @@ -69,24 +70,24 @@ public function execute(): ResponseInterface

$this->handleOpenApiTrId($paymentData, $transaction);

$this->tpayService->addCommentToHistory($orderId, 'Transaction title '.$transaction['title']);
$this->tpayService->addCommentToHistory($orderId, 'Transaction title ' . $transaction['title']);
$transactionUrl = $transaction['url'];

if (true === $this->tpay->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)->save();

if (6 === strlen($additionalPaymentInformation['blik_code'] ?? '') && $this->tpay->checkBlikLevel0Settings()) {
if (true === $this->transaction->isOpenApiUse()) {
if (isset($transaction['payments']['errors']) && count($transaction['payments']['errors']) > 0) {
return $this->_redirect('magento2basic/tpay/error');
} else {
return $this->_redirect('magento2basic/tpay/success');
}

return $this->_redirect('magento2basic/tpay/success');
}
$result = $this->blikPay($transaction['title'], $additionalPaymentInformation['blik_code']);
$this->checkoutSession->unsQuoteId();
Expand Down Expand Up @@ -131,8 +132,8 @@ private function prepareTransaction($orderId, array $additionalPaymentInformatio
$data['channel'] = null;
$this->handleBlikData($data, $additionalPaymentInformation['blik_code']);
} else {
$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->tpay->redirectToChannel()) {
$data['direct'] = 1;
Expand Down
2 changes: 1 addition & 1 deletion Model/ApiFacade/OpenApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private function handleDataStructure(array $data): array
}

if ($data['group']) {
$paymentData['pay']['groupId' ] = $data['group'];
$paymentData['pay']['groupId'] = $data['group'];
}

if ($data['channel']) {
Expand Down

0 comments on commit a8c9531

Please sign in to comment.