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