forked from LiveCarta/PayPal-PHP-SDK
Updating samples to use dynamic SDK configuration
This commit is contained in:
@@ -1,40 +1,51 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sample bootstrap file.
|
* Sample bootstrap file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Include the composer autoloader
|
// Include the composer autoloader
|
||||||
if(!file_exists(__DIR__ .'/vendor/autoload.php')) {
|
if(!file_exists(__DIR__ .'/vendor/autoload.php')) {
|
||||||
echo "The 'vendor' folder is missing. You must run 'composer update --no-dev' to resolve application dependencies.\nPlease see the README for more information.\n";
|
echo "The 'vendor' folder is missing. You must run 'composer update --no-dev' to resolve application dependencies.\nPlease see the README for more information.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
require __DIR__ . '/vendor/autoload.php';
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
require __DIR__ . '/common.php';
|
require __DIR__ . '/common.php';
|
||||||
|
|
||||||
define("PP_CONFIG_PATH", __DIR__);
|
|
||||||
|
|
||||||
use PayPal\Rest\ApiContext;
|
use PayPal\Rest\ApiContext;
|
||||||
use PayPal\Auth\OAuthTokenCredential;
|
use PayPal\Auth\OAuthTokenCredential;
|
||||||
|
|
||||||
// ### Api Context
|
|
||||||
// Pass in a `PayPal\Rest\ApiContext` object to authenticate
|
|
||||||
// the call. You can also send a unique request id
|
|
||||||
// (that ensures idempotency). The SDK generates
|
|
||||||
// a request id if you do not pass one explicitly.
|
|
||||||
$apiContext = new ApiContext(new OAuthTokenCredential(
|
|
||||||
'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM',
|
|
||||||
'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM'));
|
|
||||||
|
|
||||||
// Uncomment this step if you want to use per request
|
|
||||||
// dynamic configuration instead of using sdk_config.ini
|
|
||||||
/*
|
|
||||||
$apiContext->setConfig(array(
|
|
||||||
'mode' => 'sandbox',
|
|
||||||
'http.ConnectionTimeOut' => 30,
|
|
||||||
'log.LogEnabled' => true,
|
|
||||||
'log.FileName' => '../PayPal.log',
|
|
||||||
'log.LogLevel' => 'FINE'
|
|
||||||
));
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
// ### Api context
|
||||||
|
// Pass in a `PayPal\Rest\ApiContext` object to authenticate
|
||||||
|
// API calls. The clientId and clientSecret for the
|
||||||
|
// OAuthTokenCredential class can be retrieved from
|
||||||
|
// developer.paypal.com
|
||||||
|
|
||||||
|
$apiContext = new ApiContext(
|
||||||
|
new OAuthTokenCredential(
|
||||||
|
'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM',
|
||||||
|
'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// #### SDK configuration
|
||||||
|
// Comment this line out and uncomment the PP_CONFIG_PATH
|
||||||
|
// 'define' if you want to use a static file based configuration
|
||||||
|
|
||||||
|
$apiContext->setConfig(
|
||||||
|
array(
|
||||||
|
'mode' => 'sandbox',
|
||||||
|
'http.ConnectionTimeOut' => 30,
|
||||||
|
'log.LogEnabled' => true,
|
||||||
|
'log.FileName' => '../PayPal.log',
|
||||||
|
'log.LogLevel' => 'FINE'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
// Register the sdk_config.ini file in current directory
|
||||||
|
// as the configuration source.
|
||||||
|
// define("PP_CONFIG_PATH", __DIR__);
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
## 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
|
;Connection Information
|
||||||
[Http]
|
[Http]
|
||||||
http.ConnectionTimeOut = 30
|
http.ConnectionTimeOut = 30
|
||||||
http.Retry = 1
|
http.Retry = 1
|
||||||
;http.Proxy=http://[username:password]@hostname[:port][/path]
|
;http.Proxy=http://[username:password]@hostname[:port]
|
||||||
|
|
||||||
|
|
||||||
;Service Configuration
|
;Service Configuration
|
||||||
[Service]
|
[Service]
|
||||||
@@ -23,4 +30,4 @@ log.FileName=../PayPal.log
|
|||||||
# Logging level can be one of FINE, INFO, WARN or ERROR
|
# Logging level can be one of FINE, INFO, WARN or ERROR
|
||||||
# Logging is most verbose in the 'FINE' level and
|
# Logging is most verbose in the 'FINE' level and
|
||||||
# decreases as you proceed towards ERROR
|
# decreases as you proceed towards ERROR
|
||||||
log.LogLevel=FINE
|
log.LogLevel=FINE
|
||||||
|
|||||||
Reference in New Issue
Block a user