* @copyright PayPal * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ namespace PaypalAddons\classes\API\Request\V_1; use PayPal\Rest\ApiContext; use PayPal\Auth\OAuthTokenCredential; use PaypalAddons\classes\API\Request\RequestInteface; use PaypalAddons\classes\AbstractMethodPaypal; abstract class RequestAbstract implements RequestInteface { /** @var AbstractMethodPaypal*/ protected $method; public function __construct(AbstractMethodPaypal $method) { $this->method = $method; } /** * @return ApiContext */ public function getApiContext($mode_order = null) { if ($mode_order === null) { $mode_order = $this->method->isSandbox(); } $apiContext = new ApiContext( new OAuthTokenCredential( $this->method->getClientId($mode_order), $this->method->getSecret($mode_order) ) ); $apiContext->setConfig( array( 'mode' => $mode_order ? 'sandbox' : 'live', 'log.LogEnabled' => false, 'cache.enabled' => true, ) ); return $apiContext; } }