WIN-2308041133\Administrator 2 tygodni temu
rodzic
commit
5a52c3bfea
1 zmienionych plików z 4 dodań i 66 usunięć
  1. 4 66
      vendor/overtrue/wechat/src/Payment/API.php

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

@@ -482,79 +482,17 @@ class API extends AbstractAPI
         $params['nonce_str'] = uniqid();
         $params = array_filter($params);
         @file_put_contents('quanju2.txt',  json_encode($this->getSignkey($api))."-微信支付失败9\r\n", 8);
-        $params = [
-            'appid' => 'wxc249a20cfeed19cd',
-            'body' => 'test',
-            'mch_id' => '1731458899',
-            'nonce_str' => 'test123456',
-            'notify_url' => 'http://gcshop.qiniu1314.com/api/wechat/notify',
-            'openid' => 'o4h8g2NHKRUxkKw3ZKcDjZq0RojA',
-            'out_trade_no' => 'test' . time(),
-            'spbill_create_ip' => '127.0.0.1',
-            'total_fee' => 1,
-            'trade_type' => 'JSAPI'
-        ];
-
-// 排序并生成签名
         ksort($params);
-        $apiKey = '8BwxEDhWF3BmUDbYpasb4c5kBchnEFfB';
-        $stringA = '';
-        foreach ($params as $k => $v) {
-            $stringA .= $k . '=' . $v . '&';
-        }
-        $stringA = rtrim($stringA, '&');
-        $stringSignTemp = $stringA . '&key=' . $apiKey;
-        $params['sign'] = strtoupper(md5($stringSignTemp));
-
-// 生成XML
-        $xml = '<xml>';
-        foreach ($params as $key => $val) {
-            if (is_numeric($val)) {
-                $xml .= "<{$key}>{$val}</{$key}>";
-            } else {
-                $xml .= "<{$key}><![CDATA[{$val}]]></{$key}>";
-            }
-        }
-        $xml .= '</xml>';
-
-// 发送请求
-        $ch = curl_init();
-        curl_setopt_array($ch, [
-            CURLOPT_URL => 'https://api.mch.weixin.qq.com/pay/unifiedorder',
-            CURLOPT_POST => true,
-            CURLOPT_RETURNTRANSFER => true,
-            CURLOPT_POSTFIELDS => $xml,
-            CURLOPT_HTTPHEADER => ['Content-Type: application/xml'],
-            CURLOPT_TIMEOUT => 10,
-            CURLOPT_SSL_VERIFYPEER => false,
-            CURLOPT_SSL_VERIFYHOST => false,
-        ]);
-
-        $response = curl_exec($ch);
-        @file_put_contents('quanju2.txt',  json_encode($response)."-自己测试2\r\n", 8);
-
-        $error = curl_error($ch);
-        curl_close($ch);
-
-        echo "Request XML:\n$xml\n\n";
-        echo "Response:\n$response\n";
-        if ($error) {
-            @file_put_contents('quanju2.txt',  json_encode($error)."-自己测试1\r\n", 8);
-            echo "cURL Error: $error\n";
-        }
-        die();
-        ksort($params2);
-//        ksort($params);
-        foreach ($params2 as $key => $value) {
+        foreach ($params as $key => $value) {
             $cleanValue = preg_replace('/\s+/', ' ', trim($value));
             if ($value !== $cleanValue) {
                 file_put_contents('quanju2.txt', "参数 {$key} 包含隐藏字符\n原始: '" . $value . "'\n清理: '" . $cleanValue . "'\n", FILE_APPEND);
             }
         }
-        $params2['sign'] = generate_sign($params2, $this->getSignkey($api), 'md5');
-        @file_put_contents('quanju2.txt',  json_encode($params2)."-微信支付失败7\r\n", 8);
+        $params['sign'] = generate_sign($params, $this->getSignkey($api), 'md5');
+        @file_put_contents('quanju2.txt',  json_encode($params)."-微信支付失败7\r\n", 8);
         $options = array_merge([
-            'body' => XML::build($params2),
+            'body' => XML::build($params),
         ], $options);
         @file_put_contents('quanju2.txt',  json_encode($options)."-微信支付失败10\r\n", 8);
         $response = $this->getHttp()->request($api, $method, $options);