Skip to content

Commit

Permalink
PAYOSWXP-123
Browse files Browse the repository at this point in the history
please see related issue for more information
  • Loading branch information
rommelfreddy committed Jan 24, 2024
1 parent cd18bee commit 8b88958
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/Payone/RequestParameter/RequestParameterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct;
use PayonePayment\Payone\RequestParameter\Struct\ClientApiRequest;
use PayonePayment\Payone\RequestParameter\Struct\GetFileStruct;

class RequestParameterFactory
Expand Down Expand Up @@ -53,6 +54,12 @@ private function filterParams(AbstractRequestParameterStruct $arguments, array $
unset($parameters['aid'], $parameters['hash']);
}

if ($arguments instanceof ClientApiRequest) {
unset($parameters['key']);
} else {
unset($parameters['hash']);
}

return $parameters;
}

Expand Down
7 changes: 7 additions & 0 deletions src/Payone/RequestParameter/Struct/ClientApiRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php declare(strict_types=1);

namespace PayonePayment\Payone\RequestParameter\Struct;

interface ClientApiRequest
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use PayonePayment\Payone\RequestParameter\Struct\Traits\SalesChannelContextTrait;
use Shopware\Core\System\SalesChannel\SalesChannelContext;

class CreditCardCheckStruct extends AbstractRequestParameterStruct
class CreditCardCheckStruct extends AbstractRequestParameterStruct implements ClientApiRequest
{
use SalesChannelContextTrait;

Expand Down
24 changes: 24 additions & 0 deletions tests/Payone/RequestParameter/RequestParameterFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PayonePayment\PaymentHandler\PayoneDebitPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
use PayonePayment\Payone\RequestParameter\Struct\AbstractRequestParameterStruct;
use PayonePayment\Payone\RequestParameter\Struct\ClientApiRequest;
use PayonePayment\Payone\RequestParameter\Struct\GetFileStruct;
use PayonePayment\TestCaseBase\PayoneTestBehavior;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -45,6 +46,29 @@ public function testItReturnsCorrectRequestParametersWithKey(): void
],
$parameters
);
static::assertArrayHasKey('key', $parameters);
static::assertArrayNotHasKey('hash', $parameters);
}

public function testItReturnsCorrectRequestParametersWithHash(): void
{
$factory = new RequestParameterFactory([
$this->getSupportedParameterBuilder([
'key' => 'value',
'key-1' => 'value-1',
'key-2' => 'value-2',
]),
$this->getSupportedParameterBuilder([
'key-2' => 'other-value',
'key-3' => 'value-3',
]),
$this->getNotSupportedParameterBuilder(),
]);

$parameters = $factory->getRequestParameter(new class() extends AbstractRequestParameterStruct implements ClientApiRequest {
});

static::assertArrayNotHasKey('key', $parameters);
static::assertArrayHasKey('hash', $parameters);
}

Expand Down

0 comments on commit 8b88958

Please sign in to comment.