3 use PayPal\Core\PPAPIService;
7 protected static $SDK_NAME = "paypal-php-sdk";
9 protected static $SDK_VERSION = "2.1.96";
12 private $serviceBinding;
16 * Setters and getters for Third party authentication (Permission Services)
18 protected $accessToken;
19 protected $tokenSecret;
21 protected $lastRequest;
22 protected $lastResponse;
30 * Compute the value that needs to sent for the PAYPAL_REQUEST_SOURCE
31 * parameter when making API calls
33 public static function getRequestSource()
35 return str_replace(" ", "-", self::$SDK_NAME) . "-" . self::$SDK_VERSION;
39 public function getLastRequest() {
40 return $this->lastRequest;
42 public function setLastRequest($lastRqst) {
43 $this->lastRequest = $lastRqst;
45 public function getLastResponse() {
46 return $this->lastResponse;
48 public function setLastResponse($lastRspns) {
49 $this->lastResponse = $lastRspns;
52 public function __construct($serviceName, $serviceBinding, $handlers=array(), $config = null) {
53 $this->serviceName = $serviceName;
54 $this->serviceBinding = $serviceBinding;
55 $this->handlers = $handlers;
58 $configFile = PPConfigManager::getInstance();
59 $this->config = $configFile->getConfigHashmap();
63 $this->config = PPConfigManager::mergrDefaults($config);
67 public function getServiceName() {
68 return $this->serviceName;
73 * @param string $method - API method to call
74 * @param object $requestObject Request object
75 * @param mixed $apiCredential - Optional API credential - can either be
76 * a username configured in sdk_config.ini or a ICredential object
79 public function call($port, $method, $requestObject, $apiUserName = NULL) {
80 $service = new PPAPIService($port, $this->serviceName,
81 $this->serviceBinding, $this->handlers,$this->config);
82 $ret = $service->makeRequest($method, $requestObject, $apiUserName);
83 $this->lastRequest = $ret['request'];
84 $this->lastResponse = $ret['response'];
85 return $this->lastResponse;