Skip to content

Commit

Permalink
[project-base] order is updated in GoPay only if configuration is set…
Browse files Browse the repository at this point in the history
… (#2806)
  • Loading branch information
TomasLudvik authored Sep 21, 2023
1 parent a159284 commit ea95910
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/.env.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# define your env variables for the test environment here

DATABASE_NAME=shopsys-test

GOPAY_IS_PRODUCTION_MODE=false
GOPAY_EN_GOID=test-data
GOPAY_EN_CLIENTID=test-data
GOPAY_EN_CLIENTSECRET=test-data
GOPAY_CS_GOID=test-data
GOPAY_CS_CLIENTID=test-data
GOPAY_CS_CLIENTSECRET=test-data
6 changes: 5 additions & 1 deletion app/src/Model/GoPay/GoPayClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ public function createByLocale(string $locale): GoPayClient
*/
protected function getConfigByLocale(string $locale): array
{
if (!array_key_exists($locale, $this->config)) {
throw new GoPayNotConfiguredException();
}

$configByLocale = $this->config[$locale];
$this->config = array_merge($this->config, $configByLocale);

if ($this->config['goid'] === null) {
if ($this->config['goid'] === null || $this->config['goid'] === '') {
throw new GoPayNotConfiguredException();
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/Model/Payment/Service/PaymentServiceFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Model\Payment\Service;

use App\FrontendApi\Model\Payment\PaymentSetupCreationData;
use App\Model\GoPay\Exception\GoPayNotConfiguredException;
use App\Model\GoPay\Exception\GoPayPaymentDownloadException;
use App\Model\GoPay\GoPayFacade;
use App\Model\Order\Order;
Expand Down Expand Up @@ -98,7 +99,7 @@ public function updatePaymentTransactionsByOrder(Order $order): void
if ($update) {
$this->paymentTransactionFacade->edit($paymentTransaction->getId(), $paymentTransactionData);
}
} catch (PaymentServiceFacadeNotRegisteredException $exception) {
} catch (PaymentServiceFacadeNotRegisteredException | GoPayNotConfiguredException $exception) {
$this->logger->error($exception->getMessage());
}
}
Expand Down

0 comments on commit ea95910

Please sign in to comment.