Ejemplo n.º 1
0
 private static function bundle()
 {
     if (!self::$iIsInitialed) {
         //1、读取系统配置文件
         $tIniFile = getenv('ABCMerchantIniFile');
         if (!$tIniFile) {
             $tIniFile = dirname(__FILE__) . '/../TrustMerchant.ini';
         }
         self::$iResourceBundle = @parse_ini_file($tIniFile);
         if (empty(self::$iResourceBundle)) {
             throw new TrxException(TrxException::TRX_EXC_CODE_1000, TrxException::TRX_EXC_MSG_1000);
         }
         //2、读取系统配置段
         self::$iTrustPayConnectMethod = self::getParameterByName('TrustPayConnectMethod');
         self::$iTrustPayServerName = self::getParameterByName('TrustPayServerName');
         self::$iTrustPayServerPort = intval(self::getParameterByName('TrustPayServerPort'));
         if (self::$iTrustPayServerPort == 0) {
             throw new TrxException(TrxException::TRX_EXC_CODE_1001, TrxException::TRX_EXC_MSG_1001 . ' - 网上支付平台交易端口[TrustPayServerPort]配置错误!');
         }
         self::$iTrustPayTrxURL = self::getParameterByName('TrustPayTrxURL');
         self::$iTrustPayIETrxURL = self::getParameterByName('TrustPayIETrxURL');
         self::$iMerchantErrorURL = self::getParameterByName('MerchantErrorURL');
         $tNewLine = self::getParameterByName('TrustPayNewLine');
         if ($tNewLine == '1') {
             self::$iNewLine = '\\n';
         } else {
             self::$iNewLine = '\\r\\n';
         }
         $tTrustPayCertFile = self::getParameterByName('TrustPayCertFile');
         self::$iTrustpayCertificate = openssl_x509_read(self::der2pem(file_get_contents($tTrustPayCertFile)));
         if (!self::$iTrustpayCertificate) {
             throw new TrxException(TrxException::TRX_EXC_CODE_1002, TrxException::TRX_EXC_MSG_1002 . "[{$tTrustPayCertFile}]!");
         }
         self::$iIsLog = self::getParameterByName('EnableLog', FALSE) == '1';
         if (self::$iIsLog) {
             self::$iLogPath = self::getParameterByName('LogPath');
         }
         //3、读取商户号
         self::$iMerchantIDs = array_filter(array_map('trim', explode(',', self::getParameterByName('MerchantID'), 100)));
         self::$iMerchantNum = count(self::$iMerchantIDs);
         //4、读取商户证书
         self::$iKeyStoreType = self::getParameterByName('MerchantKeyStoreType');
         if (self::$iKeyStoreType == self::KEY_STORE_TYPE_FILE) {
             self::bindMerchantCertificateByFile();
         } else {
             if (self::$iKeyStoreType == self::KEY_STORE_TYPE_SIGN_SERVER) {
             } else {
                 throw new TrxException(TrxException::TRX_EXC_CODE_1001, TrxException::TRX_EXC_MSG_1001 . ' - 证书储存媒体配置错误!');
             }
         }
         self::$iIsInitialed = TRUE;
     }
 }