Skip to content

Commit

Permalink
tests - PayFlexCPV4PosTest refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed Mar 29, 2024
1 parent 650d2da commit 94a88c3
Show file tree
Hide file tree
Showing 3 changed files with 286 additions and 144 deletions.
48 changes: 24 additions & 24 deletions src/Gateways/PayFlexCPV4Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,38 @@ public function get3DFormData(array $order, string $paymentModel, string $txType
);
}

/**
* @inheritDoc
*
* @return array<string, mixed>
*/
protected function send($contents, string $txType, string $paymentModel, ?string $url = null): array
{
$url ??= $this->getApiURL();
$this->logger->debug('sending request', ['url' => $url]);

$isXML = \is_string($contents);
$body = $isXML ? ['body' => $contents] : ['form_params' => $contents];

$response = $this->client->post($url, $body);
$this->logger->debug('request completed', ['status_code' => $response->getStatusCode()]);

$responseContent = $response->getBody()->getContents();

return $this->data = $this->serializer->decode($responseContent, $txType);
}

/**
*
* ORTAK ÖDEME SİSTEMİNE İŞLEM KAYDETME
*
* @phpstan-param PosInterface::TX_TYPE_PAY_AUTH|PosInterface::TX_TYPE_PAY_PRE_AUTH $txType
* @phpstan-param PosInterface::MODEL_3D_* $paymentModel
* @phpstan-param PosInterface::MODEL_3D_* $paymentModel
*
* @param array<string, int|string|float|null> $order
* @param string $txType
* @param string $paymentModel
* @param CreditCardInterface|null $creditCard
* @param CreditCardInterface|null $creditCard
*
* Basarili durumda donen cevap formati: array{CommonPaymentUrl: string, PaymentToken: string, ErrorCode: null,
* ResponseMessage: null} Basarisiz durumda donen cevap formati: array{CommonPaymentUrl: null, PaymentToken: null,
Expand All @@ -190,7 +211,7 @@ public function get3DFormData(array $order, string $paymentModel, string $txType
*
* @throws Exception
*/
public function registerPayment(array $order, string $txType, string $paymentModel, CreditCardInterface $creditCard = null): array
private function registerPayment(array $order, string $txType, string $paymentModel, CreditCardInterface $creditCard = null): array
{
$requestData = $this->requestDataMapper->create3DEnrollmentCheckRequestData(
$this->account,
Expand All @@ -217,25 +238,4 @@ public function registerPayment(array $order, string $txType, string $paymentMod

return $response;
}

/**
* @inheritDoc
*
* @return array<string, mixed>
*/
protected function send($contents, string $txType, string $paymentModel, ?string $url = null): array
{
$url ??= $this->getApiURL();
$this->logger->debug('sending request', ['url' => $url]);

$isXML = \is_string($contents);
$body = $isXML ? ['body' => $contents] : ['form_params' => $contents];

$response = $this->client->post($url, $body);
$this->logger->debug('request completed', ['status_code' => $response->getStatusCode()]);

$responseContent = $response->getBody()->getContents();

return $this->data = $this->serializer->decode($responseContent, $txType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function threesDPayResponseDataProvider(): Generator
'TransactionId' => '0cb6a57715144178a014afbe0185b9ed',
'MaskedPan' => '49384601****4205',
],
'expected' => [
'expectedData' => [
'order_id' => null,
'transaction_id' => '0cb6a57715144178a014afbe0185b9ed',
'transaction_type' => 'pay',
Expand Down Expand Up @@ -122,7 +122,7 @@ public static function threesDPayResponseDataProvider(): Generator
'TransactionId' => '868382724da7480c949dafbd016c7636',
'MaskedPan' => '49384601****4205',
],
'expected' => [
'expectedData' => [
'order_id' => null,
'transaction_id' => '868382724da7480c949dafbd016c7636',
'transaction_type' => 'pay',
Expand All @@ -147,7 +147,7 @@ public static function threesDPayResponseDataProvider(): Generator

yield 'success_response_from_gateway_1' => [
'order' => [],
'txType' => PosInterface::TX_TYPE_PAY_PRE_AUTH,
'txType' => PosInterface::TX_TYPE_PAY_AUTH,
'bank_response' => [
'Rc' => '0000',
'AuthCode' => '735879',
Expand Down Expand Up @@ -182,7 +182,7 @@ public static function threesDPayResponseDataProvider(): Generator
'ErrorCode' => null,
'ResponseMessage' => null,
],
'expected' => [
'expectedData' => [
'order_id' => '2023030913ED',
'transaction_id' => '3ee068d5b5a747ada65dafc0016d5887',
'transaction_type' => 'pay',
Expand Down
Loading

0 comments on commit 94a88c3

Please sign in to comment.