Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Paypal.php

Zuletzt modifiziert: 09.10.2024, 12:59 - Dateigröße: 3.09 KiB


 001  <?php
 002   
 003  namespace OAuth\OAuth2\Service;
 004   
 005  use OAuth\OAuth2\Token\StdOAuth2Token;
 006  use OAuth\Common\Http\Exception\TokenResponseException;
 007  use OAuth\Common\Http\Uri\Uri;
 008  use OAuth\Common\Consumer\CredentialsInterface;
 009  use OAuth\Common\Http\Client\ClientInterface;
 010  use OAuth\Common\Storage\TokenStorageInterface;
 011  use OAuth\Common\Http\Uri\UriInterface;
 012   
 013  /**
 014   * PayPal service.
 015   *
 016   * @author Flávio Heleno <flaviohbatista@gmail.com>
 017   * @link https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/detailed/
 018   */
 019  class Paypal extends AbstractService
 020  {
 021      /**
 022       * Defined scopes
 023       * @link https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/detailed/
 024       * @see  #attributes
 025       */
 026      const SCOPE_OPENID           = 'openid';
 027      const SCOPE_PROFILE          = 'profile';
 028      const SCOPE_PAYPALATTRIBUTES = 'https://uri.paypal.com/services/paypalattributes';
 029      const SCOPE_EMAIL            = 'email';
 030      const SCOPE_ADDRESS          = 'address';
 031      const SCOPE_PHONE            = 'phone';
 032      const SCOPE_EXPRESSCHECKOUT  = 'https://uri.paypal.com/services/expresscheckout';
 033   
 034      public function __construct(
 035          CredentialsInterface $credentials,
 036          ClientInterface $httpClient,
 037          TokenStorageInterface $storage,
 038          $scopes = array(),
 039          UriInterface $baseApiUri = null
 040      ) {
 041          parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
 042   
 043          if (null === $baseApiUri) {
 044              $this->baseApiUri = new Uri('https://api.paypal.com/v1/');
 045          }
 046      }
 047   
 048      /**
 049       * {@inheritdoc}
 050       */
 051      public function getAuthorizationEndpoint()
 052      {
 053          return new Uri('https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize');
 054      }
 055   
 056      /**
 057       * {@inheritdoc}
 058       */
 059      public function getAccessTokenEndpoint()
 060      {
 061          return new Uri('https://api.paypal.com/v1/identity/openidconnect/tokenservice');
 062      }
 063   
 064      /**
 065       * {@inheritdoc}
 066       */
 067      protected function getAuthorizationMethod()
 068      {
 069          return static::AUTHORIZATION_METHOD_HEADER_BEARER;
 070      }
 071   
 072      /**
 073       * {@inheritdoc}
 074       */
 075      protected function parseAccessTokenResponse($responseBody)
 076      {
 077          $data = json_decode($responseBody, true);
 078   
 079          if (null === $data || !is_array($data)) {
 080              throw new TokenResponseException('Unable to parse response.');
 081          } elseif (isset($data['message'])) {
 082              throw new TokenResponseException('Error in retrieving token: "' . $data['message'] . '"');
 083          } elseif (isset($data['name'])) {
 084              throw new TokenResponseException('Error in retrieving token: "' . $data['name'] . '"');
 085          }
 086   
 087          $token = new StdOAuth2Token();
 088          $token->setAccessToken($data['access_token']);
 089          $token->setLifeTime($data['expires_in']);
 090   
 091          if (isset($data['refresh_token'])) {
 092              $token->setRefreshToken($data['refresh_token']);
 093              unset($data['refresh_token']);
 094          }
 095   
 096          unset($data['access_token']);
 097          unset($data['expires_in']);
 098   
 099          $token->setExtraParams($data);
 100   
 101          return $token;
 102      }
 103  }
 104