Skip to content

Commit

Permalink
posnetv1 - fix undefined index when creating 3d host form data
Browse files Browse the repository at this point in the history
  • Loading branch information
mustapayev committed Sep 7, 2024
1 parent 9df0a70 commit 5011dd4
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
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 @@ -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())
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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',
Expand All @@ -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=',
],
],
];
}
Expand Down

0 comments on commit 5011dd4

Please sign in to comment.