Environment.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. function __construct($site, $apiKey) {
  12. $this->site = $site;
  13. $this->apiKey = $apiKey;
  14. if (ChargeBee_Environment::$chargebeeDomain == null) {
  15. $this->apiEndPoint = "https://$site.chargebee.com/api/v1";
  16. } else {
  17. $this->apiEndPoint = ChargeBee_Environment::$scheme . "://$site." . ChargeBee_Environment::$chargebeeDomain . "/api/v1";
  18. }
  19. }
  20. public static function configure($site, $apiKey) {
  21. ChargeBee_Environment::$default_env = new ChargeBee_Environment($site, $apiKey);
  22. }
  23. public function getApiKey() {
  24. return $this->apiKey;
  25. }
  26. public function getSite() {
  27. return $this->site;
  28. }
  29. public function getApiEndpoint() {
  30. return $this->apiEndPoint;
  31. }
  32. public static function defaultEnv() {
  33. return ChargeBee_Environment::$default_env;
  34. }
  35. public function apiUrl($url) {
  36. return $this->apiEndPoint . $url;
  37. }
  38. }
  39. ?>