public function PayPalCheckoutClient::getAccessToken in Commerce PayPal 7.2
Returns the access token stored locally if any, or get one from PayPal.
Return value
string The Oauth2 access token.
Throws
PayPalCheckoutAuthenticationException
1 call to PayPalCheckoutClient::getAccessToken()
- PayPalCheckoutClient::submitRequest in modules/
checkout/ lib/ PayPalCheckoutClient.php - Submits an API request to the PayPal server.
File
- modules/
checkout/ lib/ PayPalCheckoutClient.php, line 158 - Defines a class for consuming the PayPal Checkout API.
Class
- PayPalCheckoutClient
- Defines the PayPalCheckoutClient class.
Code
public function getAccessToken() {
$access_token = variable_get('commerce_paypal_checkout_access_token', array());
if (!empty($access_token['token']) && $access_token['expires'] > time()) {
return $access_token['token'];
}
$response = $this
->acquireAccessToken();
variable_set('commerce_paypal_checkout_access_token', array(
'token' => $response['access_token'],
'expires' => time() + $response['expires_in'],
));
return $response['access_token'];
}