diff --git a/src/Gateways/AbstractGateway.php b/src/Gateways/AbstractGateway.php index 1d09dad3..235df971 100644 --- a/src/Gateways/AbstractGateway.php +++ b/src/Gateways/AbstractGateway.php @@ -136,19 +136,27 @@ public function getApiURL(string $txType = null, string $paymentModel = null, ?s } /** + * @param PosInterface::MODEL_3D_* $paymentModel + * * @return non-empty-string */ - public function get3DGatewayURL(): string + public function get3DGatewayURL(string $paymentModel = PosInterface::MODEL_3D_SECURE): string { + if (PosInterface::MODEL_3D_HOST === $paymentModel && isset($this->config['gateway_endpoints']['gateway_3d_host'])) { + return $this->config['gateway_endpoints']['gateway_3d_host']; + } + return $this->config['gateway_endpoints']['gateway_3d']; } /** + * @deprecated use get3DGatewayURL() instead + * * @return non-empty-string */ public function get3DHostGatewayURL(): string { - return $this->config['gateway_endpoints']['gateway_3d_host'] ?? $this->get3DGatewayURL(); + return $this->get3DGatewayURL(PosInterface::MODEL_3D_HOST); } /** diff --git a/src/Gateways/AkbankPos.php b/src/Gateways/AkbankPos.php index c7d230a0..96e56eb2 100644 --- a/src/Gateways/AkbankPos.php +++ b/src/Gateways/AkbankPos.php @@ -164,14 +164,12 @@ public function get3DFormData(array $order, string $paymentModel, string $txType $this->logger->debug('preparing 3D form data'); - $gatewayUrl = PosInterface::MODEL_3D_HOST === $paymentModel ? $this->get3DHostGatewayURL() : $this->get3DGatewayURL(); - return $this->requestDataMapper->create3DFormData( $this->account, $order, $paymentModel, $txType, - $gatewayUrl, + $this->get3DGatewayURL($paymentModel), $creditCard ); } diff --git a/src/Gateways/EstPos.php b/src/Gateways/EstPos.php index 2289d7bf..10460d6e 100644 --- a/src/Gateways/EstPos.php +++ b/src/Gateways/EstPos.php @@ -161,7 +161,14 @@ public function get3DFormData(array $order, string $paymentModel, string $txType $this->logger->debug('preparing 3D form data'); - return $this->requestDataMapper->create3DFormData($this->account, $order, $paymentModel, $txType, $this->get3DGatewayURL(), $creditCard); + return $this->requestDataMapper->create3DFormData( + $this->account, + $order, + $paymentModel, + $txType, + $this->get3DGatewayURL($paymentModel), + $creditCard + ); } /** diff --git a/src/Gateways/GarantiPos.php b/src/Gateways/GarantiPos.php index 16edfd69..2d12a957 100644 --- a/src/Gateways/GarantiPos.php +++ b/src/Gateways/GarantiPos.php @@ -131,7 +131,14 @@ public function get3DFormData(array $order, string $paymentModel, string $txType $this->logger->debug('preparing 3D form data'); - return $this->requestDataMapper->create3DFormData($this->account, $order, $paymentModel, $txType, $this->get3DGatewayURL(), $creditCard); + return $this->requestDataMapper->create3DFormData( + $this->account, + $order, + $paymentModel, + $txType, + $this->get3DGatewayURL($paymentModel), + $creditCard + ); } /** diff --git a/src/Gateways/InterPos.php b/src/Gateways/InterPos.php index 2fc7895b..306e20d1 100644 --- a/src/Gateways/InterPos.php +++ b/src/Gateways/InterPos.php @@ -165,9 +165,14 @@ public function get3DFormData(array $order, string $paymentModel, string $txType $this->logger->debug('preparing 3D form data'); - $gatewayUrl = PosInterface::MODEL_3D_HOST === $paymentModel ? $this->get3DHostGatewayURL() : $this->get3DGatewayURL(); - - return $this->requestDataMapper->create3DFormData($this->account, $order, $paymentModel, $txType, $gatewayUrl, $creditCard); + return $this->requestDataMapper->create3DFormData( + $this->account, + $order, + $paymentModel, + $txType, + $this->get3DGatewayURL($paymentModel), + $creditCard + ); } /** diff --git a/src/Gateways/KuveytPos.php b/src/Gateways/KuveytPos.php index bb94fd72..d3f4c29a 100644 --- a/src/Gateways/KuveytPos.php +++ b/src/Gateways/KuveytPos.php @@ -136,11 +136,16 @@ public function get3DFormData(array $order, string $paymentModel, string $txType { $this->check3DFormInputs($paymentModel, $txType, $creditCard); - $gatewayUrl = $this->get3DGatewayURL(); - $this->logger->debug('preparing 3D form data'); - return $this->getCommon3DFormData($this->account, $order, $paymentModel, $txType, $gatewayUrl, $creditCard); + return $this->getCommon3DFormData( + $this->account, + $order, + $paymentModel, + $txType, + $this->get3DGatewayURL($paymentModel), + $creditCard + ); } /** diff --git a/src/Gateways/PayFlexV4Pos.php b/src/Gateways/PayFlexV4Pos.php index d9c9b9d6..837a5ef1 100644 --- a/src/Gateways/PayFlexV4Pos.php +++ b/src/Gateways/PayFlexV4Pos.php @@ -188,7 +188,15 @@ public function get3DFormData(array $order, string $paymentModel, string $txType $this->logger->debug('preparing 3D form data'); - return $this->requestDataMapper->create3DFormData($this->account, null, $paymentModel, $txType, '', null, $data['Message']['VERes']); + return $this->requestDataMapper->create3DFormData( + $this->account, + null, + $paymentModel, + $txType, + '', + null, + $data['Message']['VERes'] + ); } /** diff --git a/src/Gateways/PayForPos.php b/src/Gateways/PayForPos.php index 205d2abb..2b6c6299 100644 --- a/src/Gateways/PayForPos.php +++ b/src/Gateways/PayForPos.php @@ -172,9 +172,14 @@ public function get3DFormData(array $order, string $paymentModel, string $txType $this->logger->debug('preparing 3D form data'); - $gatewayURL = PosInterface::MODEL_3D_HOST === $paymentModel ? $this->get3DHostGatewayURL() : $this->get3DGatewayURL(); - - return $this->requestDataMapper->create3DFormData($this->account, $order, $paymentModel, $txType, $gatewayURL, $creditCard); + return $this->requestDataMapper->create3DFormData( + $this->account, + $order, + $paymentModel, + $txType, + $this->get3DGatewayURL($paymentModel), + $creditCard + ); } diff --git a/src/Gateways/PosNet.php b/src/Gateways/PosNet.php index 290b1ef9..da6fcd04 100644 --- a/src/Gateways/PosNet.php +++ b/src/Gateways/PosNet.php @@ -182,7 +182,7 @@ public function get3DFormData(array $order, string $paymentModel, string $txType $order, $paymentModel, $txType, - $this->get3DGatewayURL(), + $this->get3DGatewayURL($paymentModel), null, $data['oosRequestDataResponse'] ); diff --git a/src/Gateways/PosNetV1Pos.php b/src/Gateways/PosNetV1Pos.php index 32517453..95b8ddb4 100644 --- a/src/Gateways/PosNetV1Pos.php +++ b/src/Gateways/PosNetV1Pos.php @@ -152,7 +152,14 @@ public function get3DFormData(array $order, string $paymentModel, string $txType $this->logger->debug('preparing 3D form data'); - return $this->requestDataMapper->create3DFormData($this->account, $order, $paymentModel, $txType, $this->get3DGatewayURL(), $creditCard); + return $this->requestDataMapper->create3DFormData( + $this->account, + $order, + $paymentModel, + $txType, + $this->get3DGatewayURL($paymentModel), + $creditCard + ); } /** diff --git a/src/Gateways/ToslaPos.php b/src/Gateways/ToslaPos.php index eacc6822..60e81046 100644 --- a/src/Gateways/ToslaPos.php +++ b/src/Gateways/ToslaPos.php @@ -84,10 +84,16 @@ public function getApiURL(string $txType = null, string $paymentModel = null, ?s /** * @inheritDoc + * + * @param string $threeDSessionId */ - public function get3DHostGatewayURL(string $threeDSessionId = null): string + public function get3DGatewayURL(string $paymentModel = PosInterface::MODEL_3D_SECURE, string $threeDSessionId = null): string { - return parent::get3DHostGatewayURL().'/'.$threeDSessionId; + if (PosInterface::MODEL_3D_HOST === $paymentModel) { + return parent::get3DGatewayURL($paymentModel).'/'.$threeDSessionId; + } + + return parent::get3DGatewayURL($paymentModel); } /** @@ -152,12 +158,15 @@ public function get3DFormData(array $order, string $paymentModel, string $txType } $this->logger->debug('preparing 3D form data'); - $gatewayUrl = $this->get3DGatewayURL(); - if (PosInterface::MODEL_3D_HOST === $paymentModel) { - $gatewayUrl = $this->get3DHostGatewayURL($data['ThreeDSessionId']); - } - return $this->requestDataMapper->create3DFormData($this->account, $data, $paymentModel, $txType, $gatewayUrl, $creditCard); + return $this->requestDataMapper->create3DFormData( + $this->account, + $data, + $paymentModel, + $txType, + $this->get3DGatewayURL($paymentModel, $data['ThreeDSessionId'] ?? null), + $creditCard + ); } /** diff --git a/src/Gateways/VakifKatilimPos.php b/src/Gateways/VakifKatilimPos.php index f4e7a789..5ef7f7a4 100644 --- a/src/Gateways/VakifKatilimPos.php +++ b/src/Gateways/VakifKatilimPos.php @@ -106,13 +106,32 @@ public function get3DFormData(array $order, string $paymentModel, string $txType $this->logger->debug('preparing 3D form data'); if (PosInterface::MODEL_3D_HOST === $paymentModel) { - return $this->requestDataMapper->create3DFormData($this->account, $order, $paymentModel, $txType, $this->get3DHostGatewayURL()); + return $this->requestDataMapper->create3DFormData( + $this->account, + $order, + $paymentModel, + $txType, + $this->get3DGatewayURL($paymentModel) + ); } - $gatewayUrl = $this->get3DGatewayURL(); - $response = $this->sendEnrollmentRequest($this->account, $order, $paymentModel, $txType, $gatewayUrl, $creditCard); + $response = $this->sendEnrollmentRequest( + $this->account, + $order, + $paymentModel, + $txType, + $this->get3DGatewayURL($paymentModel), + $creditCard + ); - return $this->requestDataMapper->create3DFormData($this->account, $response['form_inputs'], $paymentModel, $txType, $response['gateway'], $creditCard); + return $this->requestDataMapper->create3DFormData( + $this->account, + $response['form_inputs'], + $paymentModel, + $txType, + $response['gateway'], + $creditCard + ); } /** diff --git a/tests/Unit/Gateways/PayForTest.php b/tests/Unit/Gateways/PayForTest.php index 5c76a49e..16ec3967 100644 --- a/tests/Unit/Gateways/PayForTest.php +++ b/tests/Unit/Gateways/PayForTest.php @@ -134,7 +134,7 @@ public function testInit(): void $this->assertSame($this->config, $this->pos->getConfig()); $this->assertSame($this->account, $this->pos->getAccount()); $this->assertSame([PosInterface::CURRENCY_TRY], $this->pos->getCurrencies()); - $this->assertSame($this->config['gateway_endpoints']['gateway_3d_host'], $this->pos->get3DHostGatewayURL()); + $this->assertSame($this->config['gateway_endpoints']['gateway_3d_host'], $this->pos->get3DGatewayURL(PosInterface::MODEL_3D_HOST)); $this->assertSame($this->config['gateway_endpoints']['gateway_3d'], $this->pos->get3DGatewayURL()); $this->assertSame($this->config['gateway_endpoints']['payment_api'], $this->pos->getApiURL()); } diff --git a/tests/Unit/Gateways/ToslaPosTest.php b/tests/Unit/Gateways/ToslaPosTest.php index e1da675a..d0050483 100644 --- a/tests/Unit/Gateways/ToslaPosTest.php +++ b/tests/Unit/Gateways/ToslaPosTest.php @@ -155,7 +155,7 @@ public function testGet3DGatewayURL(): void public function testGet3DHostGatewayURL(): void { $sessionId = 'A2A6E942BD2AE4A68BC42FE99D1BC917D67AFF54AB2BA44EBA675843744187708'; - $actual = $this->pos->get3DHostGatewayURL($sessionId); + $actual = $this->pos->get3DGatewayURL(PosInterface::MODEL_3D_HOST, $sessionId); $this->assertSame( 'https://ent.akodepos.com/api/Payment/threeDSecure/A2A6E942BD2AE4A68BC42FE99D1BC917D67AFF54AB2BA44EBA675843744187708',