Skip to content

Commit

Permalink
Merge branch 'master' into v2
Browse files Browse the repository at this point in the history
# Conflicts:
#	tests/Unit/DataMapper/RequestDataMapper/PayForPosRequestDataMapperTest.php
  • Loading branch information
mustapayev committed Nov 17, 2024
2 parents 07ed472 + 93b3433 commit 924563f
Show file tree
Hide file tree
Showing 32 changed files with 54 additions and 69 deletions.
4 changes: 1 addition & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@
LevelSetList::UP_TO_PHP_74,
])
->withSkip([
\Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector::class,
\Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector::class,
\Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector::class,

\Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector::class,
\Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector::class,
\Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector::class,
\Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector::class,
\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector::class,

\Rector\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector::class,
\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictParamRector::class,
])
->withPreparedSets(
Expand Down
4 changes: 1 addition & 3 deletions src/DataMapper/RequestDataMapper/EstPosRequestDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,7 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s
*/
public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array
{
$requestData += $this->getRequestAccountData($posAccount);

return $requestData;
return $requestData + $this->getRequestAccountData($posAccount);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,7 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s
*/
public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array
{
$requestData += $this->getRequestAccountData($posAccount);

return $requestData;
return $requestData + $this->getRequestAccountData($posAccount);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,7 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o
*/
public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array
{
$requestData += $this->getRequestAccountData($posAccount);

return $requestData;
return $requestData + $this->getRequestAccountData($posAccount);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,7 @@ public function createRefundRequestData(AbstractPosAccount $posAccount, array $o
*/
public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array
{
$requestData += $this->getRequestAccountData($posAccount);

return $requestData;
return $requestData + $this->getRequestAccountData($posAccount);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,9 @@ public function createHistoryRequestData(AbstractPosAccount $posAccount, array $
*/
public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array
{
$requestData += $this->getRequestAccountData($posAccount) + [
return $requestData + ($this->getRequestAccountData($posAccount) + [
'MbrId' => self::MBR_ID,
];

return $requestData;
]);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/DataMapper/RequestDataMapper/PosNetRequestDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,10 @@ public function create3DResolveMerchantRequestData(AbstractPosAccount $posAccoun
*/
public function createCustomQueryRequestData(AbstractPosAccount $posAccount, array $requestData): array
{
$requestData += [
return $requestData + [
'mid' => $posAccount->getClientId(),
'tid' => $posAccount->getTerminalId(),
];

return $requestData;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public function mapOrderHistoryResponse(array $rawResponseData): array
}

if (!$isRecurringOrder) {
\usort($transactions, static function (array $tx1, array $tx2) {
\usort($transactions, static function (array $tx1, array $tx2): int {
if (null !== $tx1['transaction_time'] && null === $tx2['transaction_time']) {
return 1;
}
Expand Down
5 changes: 3 additions & 2 deletions src/Gateways/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public function customQuery(array $requestData, string $apiUrl = null): PosInter
}

$data = $this->serializer->encode($updatedRequestData, $txType);
$apiUrl = $apiUrl ?? $this->getQueryAPIUrl($txType);
$apiUrl ??= $this->getQueryAPIUrl($txType);
$this->response = $this->send(
$data,
$txType,
Expand Down Expand Up @@ -669,7 +669,8 @@ protected function check3DFormInputs(string $paymentModel, string $txType, Credi
throw new \LogicException('Bu banka altyapısı sağlanan ödeme modelini ya da işlem tipini desteklenmiyor.');
}

if ((PosInterface::MODEL_3D_SECURE === $paymentModel || PosInterface::MODEL_3D_PAY === $paymentModel) && null === $card) {
if ((PosInterface::MODEL_3D_SECURE === $paymentModel || PosInterface::MODEL_3D_PAY === $paymentModel)
&& !$card instanceof \Mews\Pos\Entity\Card\CreditCardInterface) {
throw new \InvalidArgumentException('Bu ödeme modeli için kart bilgileri zorunlu!');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class PayForPosRequestDataMapperTest extends TestCase
/** @var CryptInterface & MockObject */
private CryptInterface $crypt;

private array $order;

/** @var EventDispatcherInterface & MockObject */
private EventDispatcherInterface $dispatcher;
private PayForPosRequestValueFormatter $valueFormatter;
Expand All @@ -54,16 +52,6 @@ protected function setUp(): void
'12345678'
);

$this->order = [
'id' => '2020110828BC',
'amount' => 100.01,
'installment' => '0',
'currency' => PosInterface::CURRENCY_TRY,
'success_url' => 'http://localhost/finansbank-payfor/3d/response.php',
'fail_url' => 'http://localhost/finansbank-payfor/3d/response.php',
'lang' => PosInterface::LANG_TR,
];

$this->crypt = $this->createMock(CryptInterface::class);
$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$this->valueFormatter = new PayForPosRequestValueFormatter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public function testMapPaymentResponse(array $order, string $txType, array $resp
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

unset($actualData['all']);

\ksort($expectedData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ function () use ($expectedData) {
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD
$this->assertIsArray($actualData['all']);
$this->assertNotEmpty($actualData['all']);
}

$this->assertArrayHasKey('3d_all', $actualData);
$this->assertIsArray($actualData['3d_all']);
$this->assertNotEmpty($actualData['3d_all']);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Gateways/AkbankPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ private function configureClientResponse(
->method('dispatch')
->with($this->logicalAnd(
$this->isInstanceOf(RequestDataPreparedEvent::class),
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) {
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool {
$updatedRequestDataPreparedEvent = $dispatchedEvent;

return get_class($this->pos) === $dispatchedEvent->getGatewayClass()
Expand All @@ -1046,7 +1046,7 @@ private function configureClientResponse(
&& $paymentModel === $dispatchedEvent->getPaymentModel();
}
)))
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) {
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent {
$updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData();
$updatedRequestData['test-update-request-data-with-event'] = true;
$updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Gateways/EstPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ private function configureClientResponse(
->method('dispatch')
->with($this->logicalAnd(
$this->isInstanceOf(RequestDataPreparedEvent::class),
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) {
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool {
$updatedRequestDataPreparedEvent = $dispatchedEvent;

return get_class($this->pos) === $dispatchedEvent->getGatewayClass()
Expand All @@ -890,7 +890,7 @@ private function configureClientResponse(
&& $paymentModel === $dispatchedEvent->getPaymentModel();
}
)))
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) {
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent {
$updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData();
$updatedRequestData['test-update-request-data-with-event'] = true;
$updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Gateways/GarantiPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ private function configureClientResponse(
->method('dispatch')
->with($this->logicalAnd(
$this->isInstanceOf(RequestDataPreparedEvent::class),
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) {
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool {
$updatedRequestDataPreparedEvent = $dispatchedEvent;

return get_class($this->pos) === $dispatchedEvent->getGatewayClass()
Expand All @@ -812,7 +812,7 @@ private function configureClientResponse(
&& $paymentModel === $dispatchedEvent->getPaymentModel();
}
)))
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) {
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent {
$updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData();
$updatedRequestData['test-update-request-data-with-event'] = true;
$updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Gateways/InterPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ private function configureClientResponse(
->method('dispatch')
->with($this->logicalAnd(
$this->isInstanceOf(RequestDataPreparedEvent::class),
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) {
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool {
$updatedRequestDataPreparedEvent = $dispatchedEvent;

return get_class($this->pos) === $dispatchedEvent->getGatewayClass()
Expand All @@ -752,7 +752,7 @@ private function configureClientResponse(
&& $paymentModel === $dispatchedEvent->getPaymentModel();
}
)))
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) {
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent {
$updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData();
$updatedRequestData['test-update-request-data-with-event'] = true;
$updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Gateways/KuveytPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public function testMake3DPayment(
->method('dispatch')
->with($this->logicalAnd(
$this->isInstanceOf(RequestDataPreparedEvent::class),
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($create3DPaymentRequestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) {
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($create3DPaymentRequestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool {
$updatedRequestDataPreparedEvent = $dispatchedEvent;

return get_class($this->pos) === $dispatchedEvent->getGatewayClass()
Expand All @@ -318,7 +318,7 @@ public function testMake3DPayment(
&& $paymentModel === $dispatchedEvent->getPaymentModel();
}
)))
->willReturnCallback(function() use (&$updatedRequestDataPreparedEvent) {
->willReturnCallback(function() use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent {
$updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData();
$updatedRequestData['test-update-request-data-with-event'] = true;
$updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);
Expand Down Expand Up @@ -665,7 +665,7 @@ private function configureClientResponse(
->method('dispatch')
->with($this->logicalAnd(
$this->isInstanceOf(RequestDataPreparedEvent::class),
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) {
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool {
$updatedRequestDataPreparedEvent = $dispatchedEvent;

return get_class($this->pos) === $dispatchedEvent->getGatewayClass()
Expand All @@ -675,7 +675,7 @@ private function configureClientResponse(
&& $paymentModel === $dispatchedEvent->getPaymentModel();
}
)))
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) {
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent {
$updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData();
$updatedRequestData['test-update-request-data-with-event'] = true;
$updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Gateways/PayFlexCPV4PosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ private function configureClientResponse(
->method('dispatch')
->with($this->logicalAnd(
$this->isInstanceOf(RequestDataPreparedEvent::class),
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent) {
$this->callback(function (RequestDataPreparedEvent $dispatchedEvent) use ($requestData, $txType, $order, $paymentModel, &$updatedRequestDataPreparedEvent): bool {
$updatedRequestDataPreparedEvent = $dispatchedEvent;

return get_class($this->pos) === $dispatchedEvent->getGatewayClass()
Expand All @@ -710,7 +710,7 @@ private function configureClientResponse(
&& $paymentModel === $dispatchedEvent->getPaymentModel();
}
)))
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent) {
->willReturnCallback(function () use (&$updatedRequestDataPreparedEvent): ?\Mews\Pos\Event\RequestDataPreparedEvent {
$updatedRequestData = $updatedRequestDataPreparedEvent->getRequestData();
$updatedRequestData['test-update-request-data-with-event'] = true;
$updatedRequestDataPreparedEvent->setRequestData($updatedRequestData);
Expand Down
Loading

0 comments on commit 924563f

Please sign in to comment.