-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDirectPostStoreRequest.php
More file actions
64 lines (53 loc) · 1.47 KB
/
DirectPostStoreRequest.php
File metadata and controls
64 lines (53 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace Omnipay\NABTransact\Message;
/**
* NABTransact Direct Post Store Only Request.
*/
class DirectPostStoreRequest extends DirectPostAuthorizeRequest
{
/**
* @var string
*/
public $txnType = '8';
public function getStoreType()
{
return $this->getParameter('storeType');
}
public function setStoreType($value)
{
return $this->setParameter('storeType', $value);
}
/**
* @return array
*/
public function getData()
{
$this->validate('returnUrl', 'card');
if (!$this->getAmount()) {
$this->setAmount('0.00');
}
$data = parent::getData();
$data['EPS_STORE'] = 'true';
$data['EPS_STORETYPE'] = (string) ($this->getStoreType() ?: 'TOKEN');
$data['EPS_FINGERPRINT'] = $this->generateFingerprint($data);
return $data;
}
/**
* @param array $data
*/
public function generateFingerprint(array $data)
{
if ((string) $this->txnType !== '8' || !isset($data['EPS_STORETYPE'])) {
return parent::generateFingerprint($data);
}
$hashable = [
$data['EPS_MERCHANT'],
$this->getTransactionPassword(),
$data['EPS_TXNTYPE'],
$data['EPS_STORETYPE'],
$data['EPS_REFERENCEID'],
$data['EPS_TIMESTAMP'],
];
return hash_hmac('sha256', implode('|', $hashable), $this->getTransactionPassword());
}
}