From 07ed472f684e1e530b250a3c4b8bbc329c9d7f34 Mon Sep 17 00:00:00 2001 From: mustapayev Date: Sat, 16 Nov 2024 17:15:50 +0100 Subject: [PATCH] fixes after merge --- .../RequestDataMapper/AkbankPosRequestDataMapper.php | 8 ++++++-- .../RequestDataMapper/ToslaPosRequestDataMapper.php | 2 +- .../RequestDataMapper/ToslaPosRequestDataMapperTest.php | 5 ++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php index 23b47820..3458ad17 100644 --- a/src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/AkbankPosRequestDataMapper.php @@ -353,13 +353,17 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s */ public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array { - $dateTime = $requestData['requestDateTime'] ?? $this->createDateTime(); + if (isset($requestData['requestDateTime'])) { + $dateTime = $requestData['requestDateTime']; + } else { + $dateTime = $this->valueFormatter->formatDateTime($this->createDateTime(), 'requestDateTime'); + } return $requestData + $this->getRequestAccountData($posAccount) + [ 'version' => self::API_VERSION, - 'requestDateTime' => $this->valueFormatter->formatDateTime($dateTime, 'requestDateTime'), + 'requestDateTime' => $dateTime, 'randomNumber' => $this->crypt->generateRandomString(), ]; } diff --git a/src/DataMapper/RequestDataMapper/ToslaPosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/ToslaPosRequestDataMapper.php index fceb4f18..6650c07e 100644 --- a/src/DataMapper/RequestDataMapper/ToslaPosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/ToslaPosRequestDataMapper.php @@ -175,7 +175,7 @@ public function createCustomQueryRequestData(AbstractPosAccount $posAccount, arr { $requestData += $this->getRequestAccountData($posAccount) + [ 'rnd' => $this->crypt->generateRandomString(), - 'timeSpan' => $this->newTimeSpan(), + 'timeSpan' => $this->valueFormatter->formatDateTime($this->newTimeSpan(), 'timeSpan'), ]; if (!isset($requestData['hash'])) { diff --git a/tests/Unit/DataMapper/RequestDataMapper/ToslaPosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/ToslaPosRequestDataMapperTest.php index c9bb8573..9586ef8a 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/ToslaPosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/ToslaPosRequestDataMapperTest.php @@ -264,7 +264,7 @@ public static function createCustomQueryRequestDataDataProvider(): \Generator 'clientId' => '1000000494', 'hash' => '12fsdfdsfsfs', 'rnd' => 'rndsfldfls', - 'timeSpan' => '20241103144302', + 'timeSpan' => new \DateTimeImmutable('2024-11-03 14:43:02'), ], ]; @@ -275,7 +275,6 @@ public static function createCustomQueryRequestDataDataProvider(): \Generator 'clientId' => '1000000494xx', 'hash' => '12fsdfdsfsfsxxx', 'rnd' => 'rndsfldfls', - 'timeSpan' => '20241103144302', ], 'expected' => [ 'apiUser' => 'POS_ENT_Test_001xxx', @@ -283,7 +282,7 @@ public static function createCustomQueryRequestDataDataProvider(): \Generator 'clientId' => '1000000494xx', 'hash' => '12fsdfdsfsfsxxx', 'rnd' => 'rndsfldfls', - 'timeSpan' => '20241103144302', + 'timeSpan' => new \DateTimeImmutable('2024-11-03 14:43:02'), ], ]; }