-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added Mercado Pago OAuth functionalities - Fixed proccess_causes method
- Loading branch information
Pedro Gonçalves
committed
Nov 12, 2019
1 parent
902cfe1
commit 8d46ae6
Showing
2 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
namespace MercadoPago; | ||
use MercadoPago\Annotation\RestMethod; | ||
use MercadoPago\Annotation\Attribute; | ||
|
||
/** | ||
* @RestMethod(resource="/oauth/token", method="create") | ||
*/ | ||
|
||
class OAuth extends Entity | ||
{ | ||
/** | ||
* @Attribute() | ||
*/ | ||
protected $client_secret; | ||
/** | ||
* @Attribute() | ||
*/ | ||
protected $grant_type; | ||
/** | ||
* @Attribute() | ||
*/ | ||
protected $code; | ||
/** | ||
* @Attribute() | ||
*/ | ||
protected $redirect_uri; | ||
|
||
/** | ||
* @Attribute() | ||
*/ | ||
protected $access_token; | ||
/** | ||
* @Attribute() | ||
*/ | ||
protected $public_key; | ||
/** | ||
* @Attribute() | ||
*/ | ||
protected $refresh_token; | ||
/** | ||
* @Attribute() | ||
*/ | ||
protected $live_mode; | ||
/** | ||
* @Attribute() | ||
*/ | ||
protected $user_id; | ||
/** | ||
* @Attribute() | ||
*/ | ||
protected $token_type; | ||
/** | ||
* @Attribute() | ||
*/ | ||
protected $expires_in; | ||
/** | ||
* @Attribute() | ||
*/ | ||
protected $scope; | ||
|
||
public function getAuthorizationURL($app_id, $redirect_uri){ | ||
return "https://auth.mercadopago.com.br/authorization?client_id=${app_id}&response_type=code&platform_id=mp&redirect_uri=${redirect_uri}"; | ||
} | ||
|
||
public function getOAuthCredentials($authorization_code, $redirect_uri){ | ||
$this->client_secret = SDK::getAccessToken(); | ||
$this->grant_type = 'authorization_code'; | ||
$this->code = $authorization_code; | ||
$this->redirect_uri = $redirect_uri; | ||
|
||
return $this->save(); | ||
} | ||
|
||
public function refreshOAuthCredentials($refresh_token){ | ||
$this->client_secret = SDK::getAccessToken(); | ||
$this->grant_type = 'refresh_token'; | ||
$this->refresh_token = $refresh_token; | ||
|
||
return $this->save(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters