Skip to content

Commit

Permalink
fix response data is missing in some transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
mustapayev committed Oct 27, 2024
1 parent 64cc69f commit 7929bdd
Show file tree
Hide file tree
Showing 15 changed files with 375 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public function map3DPayResponseData(array $raw3DAuthResponseData, string $txTyp
$paymentModel
);
$defaultPaymentResponse['status'] = $paymentStatus;
$defaultPaymentResponse['all'] = $raw3DAuthResponseData;

if (self::TX_APPROVED === $threeDAuthStatus) {
$threeDAuthResult['auth_code'] = $raw3DAuthResponseData['authcode'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function mapPaymentResponse(array $rawPaymentResponseData, string $txType
$result['error_message'] = $rawPaymentResponseData['ErrorMessage'];
$result['currency'] = $order['currency'];
$result['amount'] = $order['amount'];
$result['all'] = $rawPaymentResponseData;

if (self::TX_APPROVED === $status) {
$result['transaction_time'] = new \DateTimeImmutable($rawPaymentResponseData['TRXDATE'] ?? null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public function map3DPayResponseData(array $raw3DAuthResponseData, string $txTyp
'status_detail' => $this->getStatusDetail($procReturnCode),
'error_code' => (self::TX_APPROVED !== $status) ? $procReturnCode : null,
'error_message' => (self::TX_APPROVED !== $status) ? $raw3DAuthResponseData['ErrMsg'] : null,
'all' => $raw3DAuthResponseData,
];

$commonThreeDResponseData = $this->map3DCommonResponseData($raw3DAuthResponseData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ public function testMapPaymentResponse(array $order, string $txType, array $resp
}

unset($actualData['transaction_time'], $expectedData['transaction_time']);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

\ksort($expectedData);
\ksort($actualData);
$this->assertSame($expectedData, $actualData);
Expand All @@ -103,8 +108,17 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
}

unset($actualData['transaction_time'], $expectedData['transaction_time']);
unset($actualData['all']);
unset($actualData['3d_all']);

$this->assertArrayHasKey('all', $actualData);
if ([] !== $responseData) {
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}
$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
unset($actualData['all'], $actualData['3d_all']);

\ksort($expectedData);
\ksort($actualData);
$this->assertSame($expectedData, $actualData);
Expand All @@ -123,10 +137,12 @@ public function testMap3DPayResponseData(array $order, string $txType, array $re
}

unset($actualData['transaction_time'], $expectedData['transaction_time']);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

\ksort($expectedData);
\ksort($actualData);
$this->assertSame($expectedData, $actualData);
Expand All @@ -145,10 +161,12 @@ public function testMap3DHostResponseData(array $order, string $txType, array $r
}

unset($actualData['transaction_time'], $expectedData['transaction_time']);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

\ksort($expectedData);
\ksort($actualData);
$this->assertSame($expectedData, $actualData);
Expand All @@ -160,10 +178,12 @@ public function testMap3DHostResponseData(array $order, string $txType, array $r
public function testMapRefundResponse(array $responseData, array $expectedData): void
{
$actualData = $this->responseDataMapper->mapRefundResponse($responseData);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

\ksort($actualData);
\ksort($expectedData);
$this->assertSame($expectedData, $actualData);
Expand All @@ -175,10 +195,12 @@ public function testMapRefundResponse(array $responseData, array $expectedData):
public function testMapCancelResponse(array $responseData, array $expectedData): void
{
$actualData = $this->responseDataMapper->mapCancelResponse($responseData);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

\ksort($actualData);
\ksort($expectedData);
$this->assertSame($expectedData, $actualData);
Expand Down Expand Up @@ -217,7 +239,11 @@ public function testMapOrderHistoryResponse(array $responseData, array $expected
}
}

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

\ksort($expectedData);
\ksort($actualData);
$this->assertSame($expectedData, $actualData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ public function testMapPaymentResponse(array $order, string $txType, array $resp
$actualData = $this->responseDataMapper->mapPaymentResponse($responseData, $txType, $order);
$this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']);
unset($actualData['transaction_time'], $expectedData['transaction_time']);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

\ksort($expectedData);
\ksort($actualData);
$this->assertSame($expectedData, $actualData);
Expand All @@ -101,7 +106,17 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
);
$this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']);
unset($actualData['transaction_time'], $expectedData['transaction_time']);

$this->assertArrayHasKey('all', $actualData);
if ([] !== $paymentResponse) {
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}
$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
unset($actualData['all'], $actualData['3d_all']);

\ksort($expectedData);
\ksort($actualData);
$this->assertSame($expectedData, $actualData);
Expand All @@ -115,7 +130,12 @@ public function testMap3DPayResponseData(array $order, string $txType, array $re
$actualData = $this->responseDataMapper->map3DPayResponseData($responseData, $txType, $order);
$this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']);
unset($actualData['transaction_time'], $expectedData['transaction_time']);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

\ksort($expectedData);
\ksort($actualData);
$this->assertSame($expectedData, $actualData);
Expand All @@ -134,7 +154,12 @@ public function testMap3DHostResponseData(array $order, string $txType, array $r
}

unset($actualData['transaction_time'], $expectedData['transaction_time']);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

\ksort($expectedData);
\ksort($actualData);
$this->assertSame($expectedData, $actualData);
Expand Down Expand Up @@ -168,7 +193,11 @@ public function testMapStatusResponse(array $responseData, array $expectedData):
unset($actualData['refund_time'], $expectedData['refund_time']);
}

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

\ksort($expectedData);
\ksort($actualData);

Expand All @@ -181,7 +210,12 @@ public function testMapStatusResponse(array $responseData, array $expectedData):
public function testMapRefundResponse(array $responseData, array $expectedData): void
{
$actualData = $this->responseDataMapper->mapRefundResponse($responseData);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

$this->assertSame($expectedData, $actualData);
}

Expand All @@ -191,7 +225,12 @@ public function testMapRefundResponse(array $responseData, array $expectedData):
public function testMapCancelResponse(array $responseData, array $expectedData): void
{
$actualData = $this->responseDataMapper->mapCancelResponse($responseData);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

$this->assertSame($expectedData, $actualData);
}

Expand Down Expand Up @@ -223,7 +262,11 @@ public function testMapOrderHistoryResponse(array $responseData, array $expected
$this->assertCount($actualData['trans_count'], $actualData['transactions']);
}

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

\ksort($expectedData);
\ksort($actualData);
$this->assertSame($expectedData, $actualData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ public function testMapPaymentResponse(array $order, string $txType, array $resp
$actualData = $this->responseDataMapper->mapPaymentResponse($responseData, $txType, $order);
$this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']);
unset($actualData['transaction_time'], $expectedData['transaction_time']);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

\ksort($expectedData);
\ksort($actualData);
$this->assertSame($expectedData, $actualData);
Expand All @@ -101,7 +106,17 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
);
$this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']);
unset($actualData['transaction_time'], $expectedData['transaction_time']);

$this->assertArrayHasKey('all', $actualData);
if ([] !== $paymentResponse) {
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}
$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
unset($actualData['all'], $actualData['3d_all']);

\ksort($expectedData);
\ksort($actualData);
$this->assertSame($expectedData, $actualData);
Expand All @@ -126,7 +141,12 @@ public function testMap3DPayResponseData(array $order, string $txType, array $re
}

unset($actualData['transaction_time'], $expectedData['transaction_time']);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

\ksort($expectedData);
\ksort($actualData);
$this->assertSame($expectedData, $actualData);
Expand All @@ -147,7 +167,11 @@ public function testMapStatusResponse(array $responseData, array $expectedData):
unset($actualData['refund_time'], $expectedData['refund_time']);
unset($actualData['cancel_time'], $expectedData['cancel_time']);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

\ksort($expectedData);
\ksort($actualData);
$this->assertSame($expectedData, $actualData);
Expand Down Expand Up @@ -184,6 +208,7 @@ public function testOrderMapHistoryResponse(array $responseData, array $expected
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

$this->assertSame($expectedData, $actualData);
}

Expand Down Expand Up @@ -215,10 +240,14 @@ public function testMapHistoryResponse(array $responseData, array $expectedData)
\ksort($expectedData['transactions'][$key]);
}

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

$this->assertSame($expectedData, $actualData);
}

Expand All @@ -228,7 +257,12 @@ public function testMapHistoryResponse(array $responseData, array $expectedData)
public function testMapRefundResponse(array $responseData, array $expectedData): void
{
$actualData = $this->responseDataMapper->mapRefundResponse($responseData);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

$this->assertSame($expectedData, $actualData);
}

Expand All @@ -238,7 +272,12 @@ public function testMapRefundResponse(array $responseData, array $expectedData):
public function testMapCancelResponse(array $responseData, array $expectedData): void
{
$actualData = $this->responseDataMapper->mapCancelResponse($responseData);

$this->assertArrayHasKey('all', $actualData);
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
unset($actualData['all']);

$this->assertSame($expectedData, $actualData);
}

Expand Down
Loading

0 comments on commit 7929bdd

Please sign in to comment.