Skip to content

Commit

Permalink
Direct fix
Browse files Browse the repository at this point in the history
  • Loading branch information
krzGablo committed Jan 22, 2024
1 parent b1a9899 commit c88d1ec
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Controller/tpay/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ private function prepareTransaction($orderId, array $additionalPaymentInformatio
}
}

$data = $this->transaction->originApiFieldCorrect($data);
$data = $this->transaction->translateGroupToChannel($data, $this->tpay->redirectToChannel());

if (isset($data['channel']) && $data['channel']) {
return $this->transaction->createWithInstantRedirection($data);
}
Expand Down
28 changes: 28 additions & 0 deletions Model/ApiFacade/Transaction/TransactionApiFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,34 @@ public function channels(): array
return $channels;
}

public function translateGroupToChannel(array $data, bool $redirectToChannel): array
{
if ($redirectToChannel && $this->useOpenApi && $data['group'] && !$data['channel']) {
foreach ($this->openApi->channels() as $channel) {
$group = $channel->groups[0];
if ($group['id'] == $data['group']) {
$data['channel'] = $channel->id;
$data['group'] = null;

return $data;
}
}
}

return $data;
}

public function originApiFieldCorrect(array $data): array
{
if (!$this->isOpenApiUse() && (int) $data['group'] != TransactionOriginApi::BLIK_CHANNEL) {
unset($data['channel']);
unset($data['currency']);
unset($data['language']);
}

return $data;
}

private function getCurrentApi()
{
return $this->useOpenApi ? $this->openApi : $this->originApi;
Expand Down
2 changes: 1 addition & 1 deletion Model/Tpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function onlyOnlineChannels(): bool

public function redirectToChannel(): bool
{
return true;
return (bool) $this->getConfigData('general_settings/redirect_directly_to_channel');
}

public function setTitle(string $title): void
Expand Down

0 comments on commit c88d1ec

Please sign in to comment.