diff --git a/lib/PayPal/Rest/OauthHandler.php b/lib/PayPal/Rest/OauthHandler.php index 1e80557..1678a6d 100644 --- a/lib/PayPal/Rest/OauthHandler.php +++ b/lib/PayPal/Rest/OauthHandler.php @@ -93,9 +93,8 @@ class OauthHandler implements IPPHandler throw new PPConfigurationException('The mode config parameter must be set to either sandbox/live'); } } else { - throw new PPConfigurationException( - 'You must set one of service.endpoint or mode parameters in your configuration' - ); + // Defaulting to Sandbox + $baseEndpoint = PPConstants::REST_SANDBOX_ENDPOINT; } $baseEndpoint = rtrim(trim($baseEndpoint), '/') . "/v1/oauth2/token"; diff --git a/lib/PayPal/Rest/RestHandler.php b/lib/PayPal/Rest/RestHandler.php index f8c858a..7d82879 100644 --- a/lib/PayPal/Rest/RestHandler.php +++ b/lib/PayPal/Rest/RestHandler.php @@ -116,9 +116,8 @@ class RestHandler implements IPPHandler break; } } else { - throw new PPConfigurationException( - 'You must set one of service.endpoint or mode parameters in your configuration' - ); + // Defaulting to Sandbox + return PPConstants::REST_SANDBOX_ENDPOINT; } } } diff --git a/sample/bootstrap.php b/sample/bootstrap.php index f52220f..00f7fac 100644 --- a/sample/bootstrap.php +++ b/sample/bootstrap.php @@ -3,7 +3,7 @@ * Sample bootstrap file. */ -// Include the composer autoloader +// Include the composer Autoloader // The location of your project's vendor autoloader. $composerAutoload = dirname(dirname(dirname(__DIR__))) . '/autoload.php'; if (!file_exists($composerAutoload)) { @@ -35,11 +35,14 @@ $apiContext = getApiContext($clientId, $clientSecret); return $apiContext; /** * Helper method for getting an APIContext for all calls - * + * @param string $clientId Client ID + * @param string $clientSecret Client Secret * @return PayPal\Rest\ApiContext */ function getApiContext($clientId, $clientSecret) { + + // #### SDK configuration // Register the sdk_config.ini file in current directory // as the configuration source. /* @@ -62,17 +65,10 @@ function getApiContext($clientId, $clientSecret) ) ); - // Partner Attribution Id - // Use this header if you are a PayPal partner. Specify a unique BN Code to receive revenue attribution. To learn more or to request a BN Code, contact your Partner Manager or visit the PayPal Partner Portal . - - $apiContext->addRequestHeader('PayPal-Partner-Attribution-Id', '123123123'); - - - // #### 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', @@ -86,5 +82,10 @@ function getApiContext($clientId, $clientSecret) ) ); + // Partner Attribution Id + // Use this header if you are a PayPal partner. Specify a unique BN Code to receive revenue attribution. + // To learn more or to request a BN Code, contact your Partner Manager or visit the PayPal Partner Portal + // $apiContext->addRequestHeader('PayPal-Partner-Attribution-Id', '123123123'); + return $apiContext; }