NEW Upgrade of Stripe lib to 6.4.1

This commit is contained in:
Laurent Destailleur
2018-03-07 19:25:05 +01:00
parent fe45e82e99
commit b9f1695b34
59 changed files with 903 additions and 4343 deletions

View File

@@ -6,10 +6,18 @@ use Stripe\Error;
class RequestOptions
{
/**
* @var array A list of headers that should be persisted across requests.
*/
public static $HEADERS_TO_PERSIST = [
'Stripe-Account',
'Stripe-Version',
];
public $headers;
public $apiKey;
public function __construct($key = null, $headers = array())
public function __construct($key = null, $headers = [])
{
$this->apiKey = $key;
$this->headers = $headers;
@@ -32,6 +40,18 @@ class RequestOptions
return $other_options;
}
/**
* Discards all headers that we don't want to persist across requests.
*/
public function discardNonPersistentHeaders()
{
foreach ($this->headers as $k => $v) {
if (!in_array($k, self::$HEADERS_TO_PERSIST)) {
unset($this->headers[$k]);
}
}
}
/**
* Unpacks an options array into an RequestOptions object
* @param array|string|null $options a key => value array
@@ -45,15 +65,15 @@ class RequestOptions
}
if (is_null($options)) {
return new RequestOptions(null, array());
return new RequestOptions(null, []);
}
if (is_string($options)) {
return new RequestOptions($options, array());
return new RequestOptions($options, []);
}
if (is_array($options)) {
$headers = array();
$headers = [];
$key = null;
if (array_key_exists('api_key', $options)) {
$key = $options['api_key'];