diff --git a/src/Crypt/PosNetV1PosCrypt.php b/src/Crypt/PosNetV1PosCrypt.php index 242f152b..8426ddfd 100644 --- a/src/Crypt/PosNetV1PosCrypt.php +++ b/src/Crypt/PosNetV1PosCrypt.php @@ -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); } diff --git a/src/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapper.php b/src/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapper.php index 2e912cb2..a06d65b7 100644 --- a/src/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapper.php +++ b/src/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapper.php @@ -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', ]; } diff --git a/tests/Unit/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapperTest.php b/tests/Unit/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapperTest.php index bed064c1..e764b8df 100644 --- a/tests/Unit/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapperTest.php +++ b/tests/Unit/DataMapper/RequestDataMapper/PosNetV1PosRequestDataMapperTest.php @@ -182,7 +182,7 @@ public function testCreate3DPaymentRequestData(array $order, string $txType, arr /** * @dataProvider threeDFormDataTestProvider */ - public function testCreate3DFormData(array $order, string $txType, string $gatewayUrl, array $expected): void + public function testCreate3DFormData(array $order, string $txType, string $gatewayUrl, ?CreditCardInterface $card, array $expected): void { $paymentModel = PosInterface::MODEL_3D_SECURE; $this->dispatcher->expects(self::once()) @@ -199,10 +199,10 @@ public function testCreate3DFormData(array $order, string $txType, string $gatew $paymentModel, $txType, $gatewayUrl, - $this->card + $card ); - $this->assertEquals($expected, $actual); + $this->assertSame($expected, $actual); } /** @@ -261,12 +261,17 @@ public static function threeDFormDataTestProvider(): iterable 'success_url' => 'https://domain.com/success', 'lang' => PosInterface::LANG_TR, ]; + $card = CreditCardFactory::create('5400619360964581', '20', '01', '056', 'ahmet'); + $gatewayUrl = 'https://epostest.albarakaturk.com.tr/ALBSecurePaymentUI/SecureProcess/SecureVerification.aspx'; yield [ 'order' => $order, 'txType' => PosInterface::TX_TYPE_PAY_AUTH, 'gatewayUrl' => $gatewayUrl, + 'card' => $card, 'expected' => [ + 'gateway' => $gatewayUrl, + 'method' => 'POST', 'inputs' => [ 'MerchantNo' => '6700950031', 'TerminalNo' => '67540050', @@ -288,8 +293,34 @@ public static function threeDFormDataTestProvider(): iterable 'UseOOS' => '0', 'Mac' => 'xuhPbpcPJ6kVs7JeIXS8f06Cv0mb9cNPMfjp1HiB7Ew=', ], - 'method' => 'POST', + ], + ]; + + yield '3d_host_order' => [ + 'order' => $order, + 'txType' => PosInterface::TX_TYPE_PAY_AUTH, + 'gatewayUrl' => $gatewayUrl, + 'card' => null, + 'expected' => [ 'gateway' => $gatewayUrl, + 'method' => 'POST', + 'inputs' => [ + 'MerchantNo' => '6700950031', + 'TerminalNo' => '67540050', + 'PosnetID' => '1010028724242434', + 'TransactionType' => 'Sale', + 'OrderId' => '0000000620093100_024', + 'Amount' => '175', + 'CurrencyCode' => 'TL', + 'MerchantReturnURL' => 'https://domain.com/success', + 'InstallmentCount' => '0', + 'Language' => 'tr', + 'TxnState' => 'INITIAL', + 'OpenNewWindow' => '0', + 'UseOOS' => '1', + 'MacParams' => 'MerchantNo:TerminalNo:Amount', + 'Mac' => 'UBdwWJh9rBCM0YWkBti7vHZm2G+nag16hAguohNrq1Y=', + ], ], ]; }