SDKConfig.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace com\unionpay\acp\sdk;;
  3. include_once 'log.class.php';
  4. include_once 'common.php';
  5. class SDKConfig {
  6. private static $_config = null;
  7. public static function getSDKConfig(){
  8. if (SDKConfig::$_config == null ) {
  9. SDKConfig::$_config = new SDKConfig();
  10. }
  11. return SDKConfig::$_config;
  12. }
  13. public static function setSDKConfig($name,$value){
  14. if (SDKConfig::$_config == null ) {
  15. SDKConfig::$_config = new SDKConfig();
  16. }
  17. SDKConfig::$_config->$name=$value;
  18. }
  19. private $frontTransUrl;
  20. private $backTransUrl;
  21. private $singleQueryUrl;
  22. private $batchTransUrl;
  23. private $fileTransUrl;
  24. private $appTransUrl;
  25. private $cardTransUrl;
  26. private $jfFrontTransUrl;
  27. private $jfBackTransUrl;
  28. private $jfSingleQueryUrl;
  29. private $jfCardTransUrl;
  30. private $jfAppTransUrl;
  31. private $qrcBackTransUrl;
  32. private $qrcB2cIssBackTransUrl;
  33. private $qrcB2cMerBackTransUrl;
  34. private $signMethod;
  35. private $version;
  36. private $ifValidateCNName;
  37. private $ifValidateRemoteCert;
  38. private $signCertPath;
  39. private $signCertPwd;
  40. private $validateCertDir;
  41. private $encryptCertPath;
  42. private $rootCertPath;
  43. private $middleCertPath;
  44. private $frontUrl;
  45. private $backUrl;
  46. private $secureKey;
  47. private $logFilePath;
  48. private $logLevel;
  49. function __construct(){
  50. //如果想把acp_sdk.ini挪到其他路径的话,请修改下面这行指定绝对路径。
  51. $configFilePath = dirname(__FILE__) . "/acp_sdk.ini";
  52. if(!file_exists($configFilePath)){
  53. $logger = LogUtil::getLogger();
  54. $logger->LogError("配置文件加载失败,文件路径:[" . $configFilePath . "].请检查启动php的用户是否有读权限。");
  55. return;
  56. }
  57. $ini_array = parse_ini_file($configFilePath, true);
  58. $sdk_array = $ini_array["acpsdk"];
  59. $this->frontTransUrl = array_key_exists("acpsdk.frontTransUrl", $sdk_array)?$sdk_array["acpsdk.frontTransUrl"] : null;
  60. $this->backTransUrl = array_key_exists("acpsdk.backTransUrl", $sdk_array)?$sdk_array["acpsdk.backTransUrl"] : null;
  61. $this->singleQueryUrl = array_key_exists("acpsdk.singleQueryUrl", $sdk_array)?$sdk_array["acpsdk.singleQueryUrl"] : null;
  62. $this->batchTransUrl = array_key_exists("acpsdk.batchTransUrl", $sdk_array)?$sdk_array["acpsdk.batchTransUrl"] : null;
  63. $this->fileTransUrl = array_key_exists("acpsdk.fileTransUrl", $sdk_array)?$sdk_array["acpsdk.fileTransUrl"] : null;
  64. $this->appTransUrl = array_key_exists("acpsdk.appTransUrl", $sdk_array)?$sdk_array["acpsdk.appTransUrl"] : null;
  65. $this->cardTransUrl = array_key_exists("acpsdk.cardTransUrl", $sdk_array)?$sdk_array["acpsdk.cardTransUrl"] : null;
  66. $this->jfFrontTransUrl = array_key_exists("acpsdk.jfFrontTransUrl", $sdk_array)?$sdk_array["acpsdk.jfFrontTransUrl"] : null;
  67. $this->jfBackTransUrl = array_key_exists("acpsdk.jfBackTransUrl", $sdk_array)?$sdk_array["acpsdk.jfBackTransUrl"] : null;
  68. $this->jfSingleQueryUrl = array_key_exists("acpsdk.jfSingleQueryUrl", $sdk_array)?$sdk_array["acpsdk.jfSingleQueryUrl"] : null;
  69. $this->jfCardTransUrl = array_key_exists("acpsdk.jfCardTransUrl", $sdk_array)?$sdk_array["acpsdk.jfCardTransUrl"] : null;
  70. $this->jfAppTransUrl = array_key_exists("acpsdk.jfAppTransUrl", $sdk_array)?$sdk_array["acpsdk.jfAppTransUrl"] : null;
  71. $this->qrcBackTransUrl = array_key_exists("acpsdk.qrcBackTransUrl", $sdk_array)?$sdk_array["acpsdk.qrcBackTransUrl"] : null;
  72. $this->qrcB2cIssBackTransUrl = array_key_exists("acpsdk.qrcB2cIssBackTransUrl", $sdk_array)?$sdk_array["acpsdk.qrcB2cIssBackTransUrl"] : null;
  73. $this->qrcB2cMerBackTransUrl = array_key_exists("acpsdk.qrcB2cMerBackTransUrl", $sdk_array)?$sdk_array["acpsdk.qrcB2cMerBackTransUrl"] : null;
  74. $this->signMethod = array_key_exists("acpsdk.signMethod", $sdk_array)?$sdk_array["acpsdk.signMethod"] : null;
  75. $this->version = array_key_exists("acpsdk.version", $sdk_array)?$sdk_array["acpsdk.version"] : null;
  76. $this->ifValidateCNName = array_key_exists("acpsdk.ifValidateCNName", $sdk_array)?$sdk_array["acpsdk.ifValidateCNName"] : "true";
  77. $this->ifValidateRemoteCert = array_key_exists("acpsdk.ifValidateRemoteCert", $sdk_array)?$sdk_array["acpsdk.ifValidateRemoteCert"] : "false";
  78. $this->signCertPath = array_key_exists("acpsdk.signCert.path", $sdk_array)?$sdk_array["acpsdk.signCert.path"]: null;
  79. $this->signCertPwd = array_key_exists("acpsdk.signCert.pwd", $sdk_array)?$sdk_array["acpsdk.signCert.pwd"]: null;
  80. $this->validateCertDir = array_key_exists("acpsdk.validateCert.dir", $sdk_array)? $sdk_array["acpsdk.validateCert.dir"]: null;
  81. $this->encryptCertPath = array_key_exists("acpsdk.encryptCert.path", $sdk_array)? $sdk_array["acpsdk.encryptCert.path"]: null;
  82. $this->rootCertPath = array_key_exists("acpsdk.rootCert.path", $sdk_array)? $sdk_array["acpsdk.rootCert.path"]: null;
  83. $this->middleCertPath = array_key_exists("acpsdk.middleCert.path", $sdk_array)?$sdk_array["acpsdk.middleCert.path"]: null;
  84. $this->frontUrl = array_key_exists("acpsdk.frontUrl", $sdk_array)?$sdk_array["acpsdk.frontUrl"]: null;
  85. $this->backUrl = array_key_exists("acpsdk.backUrl", $sdk_array)?$sdk_array["acpsdk.backUrl"]: null;
  86. $this->secureKey = array_key_exists("acpsdk.secureKey", $sdk_array)?$sdk_array["acpsdk.secureKey"]: null;
  87. $this->logFilePath = array_key_exists("acpsdk.log.file.path", $sdk_array)?$sdk_array["acpsdk.log.file.path"]: null;
  88. $this->logLevel = array_key_exists("acpsdk.log.level", $sdk_array)?$sdk_array["acpsdk.log.level"]: null;
  89. }
  90. public function __get($property_name)
  91. {
  92. if(isset($this->$property_name))
  93. {
  94. return($this->$property_name);
  95. }
  96. else
  97. {
  98. return(NULL);
  99. }
  100. }
  101. }