|
|
@@ -456,7 +456,25 @@ class API extends AbstractAPI
|
|
|
'body' => XML::build($params),
|
|
|
], $options);
|
|
|
|
|
|
- dump($options);
|
|
|
+ $response = $this->getHttp()->request($api, $method, $options);
|
|
|
+
|
|
|
+ return $returnResponse ? $response : $this->parseResponse($response);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function request2($api, array $params, $method = 'post', array $options = [], $returnResponse = false)
|
|
|
+ {
|
|
|
+ $params = array_merge($params);
|
|
|
+
|
|
|
+ $params['mch_appid'] = $this->merchant->app_id;
|
|
|
+ $params['mchid'] = $this->merchant->merchant_id;
|
|
|
+ $params['nonce_str'] = uniqid();
|
|
|
+ $params = array_filter($params);
|
|
|
+
|
|
|
+ $params['sign'] = generate_sign($params, $this->getSignkey($api), 'sha25');
|
|
|
+
|
|
|
+ $options = array_merge([
|
|
|
+ 'body' => XML::build($params),
|
|
|
+ ], $options);
|
|
|
|
|
|
$response = $this->getHttp()->request($api, $method, $options);
|
|
|
|
|
|
@@ -494,6 +512,16 @@ class API extends AbstractAPI
|
|
|
return $this->request($api, $params, $method, $options);
|
|
|
}
|
|
|
|
|
|
+ protected function safeRequest2($api, array $params, $method = 'post')
|
|
|
+ {
|
|
|
+ $options = [
|
|
|
+ 'cert' => $this->merchant->get('cert_path'),
|
|
|
+ 'ssl_key' => $this->merchant->get('key_path'),
|
|
|
+ ];
|
|
|
+
|
|
|
+ return $this->request2($api, $params, $method, $options);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Parse Response XML to array.
|
|
|
*
|
|
|
@@ -582,6 +610,6 @@ class API extends AbstractAPI
|
|
|
'desc' => $mark,
|
|
|
're_user_name' => '',
|
|
|
];
|
|
|
- return $this->safeRequest($this->wrapApi(self::api_batches), $params);
|
|
|
+ return $this->safeRequest2($this->wrapApi(self::api_batches), $params);
|
|
|
}
|
|
|
}
|