Пример #1
0
 /**
  * @test
  */
 public function testGetIniPrefix()
 {
     $ret = $this->object->getIniPrefix();
     $this->assertContains('acct1', $ret);
     $this->assertEquals(sizeof($ret), 2);
     $ret = $this->object->getIniPrefix('jb-us-seller_api1.paypal.com');
     $this->assertEquals('acct1', $ret);
 }
Пример #2
0
 public function getConfig()
 {
     if (!isset($this->config)) {
         $this->config = PPConfigManager::getInstance()->getConfigHashmap();
     }
     return $this->config;
 }
Пример #3
0
 public function __construct($serviceName, $serviceBinding, $handlers = array(), $config = null)
 {
     $this->serviceName = $serviceName;
     $this->serviceBinding = $serviceBinding;
     $this->handlers = $handlers;
     if ($config == null) {
         $configFile = PPConfigManager::getInstance();
         $this->config = $configFile->getConfigHashmap();
     } else {
         $this->config = PPConfigManager::mergrDefaults($config);
     }
 }
Пример #4
0
 /**
  *
  * @param string $postData OPTIONAL post data. If null,
  * 				the class automatically reads incoming POST data
  * 				from the input stream
  */
 public function __construct($postData = '', $config = null)
 {
     $this->config = PPConfigManager::getConfigWithDefaults($config);
     if ($postData == '') {
         // reading posted data from directly from $_POST may causes serialization issues with array data in POST
         // reading raw POST data from input stream instead.
         $postData = file_get_contents('php://input');
     }
     $rawPostArray = explode('&', $postData);
     foreach ($rawPostArray as $keyValue) {
         $keyValue = explode('=', $keyValue);
         if (count($keyValue) == 2) {
             $this->ipnData[$keyValue[0]] = urldecode($keyValue[1]);
         }
     }
     //var_dump($this->ipnData);
 }
 /**
  * @test
  */
 public function testMergeWithDefaults()
 {
     // Test file based config params and defaults
     $config = PPConfigManager::getInstance()->getConfigWithDefaults(array());
     $this->assertArrayHasKey('mode', $config, 'file config not read when no custom config is passed');
     $this->assertEquals('sandbox', $config['mode']);
     $this->assertEquals(60, $config['http.ConnectionTimeOut']);
     // Test custom config params and defaults
     $config = PPConfigManager::getInstance()->getConfigWithDefaults(array('mode' => 'custom'));
     $this->assertArrayHasKey('mode', $config);
     $this->assertEquals('custom', $config['mode']);
     $this->assertEquals(30, $config['http.ConnectionTimeOut']);
     // Test override for default connection params
     $config = PPConfigManager::getInstance()->getConfigWithDefaults(array('mode' => 'custom', 'http.ConnectionTimeOut' => 100));
     $this->assertArrayHasKey('mode', $config);
     $this->assertEquals('custom', $config['mode']);
     $this->assertEquals(100, $config['http.ConnectionTimeOut']);
 }
Пример #6
0
 /**
  *
  * @param string     $method        - API method to call
  * @param object     $requestObject Request object
  * @param apiContext $apiContext    object containing credential and SOAP headers
  * @param array      $handlers      Array of Handlers
  * @param mixed      $apiUserName   - Optional API credential - can either be
  *                                  a username configured in sdk_config.ini or a ICredential object created dynamically
  */
 public function call($port, $method, $requestObject, $apiContext, $handlers = array())
 {
     if (!is_array($handlers)) {
         $handlers = array();
     }
     if (is_array($this->handlers)) {
         $handlers = array_merge($this->handlers, $handlers);
     }
     if ($apiContext == null) {
         $apiContext = new PPApiContext(PPConfigManager::getConfigWithDefaults($this->config));
     }
     if ($apiContext->getConfig() == null) {
         $apiContext->setConfig(PPConfigManager::getConfigWithDefaults($this->config));
     }
     $service = new PPAPIService($port, $this->serviceName, $this->serviceBinding, $apiContext, $handlers);
     $ret = $service->makeRequest($method, new PPRequest($requestObject, $this->serviceBinding));
     $this->lastRequest = $ret['request'];
     $this->lastResponse = $ret['response'];
     return $this->lastResponse;
 }
Пример #7
0
 /**
  * use  the default configuration if it is not passed in hashmap
  */
 public static function getConfigWithDefaults($config = null)
 {
     return array_merge(PPConfigManager::$defaults, $config != null ? $config : PPConfigManager::getInstance()->getConfigHashmap());
 }
Пример #8
0
 /**
  * @param null $ClientId
  * @param null $ClientSecret
  * @return PayPal/Auth/OAuthTokenCredential
  */
 public static function OAuthTokenCredential($ClientId = null, $ClientSecret = null)
 {
     //define("PP_CONFIG_PATH", __DIR__);
     if (isset($ClientId) && isset($ClientSecret)) {
         return new OAuthTokenCredential($ClientId, $ClientSecret);
     }
     $configManager = PPConfigManager::getInstance();
     // $cred is used by samples that include this bootstrap file
     // This piece of code simply demonstrates how you can
     // dynamically pass in a client id/secret instead of using
     // the config file. If you do not need a way to pass
     // in credentials dynamically, you can skip the
     // <Resource>::setCredential($cred) calls that
     // you see in the samples.
     $cred = new OAuthTokenCredential($configManager->get('acct1.ClientId'), $configManager->get('acct1.ClientSecret'));
     return $cred;
 }
 public function testInvalidCredentials()
 {
     $this->setExpectedException('PayPal\\Exception\\PPConnectionException');
     $cred = new OAuthTokenCredential('dummy', 'secret');
     $this->assertNull($cred->getAccessToken(PPConfigManager::getInstance()->getConfigHashmap()));
 }
Пример #10
0
 public function __construct($config = null)
 {
     $this->config = PPConfigManager::getConfigWithDefaults($config);
 }