Defaulting Mode to Sandbox

- Eliminate the need to define config for mode
This commit is contained in:
japatel
2014-12-18 14:04:19 -06:00
parent 20038e7525
commit 4cb951f8b2
3 changed files with 15 additions and 16 deletions

View File

@@ -93,9 +93,8 @@ class OauthHandler implements IPPHandler
throw new PPConfigurationException('The mode config parameter must be set to either sandbox/live'); throw new PPConfigurationException('The mode config parameter must be set to either sandbox/live');
} }
} else { } else {
throw new PPConfigurationException( // Defaulting to Sandbox
'You must set one of service.endpoint or mode parameters in your configuration' $baseEndpoint = PPConstants::REST_SANDBOX_ENDPOINT;
);
} }
$baseEndpoint = rtrim(trim($baseEndpoint), '/') . "/v1/oauth2/token"; $baseEndpoint = rtrim(trim($baseEndpoint), '/') . "/v1/oauth2/token";

View File

@@ -116,9 +116,8 @@ class RestHandler implements IPPHandler
break; break;
} }
} else { } else {
throw new PPConfigurationException( // Defaulting to Sandbox
'You must set one of service.endpoint or mode parameters in your configuration' return PPConstants::REST_SANDBOX_ENDPOINT;
);
} }
} }
} }

View File

@@ -3,7 +3,7 @@
* Sample bootstrap file. * Sample bootstrap file.
*/ */
// Include the composer autoloader // Include the composer Autoloader
// The location of your project's vendor autoloader. // The location of your project's vendor autoloader.
$composerAutoload = dirname(dirname(dirname(__DIR__))) . '/autoload.php'; $composerAutoload = dirname(dirname(dirname(__DIR__))) . '/autoload.php';
if (!file_exists($composerAutoload)) { if (!file_exists($composerAutoload)) {
@@ -35,11 +35,14 @@ $apiContext = getApiContext($clientId, $clientSecret);
return $apiContext; return $apiContext;
/** /**
* Helper method for getting an APIContext for all calls * Helper method for getting an APIContext for all calls
* * @param string $clientId Client ID
* @param string $clientSecret Client Secret
* @return PayPal\Rest\ApiContext * @return PayPal\Rest\ApiContext
*/ */
function getApiContext($clientId, $clientSecret) function getApiContext($clientId, $clientSecret)
{ {
// #### SDK configuration
// Register the sdk_config.ini file in current directory // Register the sdk_config.ini file in current directory
// as the configuration source. // 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 // Comment this line out and uncomment the PP_CONFIG_PATH
// 'define' block if you want to use static file // 'define' block if you want to use static file
// based configuration // based configuration
$apiContext->setConfig( $apiContext->setConfig(
array( array(
'mode' => 'sandbox', '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; return $apiContext;
} }