@@ -29,9 +29,9 @@ class PayPal extends Base
29
29
30
30
protected string $ authUrl = 'https://www.paypal.com/signin/authorize ' ;
31
31
32
- protected string $ tokenURL = 'https://api.sandbox .paypal.com/v1/oauth2/token ' ;
32
+ protected string $ tokenURL = 'https://api-m .paypal.com/v1/oauth2/token ' ;
33
33
34
- protected string $ userinfoURL = 'https://api.paypal.com/v1/identity/openidconnect/userinfo ' ;
34
+ protected string $ userinfoURL = 'https://api.paypal.com/v1/identity/openidconnect/userinfo?schema=openid ' ;
35
35
36
36
protected array $ scopes = [
37
37
'openid ' , 'profile ' , 'email ' , 'address ' ,
@@ -42,11 +42,11 @@ class PayPal extends Base
42
42
public function __construct (array $ config )
43
43
{
44
44
parent ::__construct ($ config );
45
- $ this ->sandbox = (bool ) $ this ->config ->get ('sandbox ' , false );
45
+ $ this ->sandbox = (bool )$ this ->config ->get ('sandbox ' , false );
46
46
if ($ this ->sandbox ) {
47
47
$ this ->authUrl = 'https://www.sandbox.paypal.com/signin/authorize ' ;
48
48
$ this ->tokenURL = 'https://api-m.sandbox.paypal.com/v1/oauth2/token ' ;
49
- $ this ->userinfoURL = 'https://api-m.sandbox.paypal.com/v1/identity/openidconnect/userinfo ' ;
49
+ $ this ->userinfoURL = 'https://api-m.sandbox.paypal.com/v1/identity/openidconnect/userinfo?schema=openid ' ;
50
50
}
51
51
}
52
52
@@ -97,49 +97,24 @@ protected function getTokenUrl(): string
97
97
* @throws \Overtrue\Socialite\Exceptions\AuthorizeFailedException
98
98
*
99
99
* @see https://developer.paypal.com/docs/log-in-with-paypal/integrate/#link-getaccesstoken
100
+ *
100
101
*/
101
102
public function tokenFromCode (string $ code ): array
102
103
{
103
104
$ response = $ this ->getHttpClient ()->post (
104
105
$ this ->getTokenUrl (),
105
106
[
106
107
'form_params ' => [
107
- Contracts \RFC6749_ABNF_GRANT_TYPE => Contracts \RFC6749_ABNF_AUTHORATION_CODE ,
108
+ Contracts \RFC6749_ABNF_GRANT_TYPE => Contracts \RFC6749_ABNF_CLIENT_CREDENTIALS ,
108
109
Contracts \RFC6749_ABNF_CODE => $ code ,
109
110
],
110
111
'headers ' => [
111
112
'Accept ' => 'application/json ' ,
112
- 'Authorization ' => 'Basic ' .\base64_encode (\sprintf ('%s:%s ' , $ this ->getClientId (), $ this ->getClientSecret ())),
113
- ],
114
- ]
115
- );
116
-
117
- return $ this ->normalizeAccessTokenResponse ((string ) $ response ->getBody ());
118
- }
119
-
120
- /**
121
- * @throws \GuzzleHttp\Exception\GuzzleException
122
- * @throws \Overtrue\Socialite\Exceptions\AuthorizeFailedException
123
- *
124
- * @see https://developer.paypal.com/docs/log-in-with-paypal/integrate/#link-exchangerefreshtokenforaccesstoken
125
- */
126
- public function refreshToken (string $ refreshToken ): mixed
127
- {
128
- $ response = $ this ->getHttpClient ()->post (
129
- $ this ->getTokenUrl (),
130
- [
131
- 'form_params ' => [
132
- Contracts \RFC6749_ABNF_GRANT_TYPE => Contracts \RFC6749_ABNF_REFRESH_TOKEN ,
133
- Contracts \RFC6749_ABNF_REFRESH_TOKEN => $ refreshToken ,
134
- ],
135
- 'headers ' => [
136
- 'Accept ' => 'application/json ' ,
137
- 'Authorization ' => 'Basic ' .\base64_encode (\sprintf ('%s:%s ' , $ this ->getClientId (), $ this ->getClientSecret ())),
113
+ 'Authorization ' => 'Basic ' . \base64_encode (\sprintf ('%s:%s ' , $ this ->getClientId (), $ this ->getClientSecret ())),
138
114
],
139
115
]
140
116
);
141
-
142
- return $ this ->normalizeAccessTokenResponse ((string ) $ response ->getBody ());
117
+ return $ this ->normalizeAccessTokenResponse ((string )$ response ->getBody ());
143
118
}
144
119
145
120
/**
@@ -154,11 +129,10 @@ protected function getUserByToken(string $token): array
154
129
[
155
130
'headers ' => [
156
131
'Content-Type ' => 'application/x-www-form-urlencoded ' ,
157
- 'Authorization ' => 'Bearer ' . $ token ,
132
+ 'Authorization ' => 'Bearer ' . $ token ,
158
133
],
159
134
]
160
135
);
161
-
162
136
return $ this ->fromJsonBody ($ response );
163
137
}
164
138
0 commit comments