forked from LiveCarta/PayPal-PHP-SDK
Enabled Caching of Access Tokens
- Updated AuthTokenCredential to store access token in file storage - Updated samples to include the configuration to disable/enable caching
This commit is contained in:
@@ -40,6 +40,14 @@ return $apiContext;
|
||||
*/
|
||||
function getApiContext($clientId, $clientSecret)
|
||||
{
|
||||
// Register the sdk_config.ini file in current directory
|
||||
// as the configuration source.
|
||||
/*
|
||||
if(!defined("PP_CONFIG_PATH")) {
|
||||
define("PP_CONFIG_PATH", __DIR__);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// ### Api context
|
||||
// Use an ApiContext object to authenticate
|
||||
@@ -60,7 +68,6 @@ function getApiContext($clientId, $clientSecret)
|
||||
// Comment this line out and uncomment the PP_CONFIG_PATH
|
||||
// 'define' block if you want to use static file
|
||||
// based configuration
|
||||
|
||||
$apiContext->setConfig(
|
||||
array(
|
||||
'mode' => 'sandbox',
|
||||
@@ -68,17 +75,10 @@ function getApiContext($clientId, $clientSecret)
|
||||
'log.LogEnabled' => true,
|
||||
'log.FileName' => '../PayPal.log',
|
||||
'log.LogLevel' => 'FINE',
|
||||
'validation.level' => 'log'
|
||||
'validation.level' => 'log',
|
||||
'cache.enabled' => 'true'
|
||||
)
|
||||
);
|
||||
|
||||
/*
|
||||
// Register the sdk_config.ini file in current directory
|
||||
// as the configuration source.
|
||||
if(!defined("PP_CONFIG_PATH")) {
|
||||
define("PP_CONFIG_PATH", __DIR__);
|
||||
}
|
||||
*/
|
||||
|
||||
return $apiContext;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
;## This is an example configuration file for the SDK.
|
||||
;## The sample scripts configure the SDK dynamically
|
||||
;## but you can choose to go for file based configuration
|
||||
;## in simpler apps (See bootstrap.php for more).
|
||||
[Account]
|
||||
acct1.ClientId = AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS
|
||||
acct1.ClientSecret = EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL
|
||||
|
||||
## This is an example configuration file for the SDK.
|
||||
## The sample scripts configure the SDK dynamically
|
||||
## but you can choose to go for file based configuration
|
||||
## in simpler apps (See bootstrap.php for more).
|
||||
|
||||
|
||||
;Connection Information
|
||||
[Http]
|
||||
http.ConnectionTimeOut = 30
|
||||
@@ -16,11 +14,11 @@ http.Retry = 1
|
||||
|
||||
;Service Configuration
|
||||
[Service]
|
||||
mode=sandbox ; can be set to sandbox / live
|
||||
; can be set to sandbox / live
|
||||
mode = sandbox
|
||||
|
||||
;Logging Information
|
||||
[Log]
|
||||
|
||||
log.LogEnabled=true
|
||||
|
||||
; When using a relative path, the log file is created
|
||||
@@ -42,4 +40,16 @@ log.LogLevel=FINE
|
||||
; 'log' : logs the error message to logger only (default)
|
||||
; 'strict' : throws a php notice message
|
||||
; 'disable' : disable the validation
|
||||
validation.level=strict
|
||||
validation.level=log
|
||||
|
||||
;Caching Configuration
|
||||
[cache]
|
||||
; If Cache is enabled, it stores the access token retrieved from ClientId and Secret from the
|
||||
; server into a file provided in constant $CACHE_PATH in PayPal/Cache/AuthorizationCache.
|
||||
; If the value is set to 'true', it would try to create a file and store the information.
|
||||
; For any other value, it would disable it
|
||||
; Please note, this is a very good performance improvement, and we would encourage you to
|
||||
; set this up properly to reduce the number of calls, to almost 50% on normal use cases
|
||||
; PLEASE NOTE: You may need to provide proper write permissions to /var directory under PayPal-PHP-SDK on
|
||||
; your hosting server
|
||||
cache.enabled=true
|
||||
|
||||
Reference in New Issue
Block a user