From d740c95784a9bc057ac2859aaa219673d0f08e23 Mon Sep 17 00:00:00 2001 From: Nuryagdy Mustapayev Date: Sat, 17 Aug 2024 11:50:30 +0200 Subject: [PATCH] styling - run rector --- .../GarantiPosResponseDataMapper.php | 5 ++++ .../PayFlexV4PosResponseDataMapper.php | 1 + src/Gateways/AbstractGateway.php | 1 + .../GarantiPosResponseDataMapperTest.php | 2 ++ .../InterPosResponseDataMapperTest.php | 1 + .../VakifKatilimPosResponseDataMapperTest.php | 23 ++++++++++++------- 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php index 62a89917..556873a5 100644 --- a/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php @@ -638,6 +638,7 @@ private function mapHistoryOrderStatus(string $txStatus, ?string $txType): ?stri if (null === $txType) { return null; } + // txStatus possible values: // Basarili // Basarisiz @@ -648,19 +649,23 @@ private function mapHistoryOrderStatus(string $txStatus, ?string $txType): ?stri if (PosInterface::TX_TYPE_CANCEL === $txType) { return PosInterface::PAYMENT_STATUS_CANCELED; } + if (PosInterface::TX_TYPE_REFUND === $txType) { // todo how can we decide if order is partially or fully refunded? return PosInterface::PAYMENT_STATUS_FULLY_REFUNDED; } + if (PosInterface::TX_TYPE_PAY_AUTH === $txType || PosInterface::TX_TYPE_PAY_POST_AUTH === $txType) { return PosInterface::PAYMENT_STATUS_PAYMENT_COMPLETED; } + if (PosInterface::TX_TYPE_PAY_PRE_AUTH === $txType) { return PosInterface::PAYMENT_STATUS_PRE_AUTH_COMPLETED; } return null; } + if ('Iptal' === $txStatus) { return null; } diff --git a/src/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapper.php index bd72e345..fc36f6e2 100644 --- a/src/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapper.php @@ -213,6 +213,7 @@ public function mapPaymentResponse(array $rawPaymentResponseData, string $txType if (\strlen($txTime) === 10) { // ziraat is sending host date without year $txTime = date('Y').$txTime; } + $commonResponse['transaction_time'] = new \DateTimeImmutable($txTime); $commonResponse['auth_code'] = $rawPaymentResponseData['AuthCode']; $commonResponse['ref_ret_num'] = $rawPaymentResponseData['TransactionId']; diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index 3d4fc245..32c44c0f 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -314,6 +314,7 @@ public function refund(array $order): PosInterface if (isset($order['order_amount']) && $order['amount'] < $order['order_amount']) { $txType = PosInterface::TX_TYPE_REFUND_PARTIAL; } + $requestData = $this->requestDataMapper->createRefundRequestData($this->account, $order, $txType); $event = new RequestDataPreparedEvent( diff --git a/tests/Unit/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapperTest.php index d33877b4..758c58ab 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapperTest.php @@ -17,6 +17,7 @@ /** * @covers \Mews\Pos\DataMapper\ResponseDataMapper\GarantiPosResponseDataMapper + * @covers \Mews\Pos\DataMapper\ResponseDataMapper\AbstractResponseDataMapper */ class GarantiPosResponseDataMapperTest extends TestCase { @@ -1789,6 +1790,7 @@ public static function historyTestDataProvider(): \Generator new \DateTimeZone($item['transaction_time']['timezone']) ); } + if (null !== $item['capture_time']) { $item['capture_time'] = new \DateTimeImmutable( $item['capture_time']['date'], diff --git a/tests/Unit/DataMapper/ResponseDataMapper/InterPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/InterPosResponseDataMapperTest.php index e0e41ea2..e5b66544 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/InterPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/InterPosResponseDataMapperTest.php @@ -96,6 +96,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD } else { $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); } + unset($actualData['transaction_time'], $expectedData['transaction_time']); $this->assertArrayHasKey('3d_all', $actualData); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php index d8a2a945..e748dff6 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php @@ -17,6 +17,7 @@ /** * @covers \Mews\Pos\DataMapper\ResponseDataMapper\VakifKatilimPosResponseDataMapper + * @covers \Mews\Pos\DataMapper\ResponseDataMapper\AbstractResponseDataMapper */ class VakifKatilimPosResponseDataMapperTest extends TestCase { @@ -220,16 +221,22 @@ public function testMapHistoryResponseWithALotOfTxs(): void $actualData = $this->responseDataMapper->mapHistoryResponse(json_decode($responseData, true)); $this->assertCount(31, $actualData['transactions']); + if (count($actualData['transactions']) <= 1) { + return; + } - if (count($actualData['transactions']) > 1 - && null !== $actualData['transactions'][0]['transaction_time'] - && null !== $actualData['transactions'][1]['transaction_time'] - ) { - $this->assertGreaterThan( - $actualData['transactions'][0]['transaction_time'], - $actualData['transactions'][1]['transaction_time'], - ); + if (null === $actualData['transactions'][0]['transaction_time']) { + return; + } + + if (null === $actualData['transactions'][1]['transaction_time']) { + return; } + + $this->assertGreaterThan( + $actualData['transactions'][0]['transaction_time'], + $actualData['transactions'][1]['transaction_time'], + ); }