mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-05 16:42:53 +01:00
NEW Upgrade of Stripe lib to 6.4.1
This commit is contained in:
@@ -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'];
|
||||
|
||||
Reference in New Issue
Block a user