增加查询接口

This commit is contained in:
yansongda 2017-08-19 15:24:24 +08:00
parent 1ac3d8f188
commit fb45a0b5e8
4 changed files with 39 additions and 13 deletions

View File

@ -45,6 +45,18 @@ interface GatewayInterface
*/
public function close(array $config_biz);
/**
* 对外接口 - 订单查询
* @author yansongda <me@yansongda.cn>
*
* @version 2017-08-19
*
* @param string $out_trade_no 商家订单号
*
* @return array|boolean [description]
*/
public function find($out_trade_no);
/**
* 验证消息是否官方发出
*

View File

@ -123,6 +123,25 @@ abstract class Alipay implements GatewayInterface
return $this->getResult($config_biz, 'alipay.trade.close');
}
/**
* 对外接口 - 订单查询
* @author yansongda <me@yansongda.cn>
*
* @version 2017-08-19
*
* @param string $out_trade_no 商家订单号
*
* @return array|boolean [description]
*/
public function find($out_trade_no = '')
{
$config_biz = [
'out_trade_no' => $out_trade_no,
];
return $this->getResult($config_biz, 'alipay.trade.query');
}
/**
* 对外接口 - 验证.
*

View File

@ -149,7 +149,7 @@ abstract class Wechat implements GatewayInterface
$this->config['total_fee'] = intval($this->config['total_fee'] * 100);
$this->config['sign'] = $this->getSign($this->config);
$data = $this->fromXml($this->post($this->gateway, [], $this->toXml($this->config)));
$data = $this->fromXml($this->post($this->gateway, $this->toXml($this->config)));
if (!isset($data['return_code']) || $data['return_code'] !== 'SUCCESS' || $data['result_code'] !== 'SUCCESS') {
$error = 'preOrder error:' . $data['return_msg'];

View File

@ -41,24 +41,19 @@ trait HasHttpRequest
* Make a post request.
*
* @param string $endpoint
* @param array $params
* @param string $body
* @param mixed $params
* @param array $headers
*
* @return string
*/
protected function post($endpoint, $params = [], $body = null, $headers = [])
protected function post($endpoint, $params = [], $headers = [])
{
$options = [
'headers' => $headers,
'form_params' => $params,
];
$options['headers'] = $headers;
if (!is_null($body)) {
$options = [
'headers' => $headers,
'body' => $body,
];
if (!is_array($params)) {
$options['body'] = $params;
} else {
$options['form_params'] = $params;
}
return $this->request('post', $endpoint, $options);