Skip to content

Commit

Permalink
Merge branch 'master' into 172-kuveyt-turk-api-versiyon-guncellemesi
Browse files Browse the repository at this point in the history
# Conflicts:
#	tests/Unit/Serializer/KuveytPosSerializerTest.php
  • Loading branch information
nuryagdym committed Apr 23, 2024
2 parents a0bc982 + 15e82bb commit 899eea1
Show file tree
Hide file tree
Showing 26 changed files with 3,489 additions and 89 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ return [
Bundan sonra nesnemizi, yeni ayarlarımıza göre oluşturup kullanmamız gerekir. Örnek:
```php
//yeni ayar yolu ya da degeri
$yeniAyarlar = require './pos_ayarlar.php';
$yeniAyarlar = require __DIR__ . '/pos_ayarlar.php';
$pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account, $yeniAyarlar, $eventDispatcher);
```

Expand Down
2 changes: 1 addition & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Bu method ile kütüphanenin ilgili gateway için hangi işlemleri desteklediği

### Changed
- Kütüphane PHP sürümü **v7.4**'e yükseltildi.
- Deprecated olan `VakifBankCPPos` ve `PayFlexAccount` gateway sınıflar kaldırıldı.
- Deprecated olan `VakifBankCPPos` ve `VakifBankPos` gateway sınıflar kaldırıldı.
Yerine `PayFlexCPV4Pos` ve `PayFlexV4Pos` kullanabilirsiniz.
- `AccountFactory::createVakifBankAccount()` method silindi, yerine `AccountFactory::createPayFlexAccount()` kullanabilirsiniz.
- Constant'lar `AbstractGateway` sınıfından `PosInterface`'e taşındı.
Expand Down
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
2 changes: 1 addition & 1 deletion src/Gateways/PosNetV1Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function orderHistory(array $order): PosInterface
*/
protected function send($contents, string $txType, string $paymentModel, ?string $url = null): array
{
$url = $this->getApiURL();
$url = $this->getApiURL($txType);
$this->logger->debug('sending request', ['url' => $url]);

if (!is_string($contents)) {
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
6 changes: 3 additions & 3 deletions src/Serializer/KuveytPosSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use Mews\Pos\PosInterface;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Encoder\XmlEncoder;
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
use Symfony\Component\Serializer\Serializer;
use Throwable;

class KuveytPosSerializer implements SerializerInterface
{
Expand Down Expand Up @@ -75,13 +75,13 @@ public function decode(string $data, string $txType): array

try {
return $this->serializer->decode($data, XmlEncoder::FORMAT);
} catch (Throwable $throwable) {
} catch (NotEncodableValueException $notEncodableValueException) {
if ($this->isHTML($data)) {
// 3D form data icin enrollment istegi gonderiyoruz, o istegin cevabi icinde form olan HTML donuyor.
return $this->transformReceived3DFormData($data);
}

throw new Exception($data, $throwable->getCode(), $throwable);
throw new Exception($data, $notEncodableValueException->getCode(), $notEncodableValueException);
}
}

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 899eea1

Please sign in to comment.