Skip to content

Commit 89097e3

Browse files
authored
Merge pull request #26 from sudiptpa/fix/nab-nov-2018-update
Fixing up tests, upgrading to support Nov 2018 upgrades
2 parents f88da07 + b99b25a commit 89097e3

32 files changed

+90
-138
lines changed

src/DirectPostGateway.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66

77
/**
88
* NABTransact Direct Post Gateway.
9+
*
10+
* @link https://demo.transact.nab.com.au/nabtransact/downloadDocs.nab?nav=3-4
911
*/
1012
class DirectPostGateway extends AbstractGateway
1113
{
1214
/**
13-
* @var mixed
15+
* @var bool
1416
*/
1517
public $transparentRedirect = true;
1618

@@ -29,7 +31,7 @@ public function getDefaultParameters()
2931
}
3032

3133
/**
32-
* @return mixed
34+
* @return string
3335
*/
3436
public function getMerchantId()
3537
{
@@ -38,16 +40,14 @@ public function getMerchantId()
3840

3941
/**
4042
* @param $value
41-
*
42-
* @return mixed
4343
*/
4444
public function setMerchantId($value)
4545
{
4646
return $this->setParameter('merchantId', $value);
4747
}
4848

4949
/**
50-
* @return mixed
50+
* @return string
5151
*/
5252
public function getTransactionPassword()
5353
{
@@ -56,8 +56,6 @@ public function getTransactionPassword()
5656

5757
/**
5858
* @param $value
59-
*
60-
* @return mixed
6159
*/
6260
public function setTransactionPassword($value)
6361
{
@@ -67,7 +65,7 @@ public function setTransactionPassword($value)
6765
/**
6866
* @param array $parameters
6967
*
70-
* @return mixed
68+
* @return \Omnipay\NABTransact\Message\DirectPostAuthorizeRequest
7169
*/
7270
public function authorize(array $parameters = [])
7371
{
@@ -77,7 +75,7 @@ public function authorize(array $parameters = [])
7775
/**
7876
* @param array $parameters
7977
*
80-
* @return mixed
78+
* @return \Omnipay\NABTransact\Message\DirectPostCompletePurchaseRequest
8179
*/
8280
public function completeAuthorize(array $parameters = [])
8381
{
@@ -87,7 +85,7 @@ public function completeAuthorize(array $parameters = [])
8785
/**
8886
* @param array $parameters
8987
*
90-
* @return mixed
88+
* @return \Omnipay\NABTransact\Message\DirectPostPurchaseRequest
9189
*/
9290
public function purchase(array $parameters = [])
9391
{
@@ -97,7 +95,7 @@ public function purchase(array $parameters = [])
9795
/**
9896
* @param array $parameters
9997
*
100-
* @return mixed
98+
* @return \Omnipay\NABTransact\Message\DirectPostCompletePurchaseRequest
10199
*/
102100
public function completePurchase(array $parameters = [])
103101
{

src/HostedPaymentGateway.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ class HostedPaymentGateway extends AbstractGateway
1212
/**
1313
* @param array $parameters
1414
*
15-
* @return mixed
15+
* @return \Omnipay\NABTransact\Message\HostedPaymentCompletePurchaseRequest
1616
*/
1717
public function completePurchase(array $parameters = [])
1818
{
1919
return $this->createRequest('\Omnipay\NABTransact\Message\HostedPaymentCompletePurchaseRequest', $parameters);
2020
}
2121

2222
/**
23-
* @return mixed
23+
* @return string
2424
*/
2525
public function getMerchantId()
2626
{
@@ -35,7 +35,7 @@ public function getName()
3535
/**
3636
* @param array $parameters
3737
*
38-
* @return mixed
38+
* @return \Omnipay\NABTransact\Message\HostedPaymentPurchaseRequest
3939
*/
4040
public function purchase(array $parameters = [])
4141
{
@@ -44,8 +44,6 @@ public function purchase(array $parameters = [])
4444

4545
/**
4646
* @param $value
47-
*
48-
* @return mixed
4947
*/
5048
public function setMerchantId($value)
5149
{

src/Message/AbstractRequest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
99
{
1010
/**
11-
* @var mixed
11+
* @var string
1212
*/
1313
public $testEndpoint;
1414

1515
/**
16-
* @var mixed
16+
* @var string
1717
*/
1818
public $liveEndpoint;
1919

2020
/**
21-
* @return mixed
21+
* @return string
2222
*/
2323
public function getMerchantId()
2424
{
@@ -27,16 +27,14 @@ public function getMerchantId()
2727

2828
/**
2929
* @param $value
30-
*
31-
* @return mixed
3230
*/
3331
public function setMerchantId($value)
3432
{
3533
return $this->setParameter('merchantId', $value);
3634
}
3735

3836
/**
39-
* @return mixed
37+
* @return string
4038
*/
4139
public function getTransactionPassword()
4240
{
@@ -45,16 +43,14 @@ public function getTransactionPassword()
4543

4644
/**
4745
* @param $value
48-
*
49-
* @return mixed
5046
*/
5147
public function setTransactionPassword($value)
5248
{
5349
return $this->setParameter('transactionPassword', $value);
5450
}
5551

5652
/**
57-
* @return mixed
53+
* @return string
5854
*/
5955
public function getEndpoint()
6056
{

src/Message/DirectPostAbstractRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public function generateFingerprint(array $data)
3131
$data['EPS_TIMESTAMP'],
3232
]);
3333

34-
return sha1($hash);
34+
return hash_hmac('sha256', $hash, true);
3535
}
3636

3737
/**
38-
* @return mixed
38+
* @return array
3939
*/
4040
public function getBaseData()
4141
{

src/Message/DirectPostAuthorizeRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class DirectPostAuthorizeRequest extends DirectPostAbstractRequest
1313
public $txnType = '1';
1414

1515
/**
16-
* @return mixed
16+
* @return array
1717
*/
1818
public function getData()
1919
{
@@ -29,15 +29,15 @@ public function getData()
2929
/**
3030
* @param $data
3131
*
32-
* @return mixed
32+
* @return \Omnipay\NABTransact\Message\DirectPostAuthorizeResponse
3333
*/
3434
public function sendData($data)
3535
{
3636
return $this->response = new DirectPostAuthorizeResponse($this, $data, $this->getEndpoint());
3737
}
3838

3939
/**
40-
* @return mixed
40+
* @return array
4141
*/
4242
protected function getCardData()
4343
{

src/Message/DirectPostAuthorizeResponse.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class DirectPostAuthorizeResponse extends AbstractResponse implements RedirectResponseInterface
1313
{
1414
/**
15-
* @var mixed
15+
* @var string
1616
*/
1717
protected $redirectUrl;
1818

@@ -39,7 +39,7 @@ public function isRedirect()
3939
}
4040

4141
/**
42-
* @return mixed
42+
* @return string
4343
*/
4444
public function getRedirectUrl()
4545
{
@@ -52,7 +52,7 @@ public function getRedirectMethod()
5252
}
5353

5454
/**
55-
* @return mixed
55+
* @return array
5656
*/
5757
public function getRedirectData()
5858
{

src/Message/DirectPostCompletePurchaseRequest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class DirectPostCompletePurchaseRequest extends DirectPostAbstractRequest
1111
{
1212
/**
13-
* @return mixed
13+
* @return array|Exception
1414
*/
1515
public function getData()
1616
{
@@ -28,7 +28,7 @@ public function getData()
2828
*/
2929
public function generateResponseFingerprint($data)
3030
{
31-
$fields = implode('|', [
31+
$hash = implode('|', [
3232
$data['merchant'],
3333
$this->getTransactionPassword(),
3434
$data['refid'],
@@ -37,13 +37,13 @@ public function generateResponseFingerprint($data)
3737
$data['summarycode'],
3838
]);
3939

40-
return sha1($fields);
40+
return hash_hmac('sha256', $hash, true);
4141
}
4242

4343
/**
4444
* @param $data
4545
*
46-
* @return mixed
46+
* @return \Omnipay\NABTransact\Message\DirectPostCompletePurchaseResponse
4747
*/
4848
public function sendData($data)
4949
{

src/Message/DirectPostCompletePurchaseResponse.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class DirectPostCompletePurchaseResponse extends AbstractResponse
1111
{
1212
/**
13-
* @return mixed
13+
* @return bool
1414
*/
1515
public function isSuccessful()
1616
{
@@ -23,7 +23,7 @@ public function summaryCode()
2323
}
2424

2525
/**
26-
* @return mixed
26+
* @return string
2727
*/
2828
public function getMessage()
2929
{
@@ -33,7 +33,7 @@ public function getMessage()
3333
}
3434

3535
/**
36-
* @return mixed
36+
* @return string
3737
*/
3838
public function getCode()
3939
{
@@ -43,7 +43,7 @@ public function getCode()
4343
}
4444

4545
/**
46-
* @return mixed
46+
* @return string
4747
*/
4848
public function getTransactionReference()
4949
{

src/Message/HostedPaymentPurchaseRequest.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class HostedPaymentPurchaseRequest extends AbstractRequest
1818
public $testEndpoint = 'https://transact.nab.com.au/live/hpp/payment';
1919

2020
/**
21-
* @return mixed
21+
* @return array
2222
*/
2323
public function getData()
2424
{
@@ -45,23 +45,23 @@ public function getData()
4545
}
4646

4747
/**
48-
* @return mixed
48+
* @return string
4949
*/
5050
public function getMerchantId()
5151
{
5252
return $this->getParameter('merchantId');
5353
}
5454

5555
/**
56-
* @return mixed
56+
* @return string
5757
*/
5858
public function getPaymentAlertEmail()
5959
{
6060
return $this->getParameter('paymentAlertEmail');
6161
}
6262

6363
/**
64-
* @return mixed
64+
* @return string
6565
*/
6666
public function getReturnUrlText()
6767
{
@@ -70,8 +70,6 @@ public function getReturnUrlText()
7070

7171
/**
7272
* @param $data
73-
*
74-
* @return mixed
7573
*/
7674
public function sendData($data)
7775
{
@@ -80,8 +78,6 @@ public function sendData($data)
8078

8179
/**
8280
* @param $value
83-
*
84-
* @return mixed
8581
*/
8682
public function setPaymentAlertEmail($value)
8783
{
@@ -90,8 +86,6 @@ public function setPaymentAlertEmail($value)
9086

9187
/**
9288
* @param $value
93-
*
94-
* @return mixed
9589
*/
9690
public function setReturnUrlText($value)
9791
{

0 commit comments

Comments
 (0)