Environment.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. class ChargeBee_Environment {
  3. private $apiKey;
  4. private $site;
  5. private $apiEndPoint;
  6. private static $default_env;
  7. public static $scheme = "https";
  8. public static $chargebeeDomain;
  9. public static $connectTimeout= 50;
  10. public static $timeout=100;
  11. public static $timeMachineWaitInSecs = 3;
  12. public static $exportWaitInSecs = 3;
  13. const API_VERSION = "v2";
  14. function __construct($site, $apiKey) {
  15. $this->site = $site;
  16. $this->apiKey = $apiKey;
  17. if (ChargeBee_Environment::$chargebeeDomain == null) {
  18. $this->apiEndPoint = "https://$site.chargebee.com/api/" . ChargeBee_Environment::API_VERSION;
  19. } else {
  20. $this->apiEndPoint = ChargeBee_Environment::$scheme . "://$site." . ChargeBee_Environment::$chargebeeDomain . "/api/" . ChargeBee_Environment::API_VERSION;
  21. }
  22. }
  23. public static function configure($site, $apiKey) {
  24. ChargeBee_Environment::$default_env = new ChargeBee_Environment($site, $apiKey);
  25. }
  26. public function getApiKey() {
  27. return $this->apiKey;
  28. }
  29. public function getSite() {
  30. return $this->site;
  31. }
  32. public function getApiEndpoint() {
  33. return $this->apiEndPoint;
  34. }
  35. public static function defaultEnv() {
  36. return ChargeBee_Environment::$default_env;
  37. }
  38. public function apiUrl($url) {
  39. return $this->apiEndPoint . $url;
  40. }
  41. }
  42. ?>