Skip to content

Commit

Permalink
Merge pull request #195 from mewebstudio/working-on-test-coverage
Browse files Browse the repository at this point in the history
Working on test coverage
  • Loading branch information
nuryagdym authored Apr 1, 2024
2 parents 414dab7 + 376c8f7 commit 831a1ff
Show file tree
Hide file tree
Showing 19 changed files with 3,365 additions and 64 deletions.
4 changes: 3 additions & 1 deletion src/Gateways/InterPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ public function make3DPayPayment(Request $request, array $order, string $txType)
*/
public function make3DHostPayment(Request $request, array $order, string $txType): PosInterface
{
return $this->make3DPayPayment($request, $order, $txType);
$this->response = $this->responseDataMapper->map3DHostResponseData($request->request->all(), $txType, $order);

return $this;
}

/**
Expand Down
11 changes: 9 additions & 2 deletions src/Gateways/KuveytPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Mews\Pos\Entity\Card\CreditCardInterface;
use Mews\Pos\Event\RequestDataPreparedEvent;
use Mews\Pos\Exceptions\HashMismatchException;
use Mews\Pos\Exceptions\NotImplementedException;
use Mews\Pos\Exceptions\UnsupportedPaymentModelException;
use Mews\Pos\Exceptions\UnsupportedTransactionTypeException;
use Mews\Pos\PosInterface;
Expand Down Expand Up @@ -114,7 +113,15 @@ public function get3DFormData(array $order, string $paymentModel, string $txType
*/
public function makeRegularPayment(array $order, CreditCardInterface $creditCard, string $txType): PosInterface
{
throw new NotImplementedException();
throw new UnsupportedPaymentModelException();
}

/**
* @inheritDoc
*/
public function makeRegularPostPayment(array $order): PosInterface
{
throw new UnsupportedPaymentModelException();
}

/**
Expand Down
10 changes: 9 additions & 1 deletion src/Gateways/PayFlexCPV4Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,20 @@ public function make3DHostPayment(Request $request, array $order, string $txType
return $this->make3DPayPayment($request, $order, $txType);
}

/**
* @inheritDoc
*/
public function status(array $order): PosInterface
{
throw new UnsupportedTransactionTypeException();
}

/**
* @inheritDoc
*/
public function history(array $data): PosInterface
{
throw new UnsupportedPaymentModelException();
throw new UnsupportedTransactionTypeException();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Gateways/PayForPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ public function make3DPayPayment(Request $request, array $order, string $txType)
*/
public function make3DHostPayment(Request $request, array $order, string $txType): PosInterface
{
return $this->make3DPayPayment($request, $order, $txType);
$this->response = $this->responseDataMapper->map3DHostResponseData($request->request->all(), $txType, $order);

return $this;
}

/**
Expand Down
12 changes: 11 additions & 1 deletion src/Gateways/ToslaPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,17 @@ public function make3DPayPayment(Request $request, array $order, string $txType)
*/
public function make3DHostPayment(Request $request, array $order, string $txType): PosInterface
{
return $this->make3DPayPayment($request, $order, $txType);
$request = $request->request;

if ($this->is3DAuthSuccess($request->all()) && !$this->requestDataMapper->getCrypt()->check3DHash($this->account, $request->all())) {
throw new HashMismatchException();
}

$this->response = $this->responseDataMapper->map3DHostResponseData($request->all(), $txType, $order);

$this->logger->debug('finished 3D payment', ['mapped_response' => $this->response]);

return $this;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Serializer/PayFlexV4PosSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Symfony\Component\Serializer\Encoder\XmlEncoder;
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
use Symfony\Component\Serializer\Serializer;
use function sprintf;
use function strip_tags;

class PayFlexV4PosSerializer implements SerializerInterface
Expand Down Expand Up @@ -46,7 +45,7 @@ public static function supports(string $gatewayClass): bool
public function encode(array $data, string $txType): string
{
if (PosInterface::TX_TYPE_HISTORY === $txType || PosInterface::TX_TYPE_ORDER_HISTORY === $txType) {
throw new DomainException(sprintf('Serialization of the transaction %s is not supported', $txType));
throw new DomainException(\sprintf('Serialization of the transaction %s is not supported', $txType));
}

if (PosInterface::TX_TYPE_STATUS === $txType) {
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Crypt/PayFlexCP4CryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
*/
class PayFlexCP4CryptTest extends TestCase
{
/** @var array<string, string>|array<string, float> */
public array $order = [];

public PayFlexCPV4Crypt $crypt;

private PayFlexAccount $account;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GarantiPosRequestDataMapperTest extends TestCase

private GarantiPosRequestDataMapper $requestDataMapper;

private $order;
private array $order;

private $config;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public static function paymentDataProvider(): iterable
public static function threeDPaymentDataProvider(): array
{
return [
'authFail1' => [
'3d_auth_fail' => [
'order' => [],
'txType' => PosInterface::TX_TYPE_PAY_AUTH,
'threeDResponseData' => [
Expand Down Expand Up @@ -517,7 +517,7 @@ public static function threeDPaymentDataProvider(): array
'installment_count' => 0,
],
],
'auth_success_payment_fail' => [
'3d_auth_success_payment_fail' => [
'order' => [],
'txType' => PosInterface::TX_TYPE_PAY_PRE_AUTH,
'threeDResponseData' => [
Expand Down Expand Up @@ -584,7 +584,7 @@ public static function threeDPaymentDataProvider(): array
'installment_count' => 0,
],
],
'success1' => [
'success1' => [
'order' => [],
'txType' => PosInterface::TX_TYPE_PAY_PRE_AUTH,
'threeDResponseData' => [
Expand Down
Loading

0 comments on commit 831a1ff

Please sign in to comment.