當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ApiContext::getConfig方法代碼示例

本文整理匯總了PHP中PayPal\Rest\ApiContext::getConfig方法的典型用法代碼示例。如果您正苦於以下問題:PHP ApiContext::getConfig方法的具體用法?PHP ApiContext::getConfig怎麽用?PHP ApiContext::getConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PayPal\Rest\ApiContext的用法示例。


在下文中一共展示了ApiContext::getConfig方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handle

 /**
  * @param PayPalHttpConfig $httpConfig
  * @param string                    $request
  * @param mixed                     $options
  * @return mixed|void
  * @throws PayPalConfigurationException
  * @throws PayPalInvalidCredentialException
  * @throws PayPalMissingCredentialException
  */
 public function handle($httpConfig, $request, $options)
 {
     $credential = $this->apiContext->getCredential();
     $config = $this->apiContext->getConfig();
     if ($credential == null) {
         // Try picking credentials from the config file
         $credMgr = PayPalCredentialManager::getInstance($config);
         $credValues = $credMgr->getCredentialObject();
         if (!is_array($credValues)) {
             throw new PayPalMissingCredentialException("Empty or invalid credentials passed");
         }
         $credential = new OAuthTokenCredential($credValues['clientId'], $credValues['clientSecret']);
     }
     if ($credential == null || !$credential instanceof OAuthTokenCredential) {
         throw new PayPalInvalidCredentialException("Invalid credentials passed");
     }
     $httpConfig->setUrl(rtrim(trim($this->_getEndpoint($config)), '/') . (isset($options['path']) ? $options['path'] : ''));
     // Overwrite Expect Header to disable 100 Continue Issue
     $httpConfig->addHeader("Expect", null);
     if (!array_key_exists("User-Agent", $httpConfig->getHeaders())) {
         $httpConfig->addHeader("User-Agent", PayPalUserAgent::getValue(PayPalConstants::SDK_NAME, PayPalConstants::SDK_VERSION));
     }
     if (!is_null($credential) && $credential instanceof OAuthTokenCredential && is_null($httpConfig->getHeader('Authorization'))) {
         $httpConfig->addHeader('Authorization', "Bearer " . $credential->getAccessToken($config), false);
     }
     if ($httpConfig->getMethod() == 'POST' || $httpConfig->getMethod() == 'PUT') {
         $httpConfig->addHeader('PayPal-Request-Id', $this->apiContext->getRequestId());
     }
     // Add any additional Headers that they may have provided
     $headers = $this->apiContext->getRequestHeaders();
     foreach ($headers as $key => $value) {
         $httpConfig->addHeader($key, $value);
     }
 }
開發者ID:r8filipe,項目名稱:LAPR,代碼行數:43,代碼來源:RestHandler.php

示例2: handle

 /**
  * Handle
  *
  * @param \PayPal\Core\PPHttpConfig $httpConfig
  * @param \PayPal\Core\PPRequest    $request
  * @param array                     $options
  *
  * @throws \PayPal\Exception\PPInvalidCredentialException
  * @throws \PayPal\Exception\PPMissingCredentialException
  */
 public function handle($httpConfig, $request, $options)
 {
     $credential = $this->apiContext->getCredential();
     $config = $this->apiContext->getConfig();
     if ($credential == null) {
         // Try picking credentials from the config file
         $credMgr = PPCredentialManager::getInstance($config);
         $credValues = $credMgr->getCredentialObject();
         if (!is_array($credValues)) {
             throw new PPMissingCredentialException("Empty or invalid credentials passed");
         }
         $credential = new OAuthTokenCredential($credValues['clientId'], $credValues['clientSecret']);
     }
     if ($credential == null || !$credential instanceof OAuthTokenCredential) {
         throw new PPInvalidCredentialException("Invalid credentials passed");
     }
     $httpConfig->setUrl(rtrim(trim($this->_getEndpoint($config)), '/') . (isset($options['path']) ? $options['path'] : ''));
     if (!array_key_exists("User-Agent", $httpConfig->getHeaders())) {
         $httpConfig->addHeader("User-Agent", PPUserAgent::getValue(self::$sdkName, self::$sdkVersion));
     }
     if (!is_null($credential) && $credential instanceof OAuthTokenCredential) {
         $httpConfig->addHeader('Authorization', "Bearer " . $credential->getAccessToken($config));
     }
     if ($httpConfig->getMethod() == 'POST' || $httpConfig->getMethod() == 'PUT') {
         $httpConfig->addHeader('PayPal-Request-Id', $this->apiContext->getRequestId());
     }
 }
開發者ID:adiktus9116,項目名稱:rest-api-sdk-php,代碼行數:37,代碼來源:RestHandler.php

示例3: handle

 /**
  * @param PayPalHttpConfig $httpConfig
  * @param string                    $request
  * @param mixed                     $options
  * @return mixed|void
  * @throws PayPalConfigurationException
  * @throws PayPalInvalidCredentialException
  * @throws PayPalMissingCredentialException
  */
 public function handle($httpConfig, $request, $options)
 {
     $config = $this->apiContext->getConfig();
     $httpConfig->setUrl(rtrim(trim($this->_getEndpoint($config)), '/') . (isset($options['path']) ? $options['path'] : ''));
     $headers = array("User-Agent" => PayPalUserAgent::getValue(PayPalConstants::SDK_NAME, PayPalConstants::SDK_VERSION), "Authorization" => "Basic " . base64_encode($options['clientId'] . ":" . $options['clientSecret']), "Accept" => "*/*");
     $httpConfig->setHeaders($headers);
     // Add any additional Headers that they may have provided
     $headers = $this->apiContext->getRequestHeaders();
     foreach ($headers as $key => $value) {
         $httpConfig->addHeader($key, $value);
     }
 }
開發者ID:Roc4rdho,項目名稱:app,代碼行數:21,代碼來源:OauthHandler.php

示例4: getLogoutUrl

 /**
  * Returns the URL to which the user must be redirected to
  * logout from the OpenID provider (i.e. PayPal)
  *
  * @param string     $redirectUri   Uri on merchant website to where
  *                                  the user must be redirected to post logout
  * @param string     $idToken       id_token from the TokenInfo object
  * @param ApiContext $apiContext    Optional API Context
  * @return string logout URL
  */
 public static function getLogoutUrl($redirectUri, $idToken, $apiContext = null)
 {
     if (is_null($apiContext)) {
         $apiContext = new ApiContext();
     }
     $config = $apiContext->getConfig();
     $params = array('id_token' => $idToken, 'redirect_uri' => $redirectUri, 'logout' => 'true');
     return sprintf("%s/webapps/auth/protocol/openidconnect/v1/endsession?%s", self::getBaseUrl($config), http_build_query($params));
 }
開發者ID:paypal,項目名稱:rest-api-sdk-php,代碼行數:19,代碼來源:OpenIdSession.php

示例5: execute

 /**
  * @param array  $handlers Array of handlers
  * @param string $path     Resource path relative to base service endpoint
  * @param string $method   HTTP method - one of GET, POST, PUT, DELETE, PATCH etc
  * @param string $data     Request payload
  * @param array  $headers  HTTP headers
  * @return mixed
  * @throws \PayPal\Exception\PayPalConnectionException
  */
 public function execute($handlers = array(), $path, $method, $data = '', $headers = array())
 {
     $config = $this->apiContext->getConfig();
     $httpConfig = new PayPalHttpConfig(null, $method, $config);
     $headers = $headers ? $headers : array();
     $httpConfig->setHeaders($headers + array('Content-Type' => 'application/json'));
     /** @var \Paypal\Handler\IPayPalHandler $handler */
     foreach ($handlers as $handler) {
         if (!is_object($handler)) {
             $fullHandler = "\\" . (string) $handler;
             $handler = new $fullHandler($this->apiContext);
         }
         $handler->handle($httpConfig, $data, array('path' => $path, 'apiContext' => $this->apiContext));
     }
     $connection = new PayPalHttpConnection($httpConfig, $config);
     $response = $connection->execute($data);
     return $response;
 }
開發者ID:Roc4rdho,項目名稱:app,代碼行數:27,代碼來源:PayPalRestCall.php


注:本文中的PayPal\Rest\ApiContext::getConfig方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。