PPPStripeUtilRequestOptions

The Gravity Forms + Stripe PPP Stripe Util RequestOptions class.

Defined (1)

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

/includes/api/stripe-php/lib/Util/RequestOptions.php  
  1. class RequestOptions 
  2. public $headers; 
  3. public $apiKey; 
  4.  
  5. public function __construct($key = null, $headers = array()) 
  6. $this->apiKey = $key; 
  7. $this->headers = $headers; 
  8.  
  9. /** 
  10. * Unpacks an options array and merges it into the existing RequestOptions 
  11. * object. 
  12. * @param array|string|null $options a key => value array 
  13. * @return RequestOptions 
  14. */ 
  15. public function merge($options) 
  16. $other_options = self::parse($options); 
  17. if ($other_options->apiKey === null) { 
  18. $other_options->apiKey = $this->apiKey; 
  19. $other_options->headers = array_merge($this->headers, $other_options->headers); 
  20. return $other_options; 
  21.  
  22. /** 
  23. * Unpacks an options array into an RequestOptions object 
  24. * @param array|string|null $options a key => value array 
  25. * @return RequestOptions 
  26. */ 
  27. public static function parse($options) 
  28. if ($options instanceof self) { 
  29. return $options; 
  30.  
  31. if (is_null($options)) { 
  32. return new RequestOptions(null, array()); 
  33.  
  34. if (is_string($options)) { 
  35. return new RequestOptions($options, array()); 
  36.  
  37. if (is_array($options)) { 
  38. $headers = array(); 
  39. $key = null; 
  40. if (array_key_exists('api_key', $options)) { 
  41. $key = $options['api_key']; 
  42. if (array_key_exists('idempotency_key', $options)) { 
  43. $headers['Idempotency-Key'] = $options['idempotency_key']; 
  44. if (array_key_exists('stripe_account', $options)) { 
  45. $headers['Stripe-Account'] = $options['stripe_account']; 
  46. if (array_key_exists('stripe_version', $options)) { 
  47. $headers['Stripe-Version'] = $options['stripe_version']; 
  48. return new RequestOptions($key, $headers); 
  49.  
  50. $message = 'The second argument to Stripe API method calls is an ' 
  51. . 'optional per-request apiKey, which must be a string, or ' 
  52. . 'per-request options, which must be an array. (HINT: you can set ' 
  53. . 'a global apiKey by "Stripe::setApiKey(<apiKey>)")'; 
  54. throw new Error\Api($message);