@@ 212-227 (lines=16) @@ | ||
209 | * @throws Exception\JSON |
|
210 | * @return string Token |
|
211 | */ |
|
212 | protected function token_encode($payload) |
|
213 | { |
|
214 | Log::instance()->debug('encode payload:'); |
|
215 | Log::instance()->debug(print_r($payload, true)); |
|
216 | try |
|
217 | { |
|
218 | $token = JWT::encode($payload, $this->own_private_key(), 'RS512'); |
|
219 | } |
|
220 | catch (\Exception $e) |
|
221 | { |
|
222 | Log::instance()->error($e->getMessage().PHP_EOL.$e->getTraceAsString()); |
|
223 | throw new Exception\JSON('unable to create JWT token', $e); |
|
224 | } |
|
225 | ||
226 | return $token; |
|
227 | } |
|
228 | ||
229 | /** |
|
230 | * Send request to UAPAY |
@@ 137-153 (lines=17) @@ | ||
134 | * @throws Exception\Runtime |
|
135 | * @return array |
|
136 | */ |
|
137 | protected function token_decode($token) |
|
138 | { |
|
139 | try |
|
140 | { |
|
141 | $decoded = (array) JWT::decode($token, $this->uapay_public_key(), array('RS512')); |
|
142 | } |
|
143 | catch (\Exception $e) |
|
144 | { |
|
145 | Log::instance()->error($e->getMessage().PHP_EOL.$e->getTraceAsString()); |
|
146 | throw new Exception\JSON('unable to decode JWT token', $e); |
|
147 | } |
|
148 | ||
149 | Log::instance()->debug('decoded payload:'); |
|
150 | Log::instance()->debug(print_r($decoded, true)); |
|
151 | ||
152 | return $decoded; |
|
153 | } |
|
154 | ||
155 | /** |
|
156 | * Get status code |