Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/ChargeBee/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ class ChargeBee_Environment {
private $apiKey;
private $site;
private $apiEndPoint;

private static $default_env;
private static $universal_headers;
public static $scheme = "https";
public static $chargebeeDomain;

public static $connectTimeout= 50;
public static $timeout=100;
const API_VERSION = "v2";

function __construct($site, $apiKey) {
function __construct($site, $apiKey, $universalHeaders = array()) {
$this->site = $site;
$this->apiKey = $apiKey;
ChargeBee_Environment::$universal_headers = $universalHeaders;
if (ChargeBee_Environment::$chargebeeDomain == null) {
$this->apiEndPoint = "https://$site.chargebee.com/api/" . ChargeBee_Environment::API_VERSION;
} else {
Expand Down Expand Up @@ -46,6 +48,10 @@ public static function defaultEnv() {
return ChargeBee_Environment::$default_env;
}

public static function universalHeaders() {
return ChargeBee_Environment::$universal_headers;
}

public function apiUrl($url) {
return $this->apiEndPoint . $url;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ChargeBee/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static function send($method, $url, $params = array(), $env = null, $head
throw new Exception("ChargeBee api environment is not set. Set your site & api key in ChargeBee_Environment::configure('your_site', 'your_api_key')");
}
$ser_params = ChargeBee_Util::serialize($params);
$response = ChargeBee_Curl::doRequest($method, $url, $env, $ser_params, $headers);
$response = ChargeBee_Curl::doRequest($method, $url, $env, $ser_params, array_merge(ChargeBee_Environment::universalHeaders(), $headers));
if(is_array($response) && array_key_exists("list", $response))
{
return new ChargeBee_ListResult($response['list'], isset($response['next_offset'])?$response['next_offset']:null);
Expand Down