forked from LiveCarta/PayPal-PHP-SDK
Defaulting Mode to Sandbox
- Eliminate the need to define config for mode
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user