Commit ec0fa8d7 by 丁铜欣

微诺付支付

1 parent ec821ad6
...@@ -24,7 +24,10 @@ class ChargeData extends WNFBaseData ...@@ -24,7 +24,10 @@ class ChargeData extends WNFBaseData
'appid' => $this->appid, 'appid' => $this->appid,
'payType' => $this->payType, 'payType' => $this->payType,
'callbackUrl' => $this->callbackUrl, 'callbackUrl' => $this->callbackUrl,
'goodsListItem ' => $this->goodsListItem//商品列表,此处应该是数组 'goodsListItem' => $this->goodsListItem,//商品列表,此处应该是数组
'taxNo' => $this->taxNo ?? '',
'appKey' => $this->appKey ?? '',
'deptId' => $this->deptId ?? ''
]; ];
$this->retData = $data; $this->retData = $data;
} }
......
...@@ -59,8 +59,9 @@ abstract class WNFBaseStrategy implements BaseStrategy ...@@ -59,8 +59,9 @@ abstract class WNFBaseStrategy implements BaseStrategy
{ {
$curl = new Curl(); $curl = new Curl();
return $curl->set([ return $curl->set([
'CURLOPT_HEADER' => 0 'CURLOPT_HEADER' => 0,
])->post($body, $url)->submit($url); 'CURLOPT_HTTPHEADER' => ['Content-Type: application/json']
])->post($body, $url)->submit($url,false,true);
} }
/** /**
...@@ -83,9 +84,12 @@ abstract class WNFBaseStrategy implements BaseStrategy ...@@ -83,9 +84,12 @@ abstract class WNFBaseStrategy implements BaseStrategy
$this->reqData->setSign(); $this->reqData->setSign();
$body = $this->reqData->getData(); $body = $this->reqData->getData();
debug([
'title'=>'请求参数',
'body' => $body
]);
$ret = $this->sendReq($body); $ret = $this->sendReq($body);
return $this->retData($ret); return $this->retData($ret);
} }
...@@ -107,7 +111,7 @@ abstract class WNFBaseStrategy implements BaseStrategy ...@@ -107,7 +111,7 @@ abstract class WNFBaseStrategy implements BaseStrategy
*/ */
protected function retData(array $ret) protected function retData(array $ret)
{ {
return $ret; return $ret['body'];
} }
} }
\ No newline at end of file
...@@ -17,6 +17,7 @@ class Curl ...@@ -17,6 +17,7 @@ class Curl
private $default; private $default;
private $download; private $download;
private $isJsonStr=false; private $isJsonStr=false;
private $isWnfJson=false;
private static $instance; private static $instance;
public function __construct() public function __construct()
...@@ -122,7 +123,7 @@ class Curl ...@@ -122,7 +123,7 @@ class Curl
* @param string $url * @param string $url
* @return array * @return array
*/ */
public function submit($url,$isJsonStr= false) public function submit($url,$isJsonStr= false, $isWnfJson = false)
{ {
if (! $this->post) { if (! $this->post) {
return array( return array(
...@@ -131,6 +132,7 @@ class Curl ...@@ -131,6 +132,7 @@ class Curl
); );
} }
$this->isJsonStr = $isJsonStr; $this->isJsonStr = $isJsonStr;
$this->isWnfJson = $isWnfJson;
return $this->set('CURLOPT_URL', $url)->exec(); return $this->set('CURLOPT_URL', $url)->exec();
} }
...@@ -222,6 +224,8 @@ class Curl ...@@ -222,6 +224,8 @@ class Curl
curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POST, true);
if($this->isJsonStr){ if($this->isJsonStr){
curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($this->postFieldsBuild($this->post))); curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($this->postFieldsBuild($this->post)));
}elseif ($this->isWnfJson){//微诺付json字符串不能一维化
curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($this->post));
}else{ }else{
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postFieldsBuild($this->post)); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postFieldsBuild($this->post));
} }
...@@ -233,6 +237,13 @@ class Curl ...@@ -233,6 +237,13 @@ class Curl
// 检查错误 // 检查错误
$errno = curl_errno($ch); $errno = curl_errno($ch);
debug([
'title' => '结果',
'body' => $body,
'http_code' => $info['http_code'],
'errno' => $errno,
'post' => json_encode($this->postFieldsBuild($this->post))
]);
if ($errno === 0 && $info['http_code'] >= 400) { if ($errno === 0 && $info['http_code'] >= 400) {
$errno = $info['http_code']; $errno = $info['http_code'];
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!