Skip to content

Commit

Permalink
deprecate get3DHostGatewayURL method
Browse files Browse the repository at this point in the history
  • Loading branch information
mustapayev committed Nov 16, 2024
1 parent ec4e461 commit 4c53a77
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 32 deletions.
12 changes: 10 additions & 2 deletions src/Gateways/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Gateways/AkbankPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down
9 changes: 8 additions & 1 deletion src/Gateways/EstPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

/**
Expand Down
9 changes: 8 additions & 1 deletion src/Gateways/GarantiPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

/**
Expand Down
11 changes: 8 additions & 3 deletions src/Gateways/InterPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

/**
Expand Down
11 changes: 8 additions & 3 deletions src/Gateways/KuveytPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

/**
Expand Down
10 changes: 9 additions & 1 deletion src/Gateways/PayFlexV4Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
);
}

/**
Expand Down
11 changes: 8 additions & 3 deletions src/Gateways/PayForPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}


Expand Down
2 changes: 1 addition & 1 deletion src/Gateways/PosNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function get3DFormData(array $order, string $paymentModel, string $txType
$order,
$paymentModel,
$txType,
$this->get3DGatewayURL(),
$this->get3DGatewayURL($paymentModel),
null,
$data['oosRequestDataResponse']
);
Expand Down
9 changes: 8 additions & 1 deletion src/Gateways/PosNetV1Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

/**
Expand Down
23 changes: 16 additions & 7 deletions src/Gateways/ToslaPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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
);
}

/**
Expand Down
27 changes: 23 additions & 4 deletions src/Gateways/VakifKatilimPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Gateways/PayForTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Gateways/ToslaPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 4c53a77

Please sign in to comment.