This repository has been archived on 2026-04-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
PayPal-PHP-SDK/sample/bootstrap.php
hakito c1298112fa Fix path in bootstrap for samples when installed via composer
When installing the SDK as recommended via composer, the samples don't work because it can not find the autloader of composer
2013-10-06 20:49:49 +02:00

74 lines
1.7 KiB
PHP

<?php
/*
* Sample bootstrap file.
*/
// Include the composer autoloader
$composerAutoload = dirname(dirname(dirname(__DIR__))) . '/autoload.php';
if (file_exists($composerAutoload))
{
$composerAutoload = __DIR__ .'/vendor/autoload.php';
if(!file_exists(__DIR__ .'/vendor/autoload.php')) {
echo "The 'vendor' folder is missing. You must run 'composer update' to resolve application dependencies.\nPlease see the README for more information.\n";
exit(1);
}
}
require $composerAutoload;
require __DIR__ . '/common.php';
use PayPal\Rest\ApiContext;
use PayPal\Auth\OAuthTokenCredential;
$apiContext = getApiContext();
/**
* Helper method for getting an APIContext for all calls
*
* @return PayPal\Rest\ApiContext
*/
function getApiContext() {
// ### Api context
// Use an 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' block if you want to use 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.
if(!defined("PP_CONFIG_PATH")) {
define("PP_CONFIG_PATH", __DIR__);
}
*/
return $apiContext;
}