Skip to content

Commit

Permalink
Merge pull request #234 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 Sep 24, 2024
2 parents 5b9b15a + c7cac71 commit 11d97a2
Show file tree
Hide file tree
Showing 42 changed files with 1,640 additions and 301 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
Expand All @@ -11,5 +12,10 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 4

ij_php_align_assignments = true
ij_php_align_class_constants = true
ij_php_align_key_value_pairs = true
ij_php_phpdoc_param_spaces_between_tag_and_type = 1

[*.md]
max_line_length = 80
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
"symfony/http-client": "^5.4",
"symfony/var-dumper": "^5.1"
},
"suggest": {
"ext-soap": "KuveytPos ile iptal/iade gibi ödeme olmayan işlemleri yapacaksanız."
},
"config": {
"sort-packages": true,
"allow-plugins": {
Expand Down
10 changes: 6 additions & 4 deletions src/Crypt/PosNetV1PosCrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ public function create3DHash(AbstractPosAccount $posAccount, array $requestData,
$hashData = [
$posAccount->getClientId(),
$posAccount->getTerminalId(),
$requestData['CardNo'],
$requestData['Cvv'],
$requestData['ExpiredDate'],
// no card data for 3D host payment
$requestData['CardNo'] ?? null,
$requestData['Cvv'] ?? null,
$requestData['ExpiredDate'] ?? null,

$requestData['Amount'],
$posAccount->getStoreKey(),
];
$hashStr = implode(static::HASH_SEPARATOR, $hashData);
$hashStr = \implode(static::HASH_SEPARATOR, $hashData);

return $this->hashString($hashStr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ public function create3DFormData(AbstractPosAccount $posAccount, array $order, s
* UseOOS alanını 1 yaparak bankanın ortak ödeme sayfasının açılmasını ve
* bu ortak ödeme sayfası ile müşterinin kart bilgilerini girmesini sağlatabilir.
*/
'UseOOS' => '1',
'UseOOS' => '1',
'MacParams' => 'MerchantNo:TerminalNo:Amount',
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymen
*/
public function map3DPayResponseData(array $raw3DAuthResponseData, string $txType, array $order): array
{
return $this->map3DPaymentData($raw3DAuthResponseData, $raw3DAuthResponseData, $txType, $order);
throw new NotImplementedException();
}

/**
* {@inheritdoc}
*/
public function map3DHostResponseData(array $raw3DAuthResponseData, string $txType, array $order): array
{
return $this->map3DPayResponseData($raw3DAuthResponseData, $txType, $order);
throw new NotImplementedException();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ public function map3DPaymentData(array $raw3DAuthResponseData, ?array $rawPaymen
*/
public function map3DPayResponseData(array $raw3DAuthResponseData, string $txType, array $order): array
{
return $this->map3DPaymentData($raw3DAuthResponseData, $raw3DAuthResponseData, $txType, $order);
throw new NotImplementedException();
}

/**
* {@inheritdoc}
*/
public function map3DHostResponseData(array $raw3DAuthResponseData, string $txType, array $order): array
{
return $this->map3DPayResponseData($raw3DAuthResponseData, $txType, $order);
throw new NotImplementedException();
}

/**
Expand Down
21 changes: 14 additions & 7 deletions src/Gateways/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ public function makeRegularPayment(array $order, CreditCardInterface $creditCard
$order,
PosInterface::MODEL_NON_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down Expand Up @@ -282,7 +283,8 @@ public function makeRegularPostPayment(array $order): PosInterface
$order,
PosInterface::MODEL_NON_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down Expand Up @@ -325,7 +327,8 @@ public function refund(array $order): PosInterface
$order,
PosInterface::MODEL_NON_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down Expand Up @@ -368,7 +371,8 @@ public function cancel(array $order): PosInterface
$order,
PosInterface::MODEL_NON_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down Expand Up @@ -411,7 +415,8 @@ public function status(array $order): PosInterface
$order,
PosInterface::MODEL_NON_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down Expand Up @@ -450,7 +455,8 @@ public function history(array $data): PosInterface
$data,
PosInterface::MODEL_NON_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down Expand Up @@ -489,7 +495,8 @@ public function orderHistory(array $order): PosInterface
$order,
PosInterface::MODEL_NON_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down
7 changes: 5 additions & 2 deletions src/Gateways/AkbankPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ class AkbankPos extends AbstractGateway

/**
* @inheritDoc
*
* @throws \InvalidArgumentException when transaction type is not provided
*/
public function getApiURL(string $txType = null, string $paymentModel = null, ?string $orderTxType = null): string
{
if (null !== $txType) {
return parent::getApiURL().'/'.$this->getRequestURIByTransactionType($txType);
}

return parent::getApiURL();
throw new \InvalidArgumentException('Transaction type is required to generate API URL');
}

/** @return AkbankPosAccount */
Expand Down Expand Up @@ -93,7 +95,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$order,
PosInterface::MODEL_3D_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down
3 changes: 2 additions & 1 deletion src/Gateways/EstPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$order,
PosInterface::MODEL_3D_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down
3 changes: 2 additions & 1 deletion src/Gateways/GarantiPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$order,
PosInterface::MODEL_3D_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down
3 changes: 2 additions & 1 deletion src/Gateways/InterPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$order,
PosInterface::MODEL_3D_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down
9 changes: 6 additions & 3 deletions src/Gateways/KuveytPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function getAccount(): AbstractPosAccount
* @inheritDoc
*
* @throws UnsupportedTransactionTypeException
* @throws \InvalidArgumentException when transaction type is not provided
*/
public function getApiURL(string $txType = null, string $paymentModel = null, ?string $orderTxType = null): string
{
Expand All @@ -87,7 +88,7 @@ public function getApiURL(string $txType = null, string $paymentModel = null, ?s
return parent::getApiURL().'/'.$this->getRequestURIByTransactionType($txType, $paymentModel);
}

return parent::getApiURL();
throw new \InvalidArgumentException('Transaction type is required to generate API URL');
}

/**
Expand Down Expand Up @@ -178,7 +179,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$order,
PosInterface::MODEL_3D_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down Expand Up @@ -345,7 +347,8 @@ private function getCommon3DFormData(KuveytPosAccount $kuveytPosAccount, array $
$order,
$paymentModel
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down
6 changes: 4 additions & 2 deletions src/Gateways/PayFlexCPV4Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public function make3DPayPayment(Request $request, array $order, string $txType)
$order,
PosInterface::MODEL_3D_PAY
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down Expand Up @@ -254,7 +255,8 @@ private function registerPayment(array $order, string $txType, string $paymentMo
$order,
$paymentModel
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down
6 changes: 4 additions & 2 deletions src/Gateways/PayFlexV4Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$order,
PosInterface::MODEL_3D_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down Expand Up @@ -231,7 +232,8 @@ private function sendEnrollmentRequest(array $order, CreditCardInterface $credit
$order,
$paymentModel
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down
10 changes: 3 additions & 7 deletions src/Gateways/PayForPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$order,
PosInterface::MODEL_3D_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down Expand Up @@ -131,12 +132,7 @@ public function make3DHostPayment(Request $request, array $order, string $txType
}

/**
* Refund Order
* refund amount should be exactly the same with order amount.
* otherwise operation will be rejected
*
* Warning: You can not use refund for purchases made at the same date.
* Instead, you need to use cancel.
* Satış işlemi ile farklı batchtlerde olmalıdır.
*
* @inheritDoc
*/
Expand Down
9 changes: 6 additions & 3 deletions src/Gateways/PosNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$order,
PosInterface::MODEL_3D_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down Expand Up @@ -118,7 +119,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$order,
PosInterface::MODEL_3D_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down Expand Up @@ -266,7 +268,8 @@ private function getOosTransactionData(array $order, string $txType, string $pay
$order,
$paymentModel
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down
6 changes: 4 additions & 2 deletions src/Gateways/PosNetV1Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ public function getAccount(): AbstractPosAccount
* @inheritDoc
*
* @throws UnsupportedTransactionTypeException
* @throws \InvalidArgumentException when transaction type is not provided
*/
public function getApiURL(string $txType = null, string $paymentModel = null, ?string $orderTxType = null): string
{
if (null !== $txType) {
return parent::getApiURL().'/'.$this->requestDataMapper->mapTxType($txType);
}

return parent::getApiURL();
throw new \InvalidArgumentException('Transaction type is required to generate API URL');
}

/**
Expand Down Expand Up @@ -98,7 +99,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$order,
PosInterface::MODEL_3D_SECURE
);
$this->eventDispatcher->dispatch($event);
/** @var RequestDataPreparedEvent $event */
$event = $this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
$this->logger->debug('Request data is changed via listeners', [
'txType' => $event->getTxType(),
Expand Down
Loading

0 comments on commit 11d97a2

Please sign in to comment.