/**
  * 生成接口参数xml
  */
 function createXml()
 {
     try {
         //检测必填参数
         if ($this->parameters["out_trade_no"] == null && $this->parameters["transaction_id"] == null) {
             throw new Sp_Payment_Weixinpay_SDKRuntimeException("退款申请接口中,out_trade_no、transaction_id至少填一个!" . "<br>");
         } elseif ($this->parameters["out_refund_no"] == null) {
             throw new Sp_Payment_Weixinpay_SDKRuntimeException("退款申请接口中,缺少必填参数out_refund_no!" . "<br>");
         } elseif ($this->parameters["total_fee"] == null) {
             throw new Sp_Payment_Weixinpay_SDKRuntimeException("退款申请接口中,缺少必填参数total_fee!" . "<br>");
         } elseif ($this->parameters["refund_fee"] == null) {
             throw new Sp_Payment_Weixinpay_SDKRuntimeException("退款申请接口中,缺少必填参数refund_fee!" . "<br>");
         } elseif ($this->parameters["op_user_id"] == null) {
             throw new Sp_Payment_Weixinpay_SDKRuntimeException("退款申请接口中,缺少必填参数op_user_id!" . "<br>");
         }
         $_settings = Loader::config('pay');
         $this->parameters["appid"] = $_settings['weixinpay']['virCardNoIn'];
         //公众账号ID
         $this->parameters["mch_id"] = $_settings['weixinpay']['p1_MerId'];
         //商户号
         $this->parameters["nonce_str"] = $this->createNoncestr();
         //随机字符串
         $this->parameters["sign"] = $this->getSign($this->parameters);
         //签名
         return $this->arrayToXml($this->parameters);
     } catch (Sp_Payment_Weixinpay_SDKRuntimeException $e) {
         die($e->errorMessage());
     }
 }
 /**
  * function description
  * 
  * @param
  * @return void
  */
 public static function allConfig()
 {
     static $_settings = null;
     if ($_settings === null) {
         $_settings = Loader::config('pay');
     }
     return $_settings;
 }
 /**
  * function description
  *
  * @param
  * @return void
  */
 public static function allConfig()
 {
     static $_settings = null;
     if ($_settings === null) {
         $_settings = Loader::config(self::CONFIG_NODE);
     }
     return $_settings;
 }
Example #4
0
 /**
  * construct function
  */
 function cache_cla()
 {
     $this->config =& Loader::config();
     $engine = $this->config['cache_engine'];
     include_once LIBDIR . '/cache/' . $engine . '.php';
     $enginename = 'cache_' . $engine;
     $cache_policy = isset($this->config['cache_policy']) ? $this->config['cache_policy'] : array();
     $this->_cache = new $enginename($cache_policy);
 }
 function getReqHmacString($version, $tranCode, $merchantID, $merOrderNum, $tranAmt, $feeAmt, $tranDateTime, $frontMerUrl, $backgroundMerUrl, $orderId, $gopayOutOrderId, $tranIP, $respCode, $gopayServerTime, $verficationCode)
 {
     $_settings = Loader::config('pay');
     if (!isset($_settings['gopay'])) {
         throw new Exception('payment node [gopay] not found');
         //return null;
     }
     $signStr = 'version=[' . $version . ']tranCode=[' . $tranCode . ']merchantID=[' . $merchantID . ']merOrderNum=[' . $merOrderNum . ']tranAmt=[' . $tranAmt . ']feeAmt=[' . $feeAmt . ']tranDateTime=[' . $tranDateTime . ']frontMerUrl=[' . $frontMerUrl . ']backgroundMerUrl=[' . $backgroundMerUrl . ']orderId=[' . $orderId . ']gopayOutOrderId=[' . $gopayOutOrderId . ']tranIP=[' . $tranIP . ']respCode=[' . $respCode . ']gopayServerTime=[' . $gopayServerTime . ']VerficationCode=[' . $verficationCode . ']';
     return md5($signStr);
 }
 /**
  * 加载配置信息
  * 
  * @param string $section
  * @return array
  */
 public static function config($section)
 {
     static $_settings = null;
     if ($_settings === null) {
         $_settings = Loader::config('search');
     }
     if (!isset($_settings[$section])) {
         return null;
     }
     return $_settings[$section];
 }
Example #7
0
 public static function &get($type, $name = false)
 {
     if (!isset(self::$config[$type])) {
         self::$config[$type] = Loader::config($type);
     }
     if ($name) {
         return self::$config[$type][$name];
     } else {
         return self::$config[$type];
     }
 }
 /**
  * 	作用:设置标配的请求参数,生成签名,生成接口参数xml
  */
 function createXml()
 {
     $_settings = Loader::config('pay');
     $this->parameters["appid"] = $_settings['weixinpay']['virCardNoIn'];
     //公众账号ID
     $this->parameters["mch_id"] = $_settings['weixinpay']['p1_MerId'];
     //商户号
     $this->parameters["nonce_str"] = $this->createNoncestr();
     //随机字符串
     $this->parameters["sign"] = $this->getSign($this->parameters);
     //签名
     return $this->arrayToXml($this->parameters);
 }
 /**
  * 生成接口参数xml
  */
 function createXml()
 {
     try {
         if ($this->parameters["long_url"] == null) {
             throw new Sp_Payment_Weixinpay_SDKRuntimeException("短链接转换接口中,缺少必填参数long_url!" . "<br>");
         }
         $_settings = Loader::config('pay');
         $this->parameters["appid"] = $_settings['weixinpay']['virCardNoIn'];
         //公众账号ID
         $this->parameters["mch_id"] = $_settings['weixinpay']['p1_MerId'];
         //商户号
         $this->parameters["nonce_str"] = $this->createNoncestr();
         //随机字符串
         $this->parameters["sign"] = $this->getSign($this->parameters);
         //签名
         return $this->arrayToXml($this->parameters);
     } catch (Sp_Payment_Weixinpay_SDKRuntimeException $e) {
         die($e->errorMessage());
     }
 }
function checkCached($res, $priv, $ctl, $format)
{
    if ($format == 'html') {
        return 0;
    }
    $ac = Loader::config("admin.cache");
    if (isset($ac[$res]) && isset($ac[$res][$priv])) {
        $request = Request::current();
        $ret = $ac[$res][$priv];
        $str = '';
        if (isset($ret['params'])) {
            foreach (explode(',', $ret['params']) as $param) {
                $v = $request->{$param};
                if (!is_null($v)) {
                    $str .= $v;
                }
            }
        }
        $ret['cache_key'] = sprintf("dust_ac_%s_%s_%u_%s", strtolower($res), strtolower($priv), crc32($str), $request->format);
        return $ret;
    }
    return 0;
}
 public static function getCallbackHmacString($r0_Cmd, $r1_Code, $r2_TrxId, $r3_Amt, $r4_Cur, $r5_Pid, $r6_Order, $r7_Uid, $r8_MP, $r9_BType)
 {
     //include 'merchantProperties.php';
     $_settings = Loader::config('pay');
     if (!isset($_settings['yeepay'])) {
         throw new Exception('payment node [yeepay] not found');
         //return null;
     }
     #取得加密前的字符串
     $sbOld = "";
     #加入商家ID
     $sbOld = $sbOld . $_settings['yeepay']['p1_MerId'];
     #加入消息类型
     $sbOld = $sbOld . $r0_Cmd;
     #加入业务返回码
     $sbOld = $sbOld . $r1_Code;
     #加入交易ID
     $sbOld = $sbOld . $r2_TrxId;
     #加入交易金额
     $sbOld = $sbOld . $r3_Amt;
     #加入货币单位
     $sbOld = $sbOld . $r4_Cur;
     #加入产品Id
     $sbOld = $sbOld . $r5_Pid;
     #加入订单ID
     $sbOld = $sbOld . $r6_Order;
     #加入用户ID
     $sbOld = $sbOld . $r7_Uid;
     #加入商家扩展信息
     $sbOld = $sbOld . $r8_MP;
     #加入交易结果返回类型
     $sbOld = $sbOld . $r9_BType;
     $merchantKey = $_settings['yeepay']['merchantKey'];
     //logstr($r6_Order,$sbOld,HmacMd5($sbOld,$merchantKey));
     return self::HmacMd5($sbOld, $merchantKey);
 }
 /**
  * 生成Native支付链接二维码
  */
 function createLink()
 {
     try {
         if ($this->parameters["product_id"] == null) {
             throw new Sp_Payment_Weixinpay_SDKRuntimeException("缺少Native支付二维码链接必填参数product_id!" . "<br>");
         }
         $_settings = Loader::config('pay');
         $this->parameters["appid"] = $_settings['weixinpay']['virCardNoIn'];
         //公众账号ID
         $this->parameters["mch_id"] = $_settings['weixinpay']['p1_MerId'];
         //商户号
         $time_stamp = time();
         $this->parameters["time_stamp"] = "{$time_stamp}";
         //时间戳
         $this->parameters["nonce_str"] = $this->createNoncestr();
         //随机字符串
         $this->parameters["sign"] = $this->getSign($this->parameters);
         //签名
         $bizString = $this->formatBizQueryParaMap($this->parameters, false);
         $this->url = "weixin://wxpay/bizpayurl?" . $bizString;
     } catch (Sp_Payment_Weixinpay_SDKRuntimeException $e) {
         die($e->errorMessage());
     }
 }
 /**
  * 	作用:使用证书,以post方式提交xml到对应的接口url
  */
 function postXmlSSLCurl($xml, $url, $second = 30)
 {
     $ch = curl_init();
     //超时时间
     curl_setopt($ch, CURLOPT_TIMEOUT, $second);
     //这里设置代理,如果有的话
     //curl_setopt($ch,CURLOPT_PROXY, '8.8.8.8');
     //curl_setopt($ch,CURLOPT_PROXYPORT, 8080);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
     //设置header
     curl_setopt($ch, CURLOPT_HEADER, FALSE);
     //要求结果为字符串且输出到屏幕上
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
     $_settings = Loader::config('pay');
     //设置证书
     //使用证书:cert 与 key 分别属于两个.pem文件
     //默认格式为PEM,可以注释
     curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'PEM');
     curl_setopt($ch, CURLOPT_SSLCERT, $_settings['weixinpay']['sslcertPath']);
     //默认格式为PEM,可以注释
     curl_setopt($ch, CURLOPT_SSLKEYTYPE, 'PEM');
     curl_setopt($ch, CURLOPT_SSLKEY, $_settings['weixinpay']['sslkeyPath']);
     //post提交方式
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
     $data = curl_exec($ch);
     //返回结果
     if ($data) {
         curl_close($ch);
         return $data;
     } else {
         $error = curl_errno($ch);
         echo "curl出错,错误码:{$error}" . "<br>";
         echo "<a href='http://curl.haxx.se/libcurl/c/libcurl-errors.html'>错误原因查询</a></br>";
         curl_close($ch);
         return false;
     }
 }
 /**
  * 	作用:设置jsapi的参数
  */
 public function getParameters()
 {
     $_settings = Loader::config('pay');
     $jsApiObj["appId"] = $_settings['weixinpay']['virCardNoIn'];
     //公众账号ID
     $timeStamp = time();
     $jsApiObj["timeStamp"] = "{$timeStamp}";
     $jsApiObj["nonceStr"] = $this->createNoncestr();
     $jsApiObj["package"] = "prepay_id={$this->prepay_id}";
     $jsApiObj["signType"] = "MD5";
     $jsApiObj["paySign"] = $this->getSign($jsApiObj);
     $this->parameters = json_encode($jsApiObj, false);
     return $this->parameters;
 }
 static function filtUserSet($user_id, $section, &$types)
 {
     $user_set = Sp_Message_Message::getMessageSet($user_id, $section);
     if ($user_set) {
         $user_set = current($user_set);
     } else {
         //加载默认设置
         $user_set = Loader::config('message');
         $user_set = $user_set[$section]['channel'];
     }
     if ($user_set['email'] == 0 or $user_set['email']['default'] == 0) {
         unset($types['email']);
     }
     if ($user_set['sms'] == 0 or $user_set['sms']['default'] == 0) {
         unset($types['sms']);
     }
     if ($user_set['mess'] == 0 or $user_set['mess']['default'] == 0) {
         unset($types['mess']);
     }
     unset($types['ischeckuser']);
 }
/**
 * 获取应用的全不配置信息
 * @return array
 */
function getConfigs()
{
    if (defined("RUN_CLI")) {
        $appConfigs = Loader::config('app');
        //加载当前应用的配置信息
        return $appConfigs;
    } else {
        $webapp = \herosphp\core\WebApplication::getInstance();
        return $webapp->getConfigs();
    }
}
 public static function load($config)
 {
     if (is_array($config)) {
         self::$ini = array_merge(self::$ini, $config);
     } else {
         $arr = explode('.', $config);
         $key = $arr[0];
         if (self::$ini[$key]) {
             return;
         }
         $ini = Loader::config($key);
         if (is_array($ini)) {
             self::$ini = array_merge(self::$ini, array($key => $ini));
         } else {
             throw new Exception(sprintf("配置文件不存在 -> <span class='error'>%s</span>", $config));
         }
     }
 }
 public static function configValue($ns, $db = null, $node = null, $name)
 {
     $cfg = Loader::config(self::CONF_NAME);
     $ret =& $cfg[$name];
     if (isset($cfg[$ns])) {
         $cfg =& $cfg[$ns];
     }
     if (isset($cfg[$name])) {
         $ret =& $cfg[$name];
     }
     if ($db != null && isset($cfg[$db])) {
         $cfg =& $cfg[$db];
         if (isset($cfg[$name])) {
             $ret =& $cfg[$name];
         }
     }
     if ($node != null && isset($cfg[$node])) {
         $cfg =& $cfg[$node];
         if (isset($cfg[$name])) {
             $ret =& $cfg[$name];
         }
     }
     return $ret;
 }