Skip to content

Commit

Permalink
issue #157 fix tests after the PR #158
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed Oct 3, 2023
1 parent 44ea8c0 commit e0b4af8
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 41 deletions.
12 changes: 7 additions & 5 deletions examples/garanti/_payment_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ function doPayment(\Mews\Pos\PosInterface $pos, string $transaction, ?\Mews\Pos\
}

$testCards = [
// test kartlar https://dev.garantibbva.com.tr/test-kartlari
'visa1' => [
'number' => '4282209004348015',
'year' => '30',
'month' => '08',
'cvv' => '123',
// pin 147852
'number' => '5406697543211173',
'year' => '27',
'month' => '04',
'cvv' => '423',
'name' => 'John Doe',
'type' => AbstractCreditCard::CARD_TYPE_VISA,
'type' => AbstractCreditCard::CARD_TYPE_MASTERCARD,
],
];
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ parameters:

-
message: "#^Access to an undefined property object\\:\\:\\$currency\\.$#"
count: 1
count: 2
path: src/DataMapper/GarantiPosRequestDataMapper.php

-
Expand Down
12 changes: 5 additions & 7 deletions src/Gateways/GarantiPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ public function make3DPayment(Request $request)
$request = $request->request;
$bankResponse = null;

/**
* Destek gerekiyor.
*/
// if (!$this->requestDataMapper->getCrypt()->check3DHash($this->account, $request->all())) {
// // todo mdstatus 7 oldugunda hash, hashparam deger gelmiyor, check3dhash calismiyor
// throw new HashMismatchException();
// }
if (!$this->requestDataMapper->getCrypt()->check3DHash($this->account, $request->all())) {

// todo mdstatus 7 oldugunda hash, hashparam deger gelmiyor, check3dhash calismiyor
throw new HashMismatchException();
}

if (in_array($request->get('mdstatus'), [1, 2, 3, 4])) {
$this->logger->log(LogLevel::DEBUG, 'finishing payment', ['md_status' => $request->get('mdstatus')]);
Expand Down
59 changes: 47 additions & 12 deletions tests/Crypt/GarantiPosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testCreate3DHash()
'fail_url' => 'https://domain.com/fail_url',
];

$expected = '1D319D5EA945F5730FF5BCC970FF96690993F4BD';
$expected = '372D6CB20B2B699D0A6667DFF46E3AA8CF3F9D8C2BB69A7C411895151FFCFAAB5277CCFE3B3A06035FEEFBFBFD40C79DBE51DBF867D0A24B37335A28F0CEFDE2';
$actual = $this->crypt->create3DHash($this->threeDAccount, $requestData, 'sales');
$this->assertSame($expected, $actual);
}
Expand All @@ -82,20 +82,51 @@ public function threeDHashCheckDataProvider(): array
[
'expectedResult' => true,
'responseData' => [
'xid' => 'f3ec4783-f48c-475c-a59c-ab25f3170ec5',
'mdstatus' => '1',
'mderrormessage' => 'Y-status/Challenge authentication via ACS: https://gbemv3dsecure.garanti.com.tr/web/creq',
'txnstatus' => '',
'eci' => '02',
'cavv' => 'jCm0m+u/0hUfAREHBAMBcfN+pSo=',
'version' => '2.0',
'md' => 'G1YfkxEZ8Noemg4MRspO20vEiXaEk51A7ajPU4mKMSVmw34xpTV+8XSfhPw2vMA2XLuPjeXSvG00zCA+78yYbp83WAhjLy/qNPUCphGiC1db8oGIphWRRimqxZi1iCq3rYtLbz6EoZRFU18UGFUotA==',
'oid' => '20221101ACC4',
'cavv' => 'xgRlQDz4AAAAAAAAAAAAAAAAAAA=',
'paressyntaxok' => '',
'paresverified' => '',
'version' => '',
'ireqcode' => '',
'ireqdetail' => '',
'vendorcode' => '',
'cavvalgorithm' => '',
'md' => 'aW5kZXg6MDJ6LjAI5iAcKf/ilXjYIOnTh4t+deHrtwO8ze7tPTL1YCDcBe8KEpuq6HDLYbqQSluL7p3kGcpFzX9s9XcegNhHMsDszxqGd33+p+p5sULGrDF3J2GGfiJDwan4ku7+eiTyS8x2xS9pUy7PTgMGc6jw94aLfXLHskhvY7FYWrymzQ==',
'terminalid' => '30691298',
'oid' => '2023100354BB',
'authcode' => '',
'response' => '',
'errmsg' => '',
'hostmsg' => '',
'procreturncode' => '',
'rnd' => '3tfMjkdGsXQNc11PxchJ',
'hash' => 'r2KD+NS0f82pwRPekR1BTIT1mik=',
'transid' => '2023100354BB',
'hostrefnum' => '',
'rnd' => 'kW094tPzNEhqORzzCsLB',
'hash' => '416B6253425E73184F118CC02E3BAA393622059BF6B0865D83F501E55A61339B9EC659CBCF7297EDECC1B17BF6281D90CC0AD8EDF3E1EFE94432ACCEAF79B26E',
'hashparams' => 'clientid:oid:authcode:procreturncode:response:mdstatus:cavv:eci:md:rnd:',
'hashparamsval' => '3069129820221101ACC41jCm0m+u/0hUfAREHBAMBcfN+pSo=02G1YfkxEZ8Noemg4MRspO20vEiXaEk51A7ajPU4mKMSVmw34xpTV+8XSfhPw2vMA2XLuPjeXSvG00zCA+78yYbp83WAhjLy/qNPUCphGiC1db8oGIphWRRimqxZi1iCq3rYtLbz6EoZRFU18UGFUotA==3tfMjkdGsXQNc11PxchJ',
'hashparamsval' => '306912982023100354BB1xgRlQDz4AAAAAAAAAAAAAAAAAAA=02aW5kZXg6MDJ6LjAI5iAcKf/ilXjYIOnTh4t+deHrtwO8ze7tPTL1YCDcBe8KEpuq6HDLYbqQSluL7p3kGcpFzX9s9XcegNhHMsDszxqGd33+p+p5sULGrDF3J2GGfiJDwan4ku7+eiTyS8x2xS9pUy7PTgMGc6jw94aLfXLHskhvY7FYWrymzQ==kW094tPzNEhqORzzCsLB',
'clientid' => '30691298',
'MaskedPan' => '54066975****1173',
'apiversion' => '512',
'orderid' => '2023100354BB',
'txninstallmentcount' => '',
'terminaluserid' => 'PROVAUT',
'secure3dhash' => 'B0EE6F6405ABB6EF014D802880EF3DC72CEA1EFD16E7E346A4CD6F6EE6ED2148FA8DCFD703EAEA9C154C7C200CF42D00A874832D6D3F22F9447EDF241D540286',
'secure3dsecuritylevel' => '3D',
'txncurrencycode' => '949',
'customeremailaddress' => '[email protected]',
'errorurl' => 'http://localhost/garanti/3d/response.php',
'terminalmerchantid' => '7000679',
'mode' => 'TEST',
'terminalprovuserid' => 'PROVAUT',
'txnamount' => '101',
'successurl' => 'http://localhost/garanti/3d/response.php',
'txntype' => 'sales',
'customeripaddress' => '172.26.0.1',
],
],
];
Expand All @@ -108,34 +139,38 @@ public function hashCreateDataProvider(): array
'requestData' => [
'id' => 'order222',
'amount' => 10025,
'currency' => '949',
],
'txType' => 'sales',
'expected' => '00CD5B6C29D4CEA1F3002D785A9F9B09974AD51D',
'expected' => '0CFE09F107274C6A07292DA061A4EECAB0F5F0CF87F831F2D3626A3346A941126C52D1D95A3B77ADF5AC348B3D25C76BA5D8D98A29557D087D3367BFFACCD25C',
],
[
'requestData' => [
'id' => 'order222',
'amount' => 10025,
'currency' => '949',
],
'txType' => 'preauth',
'expected' => '00CD5B6C29D4CEA1F3002D785A9F9B09974AD51D',
'expected' => '0CFE09F107274C6A07292DA061A4EECAB0F5F0CF87F831F2D3626A3346A941126C52D1D95A3B77ADF5AC348B3D25C76BA5D8D98A29557D087D3367BFFACCD25C',
],
[
'requestData' => [
'id' => '4499996',
// for cancel request amount is always 100
'amount' => 100,
'currency' => '949',
],
'txType' => 'void',
'expected' => '9788649A0C3AE14C082783CEA6775E08A7EFB311',
'expected' => 'C0C88761726D1844AF49FBE756DBE4586F7339169994CF700AE50AA8EAD0C8E81F5828C3392CE39CFC3F8C976FC3E24B576F4DB55DAF2E7D3A6F6B6E5E89B189',
],
[
'requestData' => [
'id' => '4499996',
'amount' => 202,
'currency' => '949',
],
'txType' => 'refund',
'expected' => 'D7094EAF4C444AAC429FB2424BEE7FC68470E0DE',
'expected' => '0F97D922001221B9C90AA692CF5D4082FF6D3EB38BE863A47F9C08E63CD87312270D6F298E5FBBC320654861DA1C6EE826E0C83E904916351A9D3032FA426BAA',
],
];
}
Expand Down
32 changes: 16 additions & 16 deletions tests/DataMapper/GarantiPosRequestDataMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function testGet3DFormData()
$inputs = [
'secure3dsecuritylevel' => '3D',
'mode' => 'TEST',
'apiversion' => 'v0.01',
'apiversion' => '512',
'terminalprovuserid' => $account->getUsername(),
'terminaluserid' => $account->getUsername(),
'terminalmerchantid' => $account->getClientId(),
Expand All @@ -226,7 +226,7 @@ public function testGet3DFormData()
'errorurl' => $this->order['fail_url'],
'customeremailaddress' => $order->email,
'customeripaddress' => $this->order['ip'],
'secure3dhash' => '1D319D5EA945F5730FF5BCC970FF96690993F4BD',
'secure3dhash' => '372D6CB20B2B699D0A6667DFF46E3AA8CF3F9D8C2BB69A7C411895151FFCFAAB5277CCFE3B3A06035FEEFBFBFD40C79DBE51DBF867D0A24B37335A28F0CEFDE2',
'cardnumber' => $card->getNumber(),
'cardexpiredatemonth' => '01',
'cardexpiredateyear' => '22',
Expand Down Expand Up @@ -300,11 +300,11 @@ private function getSample3DPaymentRequestData(AbstractPosAccount $account, $ord
{
return [
'Mode' => 'TEST',
'Version' => 'v0.01',
'Version' => '512',
'Terminal' => [
'ProvUserID' => $account->getUsername(),
'UserID' => $account->getUsername(),
'HashData' => '00CD5B6C29D4CEA1F3002D785A9F9B09974AD51D',
'HashData' => '0CFE09F107274C6A07292DA061A4EECAB0F5F0CF87F831F2D3626A3346A941126C52D1D95A3B77ADF5AC348B3D25C76BA5D8D98A29557D087D3367BFFACCD25C',
'ID' => $account->getTerminalId(),
'MerchantID' => $account->getClientId(),
],
Expand Down Expand Up @@ -356,11 +356,11 @@ private function getSampleCancelXMLData(AbstractPosAccount $account, $order): ar
{
return [
'Mode' => 'TEST',
'Version' => 'v0.01',
'Version' => '512',
'Terminal' => [
'ProvUserID' => $account->getRefundUsername(),
'UserID' => $account->getRefundUsername(),
'HashData' => '8DD74209DEEB7D333105E1C69998A827419A3B04',
'HashData' => '35E8410A78E24949D78F5E025B5E05AF470B01385A2ECBFEE6C5B3CDACFF78011D387ECAFDCE4B8453D80D35C2F344F3DAA6F2EF9143079F64DE88401EC5E4F5',
'ID' => $account->getTerminalId(),
'MerchantID' => $account->getClientId(),
],
Expand Down Expand Up @@ -394,11 +394,11 @@ private function getSampleNonSecurePaymentRequestData(AbstractPosAccount $accoun
{
return [
'Mode' => 'TEST',
'Version' => 'v0.01',
'Version' => '512',
'Terminal' => [
'ProvUserID' => $account->getUsername(),
'UserID' => $account->getUsername(),
'HashData' => '3732634F78053D42304B0966E263629FE44E258B',
'HashData' => '2005F771B622399C0EC7B8BBBE9B5F7989B9587175239F0695C1E5D3BFAA0CF6D747A9CEE64D78B7081CB5193541AD9D129B929653E2B68BCAE6939E281D752E',
'ID' => $account->getTerminalId(),
'MerchantID' => $account->getClientId(),
],
Expand Down Expand Up @@ -449,11 +449,11 @@ private function getSampleNonSecurePaymentPostRequestData(AbstractPosAccount $ac
{
return [
'Mode' => 'TEST',
'Version' => 'v0.01',
'Version' => '512',
'Terminal' => [
'ProvUserID' => $account->getUsername(),
'UserID' => $account->getUsername(),
'HashData' => '00CD5B6C29D4CEA1F3002D785A9F9B09974AD51D',
'HashData' => '0CFE09F107274C6A07292DA061A4EECAB0F5F0CF87F831F2D3626A3346A941126C52D1D95A3B77ADF5AC348B3D25C76BA5D8D98A29557D087D3367BFFACCD25C',
'ID' => $account->getTerminalId(),
'MerchantID' => $account->getClientId(),
],
Expand Down Expand Up @@ -483,11 +483,11 @@ private function getSampleStatusRequestData(AbstractPosAccount $account, $order)
{
return [
'Mode' => 'TEST',
'Version' => 'v0.01',
'Version' => '512',
'Terminal' => [
'ProvUserID' => $account->getUsername(),
'UserID' => $account->getUsername(),
'HashData' => '8DD74209DEEB7D333105E1C69998A827419A3B04',
'HashData' => '35E8410A78E24949D78F5E025B5E05AF470B01385A2ECBFEE6C5B3CDACFF78011D387ECAFDCE4B8453D80D35C2F344F3DAA6F2EF9143079F64DE88401EC5E4F5',
'ID' => $account->getTerminalId(),
'MerchantID' => $account->getClientId(),
],
Expand Down Expand Up @@ -519,11 +519,11 @@ private function getSampleRefundXMLData(AbstractPosAccount $account, $order): ar
{
return [
'Mode' => 'TEST',
'Version' => 'v0.01',
'Version' => '512',
'Terminal' => [
'ProvUserID' => $account->getRefundUsername(),
'UserID' => $account->getRefundUsername(),
'HashData' => '01EA91D49CC3039D38894FBB6303EFDAAD7F964D',
'HashData' => 'CF49751B3B793B9E1946A08815451989D0231D68A5B495C6EABA9C400442F2E6B7DF97446CE2D3562780767E634A6ECBAA1DF69F6DF7F447884A71BDE38D12AA',
'ID' => $account->getTerminalId(),
'MerchantID' => $account->getClientId(),
],
Expand Down Expand Up @@ -556,11 +556,11 @@ private function getSampleHistoryRequestData(AbstractPosAccount $account, $order
{
return [
'Mode' => 'TEST',
'Version' => 'v0.01',
'Version' => '512',
'Terminal' => [
'ProvUserID' => $account->getUsername(),
'UserID' => $account->getUsername(),
'HashData' => '19460C02029180F8F7E19A4835D62E4118600A34',
'HashData' => '817BA6A5013BD1E75E1C2FE82AA0F2EFEF89033C31563575701BD05F3C20ADC5DD2AF65D9EF8CF81784E9DA787603E0C1321C6909BE920504BEB3A85992440F5',
'ID' => $account->getTerminalId(),
'MerchantID' => $account->getClientId(),
],
Expand Down

0 comments on commit e0b4af8

Please sign in to comment.