forked from LiveCarta/PayPal-PHP-SDK
Use restCall object for functions that makes requests (#841)
* Use restCall object for functions that makes requests
This commit is contained in:
@@ -18,13 +18,11 @@ class FuturePayment extends Payment
|
||||
*
|
||||
* @param null $apiContext
|
||||
* @param string|null $clientMetadataId
|
||||
* @param PayPalRestCall|null $restCall is the Rest Call Service that is used to make rest calls
|
||||
* @return $this
|
||||
*/
|
||||
public function create($apiContext = null, $clientMetadataId = null)
|
||||
public function create($apiContext = null, $clientMetadataId = null, $restCall = null)
|
||||
{
|
||||
if ($apiContext == null) {
|
||||
$apiContext = new ApiContext(self::$credential);
|
||||
}
|
||||
$headers = array();
|
||||
if ($clientMetadataId != null) {
|
||||
$headers = array(
|
||||
@@ -32,18 +30,16 @@ class FuturePayment extends Payment
|
||||
);
|
||||
}
|
||||
$payLoad = $this->toJSON();
|
||||
$call = new PayPalRestCall($apiContext);
|
||||
$json = $call->execute(
|
||||
array('PayPal\Handler\RestHandler'),
|
||||
$json = self::executeCall(
|
||||
"/v1/payments/payment",
|
||||
"POST",
|
||||
$payLoad,
|
||||
$headers
|
||||
$headers,
|
||||
$apiContext,
|
||||
$restCall
|
||||
);
|
||||
$this->fromJson($json);
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -219,9 +219,10 @@ class OpenIdTokeninfo extends PayPalResourceModel
|
||||
* (optional) grant_type is the Token grant type. Defaults to refresh_token
|
||||
* (optional) scope is an array that either the same or a subset of the scope passed to the authorization request
|
||||
* @param APIContext $apiContext Optional API Context
|
||||
* @param PayPalRestCall $restCall
|
||||
* @return OpenIdTokeninfo
|
||||
*/
|
||||
public function createFromRefreshToken($params, $apiContext = null)
|
||||
public function createFromRefreshToken($params, $apiContext = null, $restCall = null)
|
||||
{
|
||||
static $allowedParams = array('grant_type' => 1, 'refresh_token' => 1, 'scope' => 1);
|
||||
$apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential);
|
||||
@@ -244,7 +245,8 @@ class OpenIdTokeninfo extends PayPalResourceModel
|
||||
'Content-Type' => 'application/x-www-form-urlencoded',
|
||||
'Authorization' => 'Basic ' . base64_encode($clientId . ":" . $clientSecret)
|
||||
),
|
||||
$apiContext
|
||||
$apiContext,
|
||||
$restCall
|
||||
);
|
||||
|
||||
$this->fromJson($json);
|
||||
|
||||
@@ -505,9 +505,10 @@ class OpenIdUserinfo extends PayPalResourceModel
|
||||
* @param array $params (allowed values are access_token)
|
||||
* access_token - access token from the createFromAuthorizationCode / createFromRefreshToken calls
|
||||
* @param ApiContext $apiContext Optional API Context
|
||||
* @param PayPalRestCall $restCall
|
||||
* @return OpenIdUserinfo
|
||||
*/
|
||||
public static function getUserinfo($params, $apiContext = null)
|
||||
public static function getUserinfo($params, $apiContext = null, $restCall = null)
|
||||
{
|
||||
static $allowedParams = array('schema' => 1);
|
||||
|
||||
@@ -527,7 +528,8 @@ class OpenIdUserinfo extends PayPalResourceModel
|
||||
'Authorization' => "Bearer " . $params['access_token'],
|
||||
'Content-Type' => 'x-www-form-urlencoded'
|
||||
),
|
||||
$apiContext
|
||||
$apiContext,
|
||||
$restCall
|
||||
);
|
||||
|
||||
$ret = new OpenIdUserinfo();
|
||||
|
||||
Reference in New Issue
Block a user