Skip to content

Commit 27411e0

Browse files
author
yildiray.itisgen
committed
Card expiry date format changed.
1 parent e70f6b0 commit 27411e0

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

src/Messages/AbstractRequest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,10 @@ protected function getTransactionHash(): string
247247
*/
248248
protected function getTransactionHashWithoutCardNumber(): string
249249
{
250-
return strtoupper(SHA1(sprintf('%s%s%s%s',
250+
return strtoupper(SHA1(sprintf('%s%s%s%s%s',
251251
$this->getOrderId(),
252252
$this->getTerminalId(),
253+
null,
253254
$this->getAmountInteger(),
254255
$this->getSecurityHash())));
255256
}
@@ -299,7 +300,6 @@ protected function getSalesRequestParams(): array
299300

300301
/**
301302
* @return array
302-
* @throws \Omnipay\Common\Exception\InvalidRequestException
303303
*/
304304
protected function getCompleteSalesRequestParams(): array
305305
{
@@ -373,6 +373,7 @@ protected function getAuthorizeRequestParams(): array
373373
*/
374374
protected function getSalesRequestParamsFor3d(): array
375375
{
376+
$expiryYear = \DateTime::createFromFormat('Y', $this->getCard()->getExpiryYear());
376377
$params['apiversion'] = $this->version;
377378
$params['mode'] = $this->getTestMode() ? 'TEST' : 'PROD';
378379
$params['terminalprovuserid'] = $this->getUserName();
@@ -392,8 +393,8 @@ protected function getSalesRequestParamsFor3d(): array
392393
$params['txntimestamp'] = date("d/m/Y H:i:s");
393394
$params['refreshtime'] = 5;
394395
$params['cardnumber'] = $this->getCard()->getNumber();
395-
$params['cardexpiredatemonth'] = $this->getCard()->getExpiryMonth();
396-
$params['cardexpiredateyear'] = $this->getCard()->getExpiryYear();
396+
$params['cardexpiredatemonth'] = sprintf("%02d", (string)$this->getCard()->getExpiryMonth());
397+
$params['cardexpiredateyear'] = $expiryYear->format('y');
397398
$params['cardcvv2'] = $this->getCard()->getCvv();
398399
$params['secure3dsecuritylevel'] = '3D';
399400

tests/GatewayTest.php

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,36 @@ public function setUp()
3131
$this->gateway->setPassword('123qweASD/');
3232
}
3333

34+
public function testCompletePurchase()
35+
{
36+
$this->options = [
37+
'orderId' => '98976534',
38+
'amount' => "10",
39+
'currency' => 'TRY',
40+
'cavv' => 'jCm0m+u/0hUfAREHBAMBcfN+pSo=',
41+
'eci' => '02',
42+
'xid' => 'RszfrwEYe/8xb7rnrPuh6C9pZSQ=',
43+
'md' => 'G1YfkxEZ8Noemg4MRspO20vEiXaEk51APnDVEz+WRaZCdQ8gq+3XJRSTiNWDuZUhrvpkP7r3mk+BGumU6GL2XP/NFyczbI+2dQi8uS/etyI0QcvcFd2NGhLBsDNYfOwILnzLqvoyienmWkZy1a5I/w==',
44+
'mdStatus' => '1',
45+
'clientIp' => '10.241.19.2'
46+
];
47+
48+
/** @var CompletePurchaseResponse $response */
49+
$response = $this->gateway->completePurchase($this->options)->send();
50+
$this->assertTrue($response->isSuccessful());
51+
}
3452

3553
public function testPurchase()
3654
{
3755
$this->options = [
3856
'card' => $this->getCardInfo(),
39-
'orderId' => '1085204111',
40-
'amount' => "3.50",
57+
'orderId' => '98976534',
58+
'amount' => "10",
4159
'currency' => 'TRY',
4260
'returnUrl' => "https://eticaret.garanti.com.tr/destek/postback.aspx",
4361
'cancelUrl' => "https://eticaret.garanti.com.tr/destek/postback.aspx",
4462
'installment' => "",
45-
'paymentMethod' => '',
63+
'paymentMethod' => '3d',
4664
'clientIp' => '10.241.19.2',
4765
'secureKey' => '12345678'
4866
];
@@ -53,25 +71,6 @@ public function testPurchase()
5371
}
5472

5573

56-
public function testCompletePurchase()
57-
{
58-
$this->options = [
59-
'orderId' => '424569',
60-
'amount' => "3",
61-
'currency' => 'TRY',
62-
'cavv' => 'jCm0m+u/0hUfAREHBAMBcfN+pSo=',
63-
'eci' => '02',
64-
'xid' => 'RszfrwEYe/8xb7rnrPuh6C9pZSQ=',
65-
'md' => 'SbEsOKX7ObDWDySsIxdAWk+S+OBRqtO9JhbzBb2vwcwJ7nw4PmXWPaXT2zLq3Mz4hAI7F3GTIgCh4F8EC2l0LMYOr9yaA8G0yq3hudtek3FZtMRuxD29rUwF3a10zd3fQI/tSTSHkMdiT5kjKRC4Eg==',
66-
'mdStatus' => '1',
67-
'clientIp' => '172.18.0.1'
68-
];
69-
70-
/** @var CompletePurchaseResponse $response */
71-
$response = $this->gateway->completePurchase($this->options)->send();
72-
$this->assertTrue($response->isSuccessful());
73-
}
74-
7574
public function testCapture()
7675
{
7776
$this->options = [

0 commit comments

Comments
 (0)