Пример #1
0
 /**
  * 生成要请求给支付宝的参数数组
  * @param $para_temp 请求前的参数数组
  * @return 要请求的参数数组
  */
 public function buildRequestPara($para_temp, $partnerKey)
 {
     //除去待签名参数数组中的空值和签名参数
     $para_filter = EasyHelpers::paraFilter($para_temp, ['sign', 'sign_type']);
     //对待签名参数数组排序
     $para_sort = EasyHelpers::argSort($para_filter);
     //生成签名结果
     $mysign = $this->buildRequestMysign($para_sort, $partnerKey);
     //签名结果与签名方式加入请求提交参数组中
     $para_sort['sign'] = $mysign;
     $para_sort['sign_type'] = 'MD5';
     return $para_sort;
 }
Пример #2
0
 /**
  * 生成签名;
  * @param array $data
  * @return string
  */
 private static function sign($data = [])
 {
     $params = $data ?: self::$config;
     $fileter = EasyHelpers::paraFilter($params);
     $sort = EasyHelpers::argSort($fileter);
     $url = EasyHelpers::createLinkstring($sort);
     $keyString = $url . '&key=' . \Yii::$app->params['wechatPay']['key'];
     $sign = strtoupper(md5($keyString));
     self::$config['sign'] = $sign;
     return $sign;
 }