Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 359e7c5

Browse files
committed
Merge branch 'develop'
* develop: update http request method
2 parents 71c773d + 7b275c3 commit 359e7c5

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

src/Message/RefundOrderRequest.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Omnipay\WechatPay\Message;
44

5-
use Guzzle\Http\Client;
5+
use GuzzleHttp\Client;
66
use Omnipay\Common\Exception\InvalidRequestException;
77
use Omnipay\Common\Message\ResponseInterface;
88
use Omnipay\WechatPay\Helper;
@@ -29,7 +29,7 @@ public function getData()
2929
{
3030
$this->validate('app_id', 'mch_id', 'out_trade_no', 'cert_path', 'key_path');
3131

32-
$data = array(
32+
$data = [
3333
'appid' => $this->getAppId(),
3434
'mch_id' => $this->getMchId(),
3535
'sub_appid' => $this->getSubAppId(),
@@ -43,7 +43,7 @@ public function getData()
4343
'refund_fee_type' => $this->getRefundFee(),//<>
4444
'op_user_id' => $this->getOpUserId() ?: $this->getMchId(),
4545
'nonce_str' => md5(uniqid()),
46-
);
46+
];
4747

4848
$data = array_filter($data);
4949

@@ -239,20 +239,15 @@ public function setKeyPath($keyPath)
239239
*/
240240
public function sendData($data)
241241
{
242-
$options = array(
243-
CURLOPT_SSL_VERIFYPEER => true,
244-
CURLOPT_SSL_VERIFYHOST => 2,
245-
CURLOPT_SSLCERTTYPE => 'PEM',
246-
CURLOPT_SSLKEYTYPE => 'PEM',
247-
CURLOPT_SSLCERT => $this->getCertPath(),
248-
CURLOPT_SSLKEY => $this->getKeyPath(),
249-
);
250-
251-
$body = Helper::array2xml($data);
252-
$request = $this->httpClient->post($this->endpoint, null, $data)->setBody($body);
253-
$request->getCurlOptions()->overwriteWith($options);
254-
$response = $request->send()->getBody();
255-
$responseData = Helper::xml2array($response);
242+
$body = Helper::array2xml($data);
243+
$client = new Client();
244+
$result = $client->request('POST', $this->endpoint, [
245+
'body' => $body,
246+
'verify' => true,
247+
'cert' => $this->getCertPath(),
248+
'ssl_key' => $this->getKeyPath(),
249+
])->getBody()->getContents();
250+
$responseData = Helper::xml2array($result);
256251

257252
return $this->response = new RefundOrderResponse($this, $responseData);
258253
}

0 commit comments

Comments
 (0)