Skip to content

Commit

Permalink
使用驼峰命名法
Browse files Browse the repository at this point in the history
  • Loading branch information
izhiqiang committed Jun 7, 2024
1 parent 1625c23 commit a4d728a
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/Providers/PayPal.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class PayPal extends Base
* @var string|null
* code or id_token
*/
protected ?string $response_type = Contracts\RFC6749_ABNF_CODE;
protected string $flow_entry = 'static';
protected ?string $responseType = Contracts\RFC6749_ABNF_CODE;
protected string $flowEntry = 'static';

protected string $authUrl = 'https://www.paypal.com/signin/authorize';
protected string $tokenURL = "https://api.sandbox.paypal.com/v1/oauth2/token";
Expand All @@ -49,9 +49,9 @@ public function __construct(array $config)
* @param string|null $response_type
* @return $this
*/
public function withResponseType(?string $response_type)
public function withResponseType(?string $responseType)
{
$this->response_type = $response_type;
$this->responseType = $responseType;
return $this;
}

Expand All @@ -64,9 +64,9 @@ protected function getCodeFields(): array
{
$fields = \array_merge(
[
'flowEntry' => $this->flow_entry,
'flowEntry' => $this->flowEntry,
Contracts\RFC6749_ABNF_CLIENT_ID => $this->getClientId(),
Contracts\RFC6749_ABNF_RESPONSE_TYPE => $this->response_type,
Contracts\RFC6749_ABNF_RESPONSE_TYPE => $this->responseType,
Contracts\RFC6749_ABNF_SCOPE => $this->formatScopes($this->scopes, $this->scopeSeparator),
Contracts\RFC6749_ABNF_REDIRECT_URI => $this->redirectUrl,
],
Expand Down Expand Up @@ -94,14 +94,13 @@ protected function getTokenUrl(): string
*/
public function tokenFromCode(string $code): array
{
$form_params = [
Contracts\RFC6749_ABNF_GRANT_TYPE => Contracts\RFC6749_ABNF_AUTHORATION_CODE,
Contracts\RFC6749_ABNF_CODE => $code,
];
$response = $this->getHttpClient()->post(
$response = $this->getHttpClient()->post(
$this->getTokenUrl(),
[
'form_params' => $form_params,
'form_params' => [
Contracts\RFC6749_ABNF_GRANT_TYPE => Contracts\RFC6749_ABNF_AUTHORATION_CODE,
Contracts\RFC6749_ABNF_CODE => $code,
],
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Basic ' . \base64_encode(\sprintf('%s:%s', $this->getClientId(), $this->getClientSecret())),
Expand All @@ -120,14 +119,13 @@ public function tokenFromCode(string $code): array
*/
public function refreshToken(string $refreshToken): mixed
{
$form_params = [
Contracts\RFC6749_ABNF_GRANT_TYPE => Contracts\RFC6749_ABNF_REFRESH_TOKEN,
Contracts\RFC6749_ABNF_REFRESH_TOKEN => $refreshToken,
];
$response = $this->getHttpClient()->post(
$this->getTokenUrl(),
[
'form_params' => $form_params,
'form_params' => [
Contracts\RFC6749_ABNF_GRANT_TYPE => Contracts\RFC6749_ABNF_REFRESH_TOKEN,
Contracts\RFC6749_ABNF_REFRESH_TOKEN => $refreshToken,
],
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Basic ' . \base64_encode(\sprintf('%s:%s', $this->getClientId(), $this->getClientSecret())),
Expand Down

0 comments on commit a4d728a

Please sign in to comment.