Skip to content

Commit

Permalink
Merge pull request #26 from sudiptpa/fix/nab-nov-2018-update
Browse files Browse the repository at this point in the history
Fixing up tests, upgrading to support Nov 2018 upgrades
  • Loading branch information
sudiptpa authored Feb 15, 2019
2 parents f88da07 + b99b25a commit 89097e3
Show file tree
Hide file tree
Showing 32 changed files with 90 additions and 138 deletions.
20 changes: 9 additions & 11 deletions src/DirectPostGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

/**
* NABTransact Direct Post Gateway.
*
* @link https://demo.transact.nab.com.au/nabtransact/downloadDocs.nab?nav=3-4
*/
class DirectPostGateway extends AbstractGateway
{
/**
* @var mixed
* @var bool
*/
public $transparentRedirect = true;

Expand All @@ -29,7 +31,7 @@ public function getDefaultParameters()
}

/**
* @return mixed
* @return string
*/
public function getMerchantId()
{
Expand All @@ -38,16 +40,14 @@ public function getMerchantId()

/**
* @param $value
*
* @return mixed
*/
public function setMerchantId($value)
{
return $this->setParameter('merchantId', $value);
}

/**
* @return mixed
* @return string
*/
public function getTransactionPassword()
{
Expand All @@ -56,8 +56,6 @@ public function getTransactionPassword()

/**
* @param $value
*
* @return mixed
*/
public function setTransactionPassword($value)
{
Expand All @@ -67,7 +65,7 @@ public function setTransactionPassword($value)
/**
* @param array $parameters
*
* @return mixed
* @return \Omnipay\NABTransact\Message\DirectPostAuthorizeRequest
*/
public function authorize(array $parameters = [])
{
Expand All @@ -77,7 +75,7 @@ public function authorize(array $parameters = [])
/**
* @param array $parameters
*
* @return mixed
* @return \Omnipay\NABTransact\Message\DirectPostCompletePurchaseRequest
*/
public function completeAuthorize(array $parameters = [])
{
Expand All @@ -87,7 +85,7 @@ public function completeAuthorize(array $parameters = [])
/**
* @param array $parameters
*
* @return mixed
* @return \Omnipay\NABTransact\Message\DirectPostPurchaseRequest
*/
public function purchase(array $parameters = [])
{
Expand All @@ -97,7 +95,7 @@ public function purchase(array $parameters = [])
/**
* @param array $parameters
*
* @return mixed
* @return \Omnipay\NABTransact\Message\DirectPostCompletePurchaseRequest
*/
public function completePurchase(array $parameters = [])
{
Expand Down
8 changes: 3 additions & 5 deletions src/HostedPaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class HostedPaymentGateway extends AbstractGateway
/**
* @param array $parameters
*
* @return mixed
* @return \Omnipay\NABTransact\Message\HostedPaymentCompletePurchaseRequest
*/
public function completePurchase(array $parameters = [])
{
return $this->createRequest('\Omnipay\NABTransact\Message\HostedPaymentCompletePurchaseRequest', $parameters);
}

/**
* @return mixed
* @return string
*/
public function getMerchantId()
{
Expand All @@ -35,7 +35,7 @@ public function getName()
/**
* @param array $parameters
*
* @return mixed
* @return \Omnipay\NABTransact\Message\HostedPaymentPurchaseRequest
*/
public function purchase(array $parameters = [])
{
Expand All @@ -44,8 +44,6 @@ public function purchase(array $parameters = [])

/**
* @param $value
*
* @return mixed
*/
public function setMerchantId($value)
{
Expand Down
14 changes: 5 additions & 9 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
{
/**
* @var mixed
* @var string
*/
public $testEndpoint;

/**
* @var mixed
* @var string
*/
public $liveEndpoint;

/**
* @return mixed
* @return string
*/
public function getMerchantId()
{
Expand All @@ -27,16 +27,14 @@ public function getMerchantId()

/**
* @param $value
*
* @return mixed
*/
public function setMerchantId($value)
{
return $this->setParameter('merchantId', $value);
}

/**
* @return mixed
* @return string
*/
public function getTransactionPassword()
{
Expand All @@ -45,16 +43,14 @@ public function getTransactionPassword()

/**
* @param $value
*
* @return mixed
*/
public function setTransactionPassword($value)
{
return $this->setParameter('transactionPassword', $value);
}

/**
* @return mixed
* @return string
*/
public function getEndpoint()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Message/DirectPostAbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public function generateFingerprint(array $data)
$data['EPS_TIMESTAMP'],
]);

return sha1($hash);
return hash_hmac('sha256', $hash, true);
}

/**
* @return mixed
* @return array
*/
public function getBaseData()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Message/DirectPostAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DirectPostAuthorizeRequest extends DirectPostAbstractRequest
public $txnType = '1';

/**
* @return mixed
* @return array
*/
public function getData()
{
Expand All @@ -29,15 +29,15 @@ public function getData()
/**
* @param $data
*
* @return mixed
* @return \Omnipay\NABTransact\Message\DirectPostAuthorizeResponse
*/
public function sendData($data)
{
return $this->response = new DirectPostAuthorizeResponse($this, $data, $this->getEndpoint());
}

/**
* @return mixed
* @return array
*/
protected function getCardData()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Message/DirectPostAuthorizeResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class DirectPostAuthorizeResponse extends AbstractResponse implements RedirectResponseInterface
{
/**
* @var mixed
* @var string
*/
protected $redirectUrl;

Expand All @@ -39,7 +39,7 @@ public function isRedirect()
}

/**
* @return mixed
* @return string
*/
public function getRedirectUrl()
{
Expand All @@ -52,7 +52,7 @@ public function getRedirectMethod()
}

/**
* @return mixed
* @return array
*/
public function getRedirectData()
{
Expand Down
8 changes: 4 additions & 4 deletions src/Message/DirectPostCompletePurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class DirectPostCompletePurchaseRequest extends DirectPostAbstractRequest
{
/**
* @return mixed
* @return array|Exception
*/
public function getData()
{
Expand All @@ -28,7 +28,7 @@ public function getData()
*/
public function generateResponseFingerprint($data)
{
$fields = implode('|', [
$hash = implode('|', [
$data['merchant'],
$this->getTransactionPassword(),
$data['refid'],
Expand All @@ -37,13 +37,13 @@ public function generateResponseFingerprint($data)
$data['summarycode'],
]);

return sha1($fields);
return hash_hmac('sha256', $hash, true);
}

/**
* @param $data
*
* @return mixed
* @return \Omnipay\NABTransact\Message\DirectPostCompletePurchaseResponse
*/
public function sendData($data)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Message/DirectPostCompletePurchaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class DirectPostCompletePurchaseResponse extends AbstractResponse
{
/**
* @return mixed
* @return bool
*/
public function isSuccessful()
{
Expand All @@ -23,7 +23,7 @@ public function summaryCode()
}

/**
* @return mixed
* @return string
*/
public function getMessage()
{
Expand All @@ -33,7 +33,7 @@ public function getMessage()
}

/**
* @return mixed
* @return string
*/
public function getCode()
{
Expand All @@ -43,7 +43,7 @@ public function getCode()
}

/**
* @return mixed
* @return string
*/
public function getTransactionReference()
{
Expand Down
14 changes: 4 additions & 10 deletions src/Message/HostedPaymentPurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class HostedPaymentPurchaseRequest extends AbstractRequest
public $testEndpoint = 'https://transact.nab.com.au/live/hpp/payment';

/**
* @return mixed
* @return array
*/
public function getData()
{
Expand All @@ -45,23 +45,23 @@ public function getData()
}

/**
* @return mixed
* @return string
*/
public function getMerchantId()
{
return $this->getParameter('merchantId');
}

/**
* @return mixed
* @return string
*/
public function getPaymentAlertEmail()
{
return $this->getParameter('paymentAlertEmail');
}

/**
* @return mixed
* @return string
*/
public function getReturnUrlText()
{
Expand All @@ -70,8 +70,6 @@ public function getReturnUrlText()

/**
* @param $data
*
* @return mixed
*/
public function sendData($data)
{
Expand All @@ -80,8 +78,6 @@ public function sendData($data)

/**
* @param $value
*
* @return mixed
*/
public function setPaymentAlertEmail($value)
{
Expand All @@ -90,8 +86,6 @@ public function setPaymentAlertEmail($value)

/**
* @param $value
*
* @return mixed
*/
public function setReturnUrlText($value)
{
Expand Down
Loading

0 comments on commit 89097e3

Please sign in to comment.