Kirin 3 år sedan
förälder
incheckning
85111e1fed

+ 4 - 4
vendor/overtrue/wechat/src/Payment/API.php

@@ -441,7 +441,7 @@ class API extends AbstractAPI
      *
      * @return \EasyWeChat\Support\Collection|\Psr\Http\Message\ResponseInterface
      */
-    protected function request($api, array $params, $method = 'post', array $options = [], $returnResponse = false)
+    protected function request($api, array $params, $method = 'post', array $options = [], $returnResponse = false, $sign_type = 'md5')
     {
         $params = array_merge($params, $this->merchant->only(['sub_appid', 'sub_mch_id']));
 
@@ -451,7 +451,7 @@ class API extends AbstractAPI
         $params['nonce_str'] = uniqid();
         $params = array_filter($params);
 
-        $params['sign'] = generate_sign($params, $this->getSignkey($api), 'md5');
+        $params['sign'] = generate_sign($params, $this->getSignkey($api), $sign_type);
 
         $options = array_merge([
             'body' => XML::build($params),
@@ -483,14 +483,14 @@ class API extends AbstractAPI
      *
      * @return \EasyWeChat\Support\Collection
      */
-    protected function safeRequest($api, array $params, $method = 'post')
+    protected function safeRequest($api, array $params, $method = 'post', $sign_type = 'md5')
     {
         $options = [
             'cert' => $this->merchant->get('cert_path'),
             'ssl_key' => $this->merchant->get('key_path'),
         ];
 
-        return $this->request($api, $params, $method, $options);
+        return $this->request($api, $params, $method, $options,false, $sign_type);
     }
 
     /**

+ 1 - 1
vendor/overtrue/wechat/src/Payment/helpers.php

@@ -36,7 +36,7 @@ function generate_sign(array $attributes, $key, $encryptMethod = 'md5')
 
     $attributes['key'] = $key;
 
-    return strtoupper(call_user_func_array($encryptMethod, [urldecode(http_build_query($attributes))]));
+    return strtoupper(call_user_func_array($encryptMethod, $encryptMethod == "md5" ? [urldecode(http_build_query($attributes))] : ['sha256', urldecode(http_build_query($attributes)), $key]));
 }
 
 /**