1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\CapitaPay360\Message; |
4
|
|
|
|
5
|
|
|
use SoapClient; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* CapitaPay360 Complete Purchase Request |
9
|
|
|
*/ |
10
|
|
|
class CompletePurchaseRequest extends PurchaseRequest |
11
|
|
|
{ |
12
|
2 |
|
public function getData() |
13
|
|
|
{ |
14
|
2 |
|
$timeStamp = gmdate("YmdHis"); |
15
|
2 |
|
$uniqueReference = uniqid('PB'); |
16
|
2 |
|
$subjectType = 'CapitaPortal'; |
17
|
2 |
|
$algorithm = 'Original'; |
18
|
2 |
|
$credentialsToHash = implode('!', array( |
19
|
2 |
|
$subjectType, |
20
|
2 |
|
$this->getScpId(), |
21
|
2 |
|
$uniqueReference, |
22
|
2 |
|
$timeStamp, |
23
|
2 |
|
$algorithm, |
24
|
2 |
|
$this->getHmacKeyId() |
25
|
|
|
)); |
26
|
2 |
|
$key = base64_decode($this->getHmacKey()); |
27
|
2 |
|
$hash = hash_hmac('sha256', $credentialsToHash, $key, true); |
28
|
2 |
|
$digest = base64_encode($hash); |
29
|
|
|
|
30
|
|
|
$data = array( |
31
|
|
|
'credentials' => array( |
32
|
|
|
'subject' => array( |
33
|
2 |
|
'subjectType' => $subjectType, |
34
|
2 |
|
'identifier' => $this->getScpId(), |
35
|
2 |
|
'systemCode' => 'SCP' |
36
|
|
|
), |
37
|
|
|
'requestIdentification' => array( |
38
|
2 |
|
'uniqueReference' => $uniqueReference, |
39
|
2 |
|
'timeStamp' => $timeStamp |
40
|
|
|
), |
41
|
|
|
'signature' => array( |
42
|
2 |
|
'algorithm' => $algorithm, |
43
|
2 |
|
'hmacKeyID' => $this->getHmacKeyId(), |
44
|
2 |
|
'digest' => $digest |
45
|
|
|
) |
46
|
|
|
), |
47
|
2 |
|
'siteId' => $this->getSiteId(), |
48
|
2 |
|
'scpReference' => $this->getTransactionReference() |
49
|
|
|
); |
50
|
2 |
|
return $data; |
51
|
|
|
} |
52
|
|
|
|
53
|
1 |
|
public function sendData($data) |
54
|
|
|
{ |
55
|
1 |
|
$response_data = $this->getSoapClient()->scpSimpleQuery($data); |
56
|
1 |
|
return $this->response = new CompletePurchaseResponse($this, $response_data); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|