예제 #1
0
 function getMysign($para_temp)
 {
     $para_filter = paraFilter($para_temp);
     $para_sort = argSort($para_filter);
     $mysign = buildMysign($para_sort, trim($this->aliapy_config['key']), strtoupper(trim($this->aliapy_config['sign_type'])));
     return $mysign;
 }
예제 #2
0
 /**
  * 生成要请求给支付宝的参数数组
  * @param $para_temp 请求前的参数数组
  * @return 要请求的参数数组
  */
 public function buildRequestPara($para_temp)
 {
     if (strtoupper(trim($this->alipay_config['sign_type'])) == 'RSA') {
         //除去待签名参数数组中的空值和签名参数
         $para_filter = paraFilter($para_temp, 2);
         //对待签名参数数组排序
         $para_sort = argSort($para_filter);
         //生成签名结果
         $mysign = $this->buildRequestMysign($para_sort);
         //签名结果与签名方式加入请求提交参数组中
         $para_sort['sign'] = $mysign;
         //20161124  使用最官方的新sdk注意:sign_type字段需要参加签名  生成的签名不要urlencode 放在数组里再进行urlencode
     } elseif (strtoupper(trim($this->alipay_config['sign_type'])) == 'MD5') {
         //除去待签名参数数组中的空值和签名参数
         $para_filter = paraFilter($para_temp);
         //对待签名参数数组排序
         $para_sort = argSort($para_filter);
         //生成签名结果
         $mysign = $this->buildRequestMysign($para_sort);
         //签名结果与签名方式加入请求提交参数组中
         $para_sort['sign'] = $mysign;
         $para_sort['sign_type'] = strtoupper(trim($this->alipay_config['sign_type']));
     }
     return $para_sort;
 }
예제 #3
0
 function getSignVeryfy($para_temp, $sign, $isSort)
 {
     $para = paraFilter($para_temp);
     if ($isSort) {
         $para = argSort($para);
     } else {
         $para = $this->sortNotifyPara($para);
     }
     $prestr = createLinkstring($para);
     $isSgin = false;
     switch (strtoupper(trim($this->alipay_config['sign_type']))) {
         case "MD5":
             $isSgin = md5Verify($prestr, $sign, $this->alipay_config['key']);
             break;
         case "RSA":
             $isSgin = rsaVerify($prestr, trim($this->alipay_config['ali_public_key_path']), $sign);
             break;
         case "0001":
             $isSgin = rsaVerify($prestr, trim($this->alipay_config['ali_public_key_path']), $sign);
             break;
         default:
             $isSgin = false;
     }
     return $isSgin;
 }
예제 #4
0
 function buildRequestPara($para_temp)
 {
     $para_filter = paraFilter($para_temp);
     $para_sort = argSort($para_filter);
     $mysign = $this->buildRequestMysign($para_sort);
     $para_sort['sign'] = $mysign;
     $para_sort['sign_type'] = strtoupper(trim($this->alipay_config['sign_type']));
     return $para_sort;
 }
예제 #5
0
 function buildRequestPara($para_temp, $aliapy_config)
 {
     $para_filter = paraFilter($para_temp);
     $para_sort = argSort($para_filter);
     $mysign = buildMysign($para_sort, trim($aliapy_config['key']), strtoupper(trim($aliapy_config['sign_type'])));
     $para_sort['sign'] = $mysign;
     $para_sort['sign_type'] = strtoupper(trim($aliapy_config['sign_type']));
     return $para_sort;
 }
예제 #6
0
 function buildRequestPara($para_temp)
 {
     $para_filter = paraFilter($para_temp);
     $para_sort = argSort($para_filter);
     $mysign = $this->buildRequestMysign($para_sort);
     $para_sort['sign'] = $mysign;
     if ($para_sort['service'] != 'alipay.wap.trade.create.direct' && $para_sort['service'] != 'alipay.wap.auth.authAndExecute') {
         $para_sort['sign_type'] = strtoupper(trim($this->alipay_config['sign_type']));
     }
     return $para_sort;
 }
예제 #7
0
 /**
  * 生成要请求给集付宝的参数数组
  * @param $para_temp 请求前的参数数组
  * @return 要请求的参数数组
  */
 function buildRequestPara($para_temp)
 {
     //除去待签名参数数组中的空值和签名参数
     $para_filter = paraFilter($para_temp);
     //对待签名参数数组排序
     $para_sort = argSort($para_filter);
     //生成签名结果
     $mysign = $this->buildRequestMysign($para_sort);
     //签名结果与签名方式加入请求提交参数组中
     $para_sort['sign'] = $mysign;
     return $para_sort;
 }
 /**
  * 生成要请求给支付宝的参数数组
  * @param $para_temp 请求前的参数数组
  * @return 要请求的参数数组
  */
 function buildRequestPara($para_temp)
 {
     //除去待签名参数数组中的空值和签名参数
     $para_filter = paraFilter($para_temp);
     //对待签名参数数组排序
     $para_sort = argSort($para_filter);
     //生成签名结果
     $mysign = $this->buildRequestMysign($para_sort);
     //签名结果与签名方式加入请求提交参数组中
     $para_sort['sign'] = $mysign;
     $para_sort['sign_type'] = strtoupper(trim($this->alipay_config['sign_type']));
     return $para_sort;
 }
예제 #9
0
 /**
  * 生成要请求给支付宝的参数数组
  * @param $para_temp 请求前的参数数组
  * @param $aliapy_config 基本配置信息数组
  * @return 要请求的参数数组
  */
 function buildRequestPara($para_temp, $aliapy_config)
 {
     //除去待签名参数数组中的空值和签名参数
     $para_filter = paraFilter($para_temp);
     //对待签名参数数组排序
     $para_sort = argSort($para_filter);
     //生成签名结果
     $mysign = buildMysign($para_sort, trim($aliapy_config['key']), strtoupper(trim($aliapy_config['sign_type'])));
     //签名结果与签名方式加入请求提交参数组中
     $para_sort['sign'] = $mysign;
     $para_sort['sign_type'] = strtoupper(trim($aliapy_config['sign_type']));
     return $para_sort;
 }
예제 #10
0
	/**

	 * 生成签名结果

	 * @param $para_sort 已排序要签名的数组

	 * return 签名结果字符串

	 */

	public function buildRequestMysign($para_sort) {

		//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串

		$prestr = createLinkstring($para_sort);

		$mysign = "";

		switch (strtoupper(trim($this->alipay_config['sign_type']))) {
예제 #11
0
 public function getSignVeryfy($para_temp, $sign)
 {
     $para_filter = paraFilter($para_temp);
     $para_sort = argSort($para_filter);
     $prestr = createLinkstring($para_sort);
     $isSgin = false;
     switch (strtoupper(trim($this->alipay_config["sign_type"]))) {
         case "MD5":
             $isSgin = md5Verify($prestr, $sign, $this->alipay_config["key"]);
             break;
         default:
             $isSgin = false;
     }
     return $isSgin;
 }
예제 #12
0
/**
 * 把请求要素按照“参数=参数值”的模式用“&”字符拼接成字符串
 * @param para 请求要素
 * @param sort 是否需要根据key值作升序排列
 * @param encode 是否需要URL编码
 * @return 拼接成的字符串
 */
function createLinkString($para, $sort, $encode)
{
    $linkString = "";
    if ($sort) {
        $para = argSort($para);
    }
    while (list($key, $value) = each($para)) {
        if ($encode) {
            $value = urlencode($value);
        }
        $linkString .= $key . upmp_config::QSTRING_EQUAL . $value . upmp_config::QSTRING_SPLIT;
    }
    //去掉最后一个&字符
    $linkString = substr($linkString, 0, count($linkString) - 2);
    return $linkString;
}
예제 #13
0
 /**
  * 生成要请求给连连支付的参数数组
  * @param $para_temp 请求前的参数数组
  * @return 要请求的参数数组
  */
 function buildRequestPara($para_temp)
 {
     //除去待签名参数数组中的空值和签名参数
     $para_filter = paraFilter($para_temp);
     //对待签名参数数组排序
     $para_sort = argSort($para_filter);
     //生成签名结果
     $mysign = $this->buildRequestMysign($para_sort);
     //签名结果与签名方式加入请求提交参数组中
     $para_sort['sign'] = $mysign;
     $para_sort['sign_type'] = strtoupper(trim($this->llpay_config['sign_type']));
     foreach ($para_sort as $key => $value) {
         $para_sort[$key] = urlencode($value);
     }
     return urldecode(json_encode($para_sort));
 }
예제 #14
0
 /**
  * 获取返回时的签名验证结果
  * @param $para_temp 通知返回来的参数数组
  * @param $sign 返回的签名结果
  * @return 签名验证结果
  */
 function getSignVeryfy($para_temp, $sign)
 {
     //除去待签名参数数组中的空值和签名参数
     $para_filter = paraFilter($para_temp);
     //对待签名参数数组排序
     $para_sort = argSort($para_filter);
     //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
     $prestr = createLinkstring($para_sort);
     $isSgin = false;
     switch (strtoupper(trim($this->alipay_config['sign_type']))) {
         case "MD5":
             $isSgin = md5Verify($prestr, $sign, $this->alipay_config['key']);
             break;
         default:
             $isSgin = false;
     }
     return $isSgin;
 }
예제 #15
0
 /**
  * 获取请求签名
  * @param $para_temp 请求的参数数组
  * @return 签名
  */
 public function getSign($para_temp)
 {
     //除去待签名参数数组中的空值和签名参数
     $para_filter = paraFilter($para_temp);
     //对待签名参数数组排序
     $para_sort = argSort($para_filter);
     //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
     $prestr = createLinkstring($para_sort);
     $isSgin = false;
     switch (strtoupper(trim($this->alipay_config['sign_type']))) {
         case "RSA":
             $isSgin = rsaSign($prestr, trim($this->alipay_config['private_key_path']));
             break;
         default:
             $isSgin = false;
     }
     return $isSgin;
 }
예제 #16
0
	function buildRequestPara($para_temp) {
				$para_filter = paraFilter($para_temp);
				$para_sort = argSort($para_filter);
				$mysign = $this->buildRequestMysign($para_sort);
				$para_sort['sign'] = $mysign;
		$para_sort['sign_type'] = strtoupper(trim($this->llpay_config['sign_type']));
		foreach ($para_sort as $key => $value) {
			$para_sort[$key] = $value;
		}
		if('3' == $this->llpay_config['app_request']) {
						if('api' == WEB_BASE_ENV_DFS::$APPNAME) {
				return json_encode($para_sort);
			} else {
				return urldecode(json_encode($para_sort));
			}
		} else {
			return $para_sort;
		}
		
	}
예제 #17
0
 /**
  * 支付宝支付
  */
 public function alipayAction()
 {
     //支付宝提供的加密方式
     include_once __DIR__ . '/../../utils/alipay/lib/alipay_core.function.php';
     $babyId = $this->devices->getBabyIdByShoeId($this->userInfo['uid'], $this->_sanReq['shoe_id']);
     if (!$babyId) {
         $this->_showMsg(self::NON_SHOE, $this->di['flagmsg'][self::NON_SHOE]);
     }
     $rel = $this->_checkRelation($this->userInfo['uid'], $babyId['baby_id']);
     //角色名
     if (!empty($rel) && $rel['family_rolename'] != '') {
         $rolename = $rel['family_rolename'];
     } else {
         $rolename = '';
     }
     //获取套餐
     $renew = $this->renew->getRenew($serviceId, 1);
     if (!$renew) {
         $this->_showMsg(self::NON_PACKAGE, $this->di['flagmsg'][self::NON_PACKAGE]);
     }
     //配置
     $alipayConf = $this->di->get('sysconfig')['payment']['alipay'];
     //签名参数
     $params['partner'] = $alipayConf['partner'];
     $params['seller_id'] = $alipayConf['seller_id'];
     $params['out_trade_no'] = (string) Common::makeOrderSn();
     $params['subject'] = $renew['cr_name'];
     $params['body'] = $renew['cr_detail'];
     $params['total_fee'] = (string) number_format($renew['cr_real_price'], '2', '.', '');
     $params['notify_url'] = $this->di->get['sysconfig']['renewServer'] . $alipayConf['notify_url'];
     $params['service'] = 'mobile.securitypay.pay';
     $params['_input_charset'] = 'utf-8';
     $params['payment_type'] = '1';
     //生成续费订单,入库
     if (($res = $this->renew->renewUpdate($shoeId, $this->userInfo['uid'], $serviceId, $_SERVER['REQUEST_TIME'], 1, $params['out_trade_no'], 1, $params['total_fee'], $params['subject'], $renew['cr_period'], $renew['cr_coins'], $rolename, $babyId['baby_id'], $babyId['dev_imei'])) != self::SUCCESS) {
         $this->_showMsg($res, $this->di['flagmsg'][$res]);
     }
     $data = makeSignstring(argSort(paraFilter($params)));
     $params['sign'] = urlencode(rsaSign($data, $alipay_config['private_key_path']));
     $this->_returnResult(array('flag' => self::SUCCESS, 'data' => urlencode($data . '&sign="' . $params['sign'] . '"&sign_type="RSA"'), 'order_no' => $params['out_trade_no']));
 }
예제 #18
0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>支付宝手机网站支付接口接口</title>
</head>
<body>
<?php 
defined('SYSTEM_IN') or exit('Access Denied');
require_once "common.php";
$payment = mysqld_select("SELECT * FROM " . table('payment') . " WHERE  enabled=1 and code='alipay' limit 1");
$configs = unserialize($payment['configs']);
//$goodtitle
$parameter = array("service" => "alipay.wap.create.direct.pay.by.user", "partner" => trim($configs['alipay_safepid']), "seller_id" => trim($configs['alipay_safepid']), "payment_type" => 1, "notify_url" => WEBSITE_ROOT . 'notify/alipay_notify.php', "return_url" => WEBSITE_ROOT . 'notify/alipay_return_url.php', "out_trade_no" => $order['ordersn'] . '-' . $order['id'], "subject" => $goodtitle, "total_fee" => $order['price'], "show_url" => WEBSITE_ROOT . mobile_url('fansindex'), "body" => $goodtitle, "_input_charset" => 'utf-8');
$para_filter = paraFilter($parameter);
$para_filter = argSort($para_filter);
$mysign_t = buildRequestMysign($para_filter, $configs['alipay_safekey']);
$para_filter['sign'] = $mysign_t;
$para_filter['sign_type'] = 'MD5';
$sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='https://mapi.alipay.com/gateway.do' method='get'>";
while (list($key, $val) = each($para_filter)) {
    $sHtml .= "<input type='hidden' name='" . $key . "' value='" . $val . "'/>";
}
$sHtml = $sHtml . "<input type='submit' style='display:none' value='确认'></form>";
$sHtml = $sHtml . "<script>document.forms['alipaysubmit'].submit();</script>";
echo $sHtml;
//	echo "<textarea rows=\"3\" cols=\"20\">1212".$sHtml."</textarea>";
exit;
?>
</body>
</html>
예제 #19
0
 /**
  * 获取返回时的签名验证结果
  * @param $para_temp 通知返回来的参数数组
  * @param $sign 返回的签名结果
  * @param $isSort 是否对待签名数组排序
  * @return 签名验证结果
  */
 function getSignVeryfy($para_temp, $sign, $isSort)
 {
     //除去待签名参数数组中的空值和签名参数
     $para = paraFilter($para_temp);
     //对待签名参数数组排序
     if ($isSort) {
         $para = argSort($para);
     } else {
         $para = sortNotifyPara($para);
     }
     //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
     $prestr = createLinkstring($para);
     $isSgin = false;
     switch (strtoupper(trim($this->alipay_config['sign_type']))) {
         case "MD5":
             $isSgin = md5Verify($prestr, $sign, $this->alipay_config['key']);
             break;
         case "RSA":
             $isSgin = rsaVerify($prestr, trim($this->alipay_config['ali_public_key_path']), $sign);
             break;
         case "0001":
             $isSgin = rsaVerify($prestr, trim($this->alipay_config['ali_public_key_path']), $sign);
             break;
         default:
             $isSgin = false;
     }
     return $isSgin;
 }
예제 #20
0
 /**
  * 获取返回时的签名验证结果
  * @param $para_temp 通知返回来的参数数组
  * @param $sign 返回的签名结果
  * @return 签名验证结果
  */
 function getSignVeryfy($para_temp, $sign)
 {
     //除去待签名参数数组中的空值和签名参数
     $para_filter = paraFilter($para_temp);
     //对待签名参数数组排序
     $para_sort = argSort($para_filter);
     //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
     $prestr = createLinkstring($para_sort);
     //		$path="ext/log.log";
     //        $fp=fopen($path,'w+');
     //        fwrite($fp,$prestr);
     //        fclose($fp);
     $isSgin = false;
     switch (strtoupper(trim($this->alipay_config['sign_type']))) {
         case "RSA":
             $isSgin = rsaVerify($prestr, trim($this->alipay_config['ali_public_key_path']), $sign);
             break;
         default:
             $isSgin = false;
     }
     return $isSgin;
 }
 public function doalipayWap()
 {
     //echo "<pre>";var_dump( $_SERVER );echo "</pre>";
     //返回格式
     $format = "xml";
     //必填,不需要修改//返回格式
     $v = "2.0";
     //这里我们通过TP的C函数把配置项参数读出,赋给$alipay_config;
     $alipay_config = C('alipay_config');
     /**************************请求参数**************************/
     $payment_type = C('alipay_config.sign_type');
     //支付类型 //必填,不能修改
     $notify_url = C('alipay.notify_urlWap');
     //服务器异步通知页面路径
     $return_url = C('alipay.return_urlWap');
     //页面跳转同步通知页面路径
     $merchant_url = C('alipay.merchant_urlWap');
     //操作中断返回地址
     $seller_email = C('alipay.seller_email');
     //卖家支付宝帐户必填
     $out_trade_no = $_POST['trade_no'];
     //商户订单号 通过支付页面的表单进行传递,注意要唯一!
     $subject = $_POST['ordsubject'];
     //订单名称 //必填 通过支付页面的表单进行传递
     $total_fee = $_POST['ordtotal_fee'];
     //付款金额  //必填 通过支付页面的表单进行传递
     $body = $_POST['ordbody'];
     //订单描述 通过支付页面的表单进行传递
     $show_url = $_POST['ordshow_url'];
     //商品展示地址 通过支付页面的表单进行传递
     $anti_phishing_key = "";
     //防钓鱼时间戳 //若要使用请调用类文件submit中的query_timestamp函数
     //$exter_invoke_ip = get_client_ip();//var_dump($exter_invoke_ip);die();   //客户端的IP地址
     $exter_invoke_ip = $_SERVER["REMOTE_ADDR"];
     //var_dump($exter_invoke_ip);die();   //客户端的IP地址
     /************************************************************/
     //对前台传过来的价钱数据做判断
     $orderId = $out_trade_no;
     $oOb = M("order");
     $orderArr = $oOb->field("count(*) as num")->where("orderId='{$orderId}'")->select();
     $num = $orderArr[0]['num'];
     if ($num == 0) {
         $coOb = M("cardorder");
         $arr = $coOb->where("orderId='{$orderId}'")->select();
         //var_dump($arr);
         $realPrice = $arr[0]['price'] - $arr[0]['discount'] - $arr[0]['yhqPrice'];
         //var_dump($total_fee); var_dump($realPrice); die;
         if ($total_fee != $realPrice) {
             header("location:index.php?m=Member&a=payFail");
         }
     } else {
         $arr = $oOb->where("orderId='{$orderId}'")->select();
         $realPrice = $arr[0]['price'] - $arr[0]['discount'] - $arr[0]['yhq'];
         if ($total_fee != $realPrice) {
             header("location:index.php?m=Member&a=payFail");
         }
     }
     $call_back_url = $return_url;
     //请求业务参数详细
     $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>';
     //echo "req_data";var_dump($req_data);echo "----------------------------------";
     //必填
     //构造要请求的参数数组,无需改动
     $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => $payment_type, "format" => $format, "v" => $v, "req_id" => $out_trade_no, "req_data" => trim($req_data), "_input_charset" => trim(strtolower($alipay_config['input_charset'])));
     //echo "<pre>";var_dump($para_token);echo "</pre>";die();
     //建立请求
     $alipaySubmit = new AlipaySubmit($alipay_config);
     $html_text = $alipaySubmit->buildRequestHttp($para_token);
     //var_dump($html_text);die();
     //URLDECODE返回的信息
     $html_text = urldecode($html_text);
     //echo "<pre>";var_dump($html_text);echo "</pre>";die();
     //解析远程模拟提交后返回的信息
     $para_html_text = $alipaySubmit->parseResponse($html_text);
     //var_dump($para_html_text);die;
     //获取request_token
     $request_token = $para_html_text['request_token'];
     //var_dump($request_token);
     /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/
     //业务详细
     $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>';
     //必填
     $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => $payment_type, "format" => $format, "v" => $v, "req_id" => $out_trade_no, "req_data" => trim($req_data), "_input_charset" => trim(strtolower($alipay_config['input_charset'])));
     //var_dump($parameter);die();
     $parameter1 = paraFilter($parameter);
     $parameter2 = argSort($parameter);
     //建立请求
     $alipaySubmit = new AlipaySubmit($alipay_config);
     $mysign = $alipaySubmit->buildRequestMysign($parameter2);
     $parameter2['sign'] = $mysign;
     //echo "<pre>";var_dump($parameter2);echo "</pre>";die();
     $html_text = $alipaySubmit->buildRequestForm($parameter2, "get", "确认");
     echo $html_text;
 }
 /**
  * 获取返回时的签名验证结果
  * @param $para_temp 通知返回来的参数数组
  * @param $sign 返回的签名结果
  * @param $isSort 是否对待签名数组排序
  * @return 签名验证结果
  */
 function getSignVeryfy($para_temp, $sign, $isSort)
 {
     //除去待签名参数数组中的空值和签名参数
     //file_put_contents("./alipaylog/getSignVeryfy_para_temp_".strftime("%Y%m%d%H%M%S",time()).".txt",print_r($para_temp,true));
     $para = paraFilter($para_temp);
     //file_put_contents("./alipaylog/getSignVeryfy_para1_".strftime("%Y%m%d%H%M%S",time()).".txt",print_r($para,true));
     //对待签名参数数组排序
     if ($isSort) {
         $para = argSort($para);
     } else {
         $para = $this->sortNotifyPara($para);
     }
     //file_put_contents("./alipaylog/getSignVeryfy_para2_".strftime("%Y%m%d%H%M%S",time()).".txt",print_r($para,true));
     //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
     $prestr = createLinkstring($para);
     //file_put_contents("./alipaylog/getSignVeryfy_prestr_".strftime("%Y%m%d%H%M%S",time()).".txt",print_r($prestr,true));
     //echo $prestr;
     $isSgin = false;
     switch (strtoupper(trim($this->alipay_config['sign_type']))) {
         case "MD5":
             $isSgin = md5Verify($prestr, $sign, $this->alipay_config['key']);
             break;
         case "RSA":
             $isSgin = rsaVerify($prestr, trim($this->alipay_config['ali_public_key_path']), $sign);
             break;
         case "0001":
             $isSgin = rsaVerify($prestr, trim($this->alipay_config['ali_public_key_path']), $sign);
             break;
         default:
             $isSgin = false;
     }
     return $isSgin;
 }
예제 #23
0
파일: common.php 프로젝트: Lazybin/huisa
/**
 * 讲数组转换为string
 *
 * @param $para 数组        	
 * @param $sort 是否需要排序        	
 * @param $encode 是否需要URL编码        	
 * @return string
 */
function createLinkString($para, $sort, $encode)
{
    if ($para == NULL || !is_array($para)) {
        return "";
    }
    $linkString = "";
    if ($sort) {
        $para = argSort($para);
    }
    while (list($key, $value) = each($para)) {
        if ($encode) {
            $value = urlencode($value);
        }
        $linkString .= $key . "=" . $value . "&";
    }
    // 去掉最后一个&字符
    $linkString = substr($linkString, 0, count($linkString) - 2);
    return $linkString;
}
예제 #24
0
 /**
  * 获取返回时的签名验证结果
  * @param $para_temp 通知返回来的参数数组
  * @param $sign 返回的签名结果
  * @return 签名验证结果
  */
 function getSignVeryfy($para_temp, $sign)
 {
     //除去待签名参数数组中的空值和签名参数
     $para_filter = paraFilter($para_temp);
     //对待签名参数数组排序
     $para_sort = argSort($para_filter);
     //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
     $prestr = createLinkstring($para_sort);
     $isSgin = false;
     switch (strtoupper(trim($this->alipay_config['sign_type']))) {
         case "RSA":
             $isSgin = rsaVerify($prestr, trim($this->alipay_config['ali_public_key_path']), $sign);
             /*
             $log_text = 'Prestr:'.$prestr.',Alipay_public_key_path:'.trim($this->alipay_config['ali_public_key_path']);
             logResult($log_text);
             */
             break;
         default:
             $isSgin = false;
     }
     return $isSgin;
 }
예제 #25
0
파일: resource.php 프로젝트: josf/folkso
/**
 * Web parameters: POST + folksores + folksotag
 * Optional : folksometa (defaults to 'normal' (1)). 
 */
function tagResource(folksoQuery $q, folksoDBconnect $dbc, folksoSession $fks)
{
    $r = new folksoResponse();
    $u = $fks->userSession(null, 'folkso', 'tag');
    if (!$u instanceof folksoUser || !$u->checkUserRight('folkso', 'tag')) {
        return $r->unAuthorized($u);
    }
    try {
        $i = new folksoDBinteract($dbc);
        $tag_args = argSort($q->res, $q->tag, $q->get_param('meta'), $i);
        $query = sprintf("CALL tag_resource('%s', %s)", $u->userid, $tag_args);
        $i->query($query);
    } catch (dbConnectionException $e) {
        $r->dbConnectionError($e->getMessage());
        return $r;
    } catch (dbQueryException $e) {
        if ($e->sqlcode == 1048) {
            if (strpos($e->getMessage(), 'resource_id')) {
                $r->setError(404, "Missing resource", "Resource " . $q->res . " has not been indexed yet.");
            } elseif (strpos($e->getMessage(), 'tag_id')) {
                $r->setError(404, 'Tag does not exist', "Tag " . $q->tag . " does not exist. " . $i->error_info());
            }
        } else {
            $r->dbQueryError($i->error_info());
        }
        return $r;
    }
    $r->setOk(200, "Tagged");
    $r->t("Resource has been tagged");
    return $r;
}
예제 #26
0
 /**
  * 获取返回时的签名验证结果
  * @param $para_temp 通知返回来的参数数组
  * @param $sign 返回的签名结果
  * @return 签名验证结果
  */
 public function getSignVeryfy($para_temp, $sign)
 {
     //除去待签名参数数组中的空值和签名参数
     if (strtoupper(trim($this->alipay_config['sign_type'])) == 'RSA') {
         $para_filter = paraFilter($para_temp, 3);
         //参数需要urldecode
     } else {
         $para_filter = paraFilter($para_temp);
     }
     //对待签名参数数组排序
     $para_sort = argSort($para_filter);
     //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
     $prestr = createLinkstring($para_sort);
     $isSgin = false;
     switch (strtoupper(trim($this->alipay_config['sign_type']))) {
         case 'MD5':
             $isSgin = md5Verify($prestr, $sign, $this->alipay_config['key']);
             break;
         case 'RSA':
             $isSgin = rsaVerify($prestr, $this->alipay_config['alipay_public_key'], $sign);
             break;
         default:
             $isSgin = false;
     }
     return $isSgin;
 }
예제 #27
0
	function getSignVeryfy($para_temp, $sign) {
				$para_filter = paraFilter($para_temp);

				$para_sort = argSort($para_filter);

				$prestr = createLinkstring($para_sort);

		true === DEBUG_LIANLIANPAY && file_put_contents(ROOT_PATH . "errorlog/pay.lianlianpay.".date("Ym").".log", "原串:" . $prestr . "\n", FILE_APPEND);
		true === DEBUG_LIANLIANPAY && file_put_contents(ROOT_PATH . "errorlog/pay.lianlianpay.".date("Ym").".log", "sign:" . $sign . "\n", FILE_APPEND);
		$isSgin = false;
		switch (strtoupper(trim($this->llpay_config['sign_type']))) {
			case "MD5" :
				$isSgin = md5Verify($prestr, $sign, $this->llpay_config['key']);
				break;
			default :
				$isSgin = false;
		}

		return $isSgin;
	}
예제 #28
0
identityid	用户标识	用户ID	不可空
productname	商品名称	最长50位,出于风控考虑,请按下面的格式传递值:应用-商品名称,如“诛仙-3阶成品天琊”,此商品名在发送短信校验的时候会发给用户,所以描述内容不要加在此参数中,以提高用户的体验度	不可空
productdesc	商品描述	最长200位	可空
appcallbackurl	第3方平台异步通知地址		可空
appkey	应用id	Sdk后台申请	不可空
sign	本系统签名		不可空
*/
$key = "jz";
//干扰码:jz
$notice_sn = $_REQUEST['apporderid'];
$trade_no = $_REQUEST['order_id'];
$sign = $_REQUEST['sign'];
//除去待签名参数数组中的空值和签名参数
$para_filter = paraFilter($_REQUEST);
//对待签名参数数组排序
$para_sort = argSort($para_filter);
//生成签名结果
$sign_str = createLinkstring($para_sort);
$mysign = md5($sign_str . $key);
/*
$sign_str = $amount.$apporderid.$order_id;
$mysign = md5($sing_str.$key);
*/
if ($sign == $mysign) {
    $apporderid = $_REQUEST['apporderid'];
    $payment_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment_notice where notice_sn = '" . $notice_sn . "'");
    require_once APP_ROOT_PATH . "system/libs/cart.php";
    $rs = payment_paid($notice_sn, $trade_no);
    if ($rs) {
        $GLOBALS['db']->query("update " . DB_PREFIX . "payment_notice set outer_notice_sn = '" . $trade_no . "' where id = " . $payment_notice['id']);
    }
예제 #29
0
 /**
  * 根据反馈回来的信息,生成签名结果
  * @param $para_temp 通知返回来的参数数组
  * @return 生成的签名结果
  */
 function getMysign($para_temp)
 {
     //除去待签名参数数组中的空值和签名参数
     $para_filter = paraFilter($para_temp);
     //对待签名参数数组排序
     $para_sort = argSort($para_filter);
     //生成签名结果
     $mysign = buildMysign($para_sort, trim($this->aliapy_config['key']), strtoupper(trim($this->aliapy_config['sign_type'])));
     return $mysign;
 }
예제 #30
0
파일: common.php 프로젝트: skystar/cms
function getSignVeryfy($para_temp, $sign, $md5)
{
    //除去待签名参数数组中的空值和签名参数
    $para_filter = paraFilter($para_temp);
    //对待签名参数数组排序
    $para_sort = argSort($para_filter);
    //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
    $prestr = createLinkstring($para_sort);
    $isSgin = false;
    $isSgin = md5Verify($prestr, $sign, $md5);
    return $isSgin;
}