PayPalApiFuturePayment

Class FuturePayment.

Defined (1)

The class is defined in the following location(s).

/classes/lib/PayPal/Api/FuturePayment.php  
  1. class FuturePayment extends Payment 
  2.  
  3. /** 
  4. * Extends the Payment object to create future payments 
  5. * @param null $apiContext 
  6. * @param string|null $clientMetadataId 
  7. * @return $this 
  8. */ 
  9. public function create($apiContext = null, $clientMetadataId = null) 
  10. if ($apiContext == null) { 
  11. $apiContext = new ApiContext(self::$credential); 
  12. $headers = array(); 
  13. if ($clientMetadataId != null) { 
  14. $headers = array( 
  15. 'PAYPAL-CLIENT-METADATA-ID' => $clientMetadataId 
  16. ); 
  17. $payLoad = $this->toJSON(); 
  18. $call = new PayPalRestCall($apiContext); 
  19. $json = $call->execute( 
  20. array('PayPal\Handler\RestHandler'),  
  21. "/v1/payments/payment",  
  22. "POST",  
  23. $payLoad,  
  24. $headers 
  25. ); 
  26. $this->fromJson($json); 
  27.  
  28. return $this; 
  29.  
  30.  
  31. /** 
  32. * Get a Refresh Token from Authorization Code 
  33. * @param $authorizationCode 
  34. * @param ApiContext $apiContext 
  35. * @return string|null refresh token 
  36. */ 
  37. public static function getRefreshToken($authorizationCode, $apiContext = null) 
  38. $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential); 
  39. $credential = $apiContext->getCredential(); 
  40. return $credential->getRefreshToken($apiContext->getConfig(), $authorizationCode); 
  41.  
  42. /** 
  43. * Updates Access Token using long lived refresh token 
  44. * @param string|null $refreshToken 
  45. * @param ApiContext $apiContext 
  46. * @return void 
  47. */ 
  48. public function updateAccessToken($refreshToken, $apiContext) 
  49. $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential); 
  50. $apiContext->getCredential()->updateAccessToken($apiContext->getConfig(), $refreshToken);