1 | <?php |
||
11 | class Tokenizer |
||
12 | { |
||
13 | /** |
||
14 | * Token type for all tokenizations requests is always CC. |
||
15 | */ |
||
16 | const TOKEN_TYPE = "CC"; |
||
17 | /** |
||
18 | * Tokenization Server URL |
||
19 | */ |
||
20 | const SERVER_URL = "https://sensei.homeaway.com/tokens"; |
||
21 | /** |
||
22 | * HAPI Secure API Key. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | private $apiKey; |
||
27 | /** |
||
28 | * HAPI Client ID. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | private $clientId; |
||
33 | /** |
||
34 | * @var GuzzleClient |
||
35 | */ |
||
36 | private $guzzleClient; |
||
37 | /** |
||
38 | * Unix Timestamp for generating the digest hash. |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | private $timestamp; |
||
43 | |||
44 | /** |
||
45 | * HAPI constructor. |
||
46 | * |
||
47 | * @param $apiKey |
||
48 | * @param $clientId |
||
49 | */ |
||
50 | 6 | public function __construct($apiKey, $clientId, GuzzleClient $guzzleClient = null) |
|
56 | |||
57 | /** |
||
58 | * @param mixed $apiKey |
||
59 | */ |
||
60 | 6 | private function setApiKey($apiKey) |
|
64 | |||
65 | /** |
||
66 | * @param mixed $clientId |
||
67 | */ |
||
68 | 6 | private function setClientId($clientId) |
|
72 | |||
73 | /** |
||
74 | * @param $creditCardNumber |
||
75 | * @throws TokenizerException |
||
76 | */ |
||
77 | 6 | public function tokenize($creditCardNumber) |
|
93 | |||
94 | 6 | private function performTokenizationRequest($creditCardNumber) |
|
119 | |||
120 | /** |
||
121 | * @return string |
||
122 | */ |
||
123 | 6 | private function generateDigest() |
|
127 | |||
128 | /** |
||
129 | * @return string |
||
130 | */ |
||
131 | 6 | private function getTimestamp() |
|
140 | } |
||
141 |