Conditions | 3 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
18 | public function getDataClientToken(string $clientId) |
||
19 | { |
||
20 | try { |
||
21 | $accessToken = $this->getAccessToken(); |
||
22 | $response = $this->paypalApiCall( |
||
23 | $accessToken, |
||
|
|||
24 | json_encode(["customer_id" => $clientId]), |
||
25 | "https://api-m.sandbox.paypal.com/v1/identity/generate-token", |
||
26 | [], |
||
27 | 'POST' |
||
28 | ); |
||
29 | } catch (Exception $e) { |
||
30 | $this->logger->error('Error on PayPal::getDataClientToken = ' . $e->getMessage()); |
||
31 | return null; |
||
32 | } |
||
33 | $result = json_decode($response['result'], true); |
||
34 | |||
35 | if (array_key_exists('client_token', $result)) { |
||
36 | return $result['client_token']; |
||
37 | } |
||
38 | return null; |
||
39 | } |
||
41 |