Skip to content

Commit c3f0c8b

Browse files
author
Can Sözeri
committed
refactor
1 parent 74559b9 commit c3f0c8b

11 files changed

+49
-42
lines changed

composer.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,5 @@
2020
"omnipay/tests": "^3",
2121
"squizlabs/php_codesniffer": "^3"
2222
},
23-
"extra": {
24-
"branch-alias": {
25-
"dev-master": "3.0.x-dev"
26-
}
27-
},
2823
"prefer-stable": true
2924
}

src/Gateway.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Omnipay\Gvp\Messages\CompletePurchaseRequest;
1414
use Omnipay\Gvp\Messages\PurchaseRequest;
1515

16-
1716
/**
1817
* @method \Omnipay\Common\Message\NotificationInterface acceptNotification(array $options = array())
1918
* @method \Omnipay\Common\Message\RequestInterface completeAuthorize(array $options = array())
@@ -71,6 +70,40 @@ public function setTerminalId(string $value): Gateway
7170
return $this->setParameter('terminalId', $value);
7271
}
7372

73+
/**
74+
* @return string
75+
*/
76+
public function getUserName(): string
77+
{
78+
return $this->getParameter('username');
79+
}
80+
81+
/**
82+
* @param string $value
83+
* @return Gateway
84+
*/
85+
public function setUserName(string $value): Gateway
86+
{
87+
return $this->setParameter('username', $value);
88+
}
89+
90+
/**
91+
* @return string
92+
*/
93+
public function getPassword(): string
94+
{
95+
return $this->getParameter('password');
96+
}
97+
98+
/**
99+
* @param string $value
100+
* @return Gateway
101+
*/
102+
public function setPassword(string $value): Gateway
103+
{
104+
return $this->setParameter('password', $value);
105+
}
106+
74107
/**
75108
* @param array $parameters
76109
* @return AbstractRequest|RequestInterface

src/Messages/AbstractRequest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
4141
*/
4242
public function getEndpoint(): string
4343
{
44-
$paymentType = $this->getPaymentType() == '3d' ? '3d' : 'direct';
44+
$paymentType = $this->getPaymentType() === '3d' ? '3d' : 'direct';
4545

4646
return $this->getTestMode() ? $this->endpoints[$paymentType]["test"] : $this->endpoints[$paymentType]["prod"];
4747
}
@@ -140,12 +140,12 @@ public function setPaymentType(string $value = ""): AbstractRequest
140140
public function sendData($data)
141141
{
142142
try {
143-
if ($this->getPaymentType() == '3d') {
143+
if ($this->getPaymentType() === '3d') {
144144
$body = http_build_query($data, '', '&');
145145
} else {
146146
$document = new \DOMDocument('1.0', 'UTF-8');
147147
$root = $document->createElement('GVPSRequest');
148-
$xml = function ($root, $data) use ($document, &$xml) {
148+
$xml = static function ($root, $data) use ($document, &$xml) {
149149
foreach ($data as $key => $value) {
150150
if (is_array($value)) {
151151
$subs = $document->createElement($key);
@@ -377,7 +377,6 @@ protected function getSalesRequestParamsFor3d(): array
377377
$params['cardnumber'] = $this->getCard()->getNumber();
378378
$params['cardexpiredatemonth'] = $this->getCard()->getExpiryMonth();
379379
$params['cardexpiredateyear'] = $this->getCard()->getExpiryYear();
380-
$params['cardexpiredateyear'] = $this->getCard()->getExpiryYear();
381380
$params['cardcvv2'] = $this->getCard()->getCvv();
382381
$params['secure3dsecuritylevel'] = '3D';
383382

src/Messages/AbstractResponse.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
use Omnipay\Common\Message\RequestInterface;
99

10-
class AbstractResponse extends \Omnipay\Common\Message\AbstractResponse
10+
abstract class AbstractResponse extends \Omnipay\Common\Message\AbstractResponse
1111
{
1212
public function __construct(RequestInterface $request, $data)
1313
{
@@ -29,7 +29,7 @@ public function getMessage(): string
2929

3030
public function getCode(): ?string
3131
{
32-
return (string)$this->data["Transaction"]->Response->Code ?? null;
32+
return (string)($this->data["Transaction"]->Response->Code ?? null);
3333
}
3434

3535
/**
@@ -46,14 +46,4 @@ public function setData(string $data): array
4646

4747
return $this->data = $content;
4848
}
49-
50-
/**
51-
* Is the response successful?
52-
*
53-
* @return bool
54-
*/
55-
public function isSuccessful()
56-
{
57-
58-
}
5949
}

src/Messages/AuthorizeRequest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55

66
namespace Omnipay\Gvp\Messages;
77

8-
use Exception;
9-
use Omnipay\Common\Exception\InvalidResponseException;
10-
use Omnipay\Common\Message\ResponseInterface;
11-
128
class AuthorizeRequest extends AbstractRequest
139
{
1410
/**

src/Messages/AuthorizeResponse.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55

66
namespace Omnipay\Gvp\Messages;
77

8-
98
class AuthorizeResponse extends AbstractResponse
109
{
11-
1210
/**
1311
* @return boolean
1412
*/
1513
public function isSuccessful(): bool
1614
{
17-
return isset($this->data["Transaction"]) ? $this->data["Transaction"]->Response->Code == '00' : false;
15+
return isset($this->data["Transaction"]) ? $this->data["Transaction"]->Response->Code === '00' : false;
1816
}
1917
}

src/Messages/CaptureRequest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55

66
namespace Omnipay\Gvp\Messages;
77

8-
98
class CaptureRequest extends AbstractRequest
109
{
11-
1210
/**
1311
* @return array
1412
*/

src/Messages/CaptureResponse.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77

88
class CaptureResponse extends AbstractResponse
99
{
10-
1110
/**
1211
* @return boolean
1312
*/
1413
public function isSuccessful(): bool
1514
{
16-
return isset($this->data["Transaction"]) ? $this->data["Transaction"]->Response->Code == '00' : false;
15+
return isset($this->data["Transaction"]) ? $this->data["Transaction"]->Response->Code === '00' : false;
1716
}
1817
}

src/Messages/CompletePurchaseRequest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ public function getData()
1818
{
1919
$this->setPaymentType();
2020

21-
if (!in_array($this->getMd(), array(1, 2, 3, 4))) {
21+
if (!in_array($this->getMd(), array(1, 2, 3, 4), false)) {
2222
throw new RuntimeException('3DSecure verification error');
2323
}
2424

2525
$data = $this->getSalesRequestParams();
2626
$data['Transaction']['CardholderPresentCode'] = "13";
2727
$secure3d = [
28-
"AuthenticationCode" => $this->getCavv(),
28+
"AuthenticationCode" => $this->getCvv(),
2929
"SecurityLevel" => $this->getEci(),
3030
"TxnID" => $this->getXid(),
3131
"Md" => $this->getMd(),
@@ -38,18 +38,18 @@ public function getData()
3838
/**
3939
* @return string
4040
*/
41-
public function getCavv(): string
41+
public function getCvv(): string
4242
{
43-
return $this->getParameter('cavv');
43+
return $this->getParameter('cvv');
4444
}
4545

4646
/**
4747
* @param string $value
4848
* @return CompletePurchaseRequest
4949
*/
50-
public function setCavv(string $value): CompletePurchaseRequest
50+
public function setCvv(string $value): CompletePurchaseRequest
5151
{
52-
return $this->setParameter('cavv', $value);
52+
return $this->setParameter('cvv', $value);
5353
}
5454

5555
/**

src/Messages/CompletePurchaseResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ class CompletePurchaseResponse extends AbstractResponse
1212
*/
1313
public function isSuccessful(): bool
1414
{
15-
return isset($this->data["Transaction"]) ? $this->data["Transaction"]->Response->Code == '00' : false;
15+
return isset($this->data["Transaction"]) ? $this->data["Transaction"]->Response->Code === '00' : false;
1616
}
1717
}

0 commit comments

Comments
 (0)