示例#1
0
 /**
  * 生成要请求给支付宝的参数数组
  * @param $para_temp 请求前的参数数组
  * @return 要请求的参数数组
  */
 function buildRequestPara($para_temp)
 {
     //除去待签名参数数组中的空值和签名参数
     $para_filter = AlipayCore::paraFilter($para_temp);
     //对待签名参数数组排序
     $para_sort = AlipayCore::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;
 }
示例#2
0
 /**
  * 获取返回时的签名验证结果
  * @param $para_temp 通知返回来的参数数组
  * @param $sign 返回的签名结果
  * @return 签名验证结果
  */
 function getSignVeryfy($para_temp, $sign)
 {
     //除去待签名参数数组中的空值和签名参数
     $para_filter = AlipayCore::paraFilter($para_temp);
     //对待签名参数数组排序
     $para_sort = AlipayCore::argSort($para_filter);
     //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
     $prestr = AlipayCore::createLinkstring($para_sort);
     $isSgin = false;
     switch (strtoupper(trim($this->alipay_config['sign_type']))) {
         case "MD5":
             $isSgin = AlipayMd5::md5Verify($prestr, $sign, $this->alipay_config['key']);
             break;
         default:
             $isSgin = false;
     }
     return $isSgin;
 }