Commit ec0fa8d7 by 丁铜欣

微诺付支付

1 parent ec821ad6
......@@ -24,7 +24,10 @@ class ChargeData extends WNFBaseData
'appid' => $this->appid,
'payType' => $this->payType,
'callbackUrl' => $this->callbackUrl,
'goodsListItem ' => $this->goodsListItem//商品列表,此处应该是数组
'goodsListItem' => $this->goodsListItem,//商品列表,此处应该是数组
'taxNo' => $this->taxNo ?? '',
'appKey' => $this->appKey ?? '',
'deptId' => $this->deptId ?? ''
];
$this->retData = $data;
}
......
......@@ -59,8 +59,9 @@ abstract class WNFBaseStrategy implements BaseStrategy
{
$curl = new Curl();
return $curl->set([
'CURLOPT_HEADER' => 0
])->post($body, $url)->submit($url);
'CURLOPT_HEADER' => 0,
'CURLOPT_HTTPHEADER' => ['Content-Type: application/json']
])->post($body, $url)->submit($url,false,true);
}
/**
......@@ -83,9 +84,12 @@ abstract class WNFBaseStrategy implements BaseStrategy
$this->reqData->setSign();
$body = $this->reqData->getData();
debug([
'title'=>'请求参数',
'body' => $body
]);
$ret = $this->sendReq($body);
return $this->retData($ret);
}
......@@ -107,7 +111,7 @@ abstract class WNFBaseStrategy implements BaseStrategy
*/
protected function retData(array $ret)
{
return $ret;
return $ret['body'];
}
}
\ No newline at end of file
......@@ -17,6 +17,7 @@ class Curl
private $default;
private $download;
private $isJsonStr=false;
private $isWnfJson=false;
private static $instance;
public function __construct()
......@@ -122,7 +123,7 @@ class Curl
* @param string $url
* @return array
*/
public function submit($url,$isJsonStr= false)
public function submit($url,$isJsonStr= false, $isWnfJson = false)
{
if (! $this->post) {
return array(
......@@ -131,6 +132,7 @@ class Curl
);
}
$this->isJsonStr = $isJsonStr;
$this->isWnfJson = $isWnfJson;
return $this->set('CURLOPT_URL', $url)->exec();
}
......@@ -222,6 +224,8 @@ class Curl
curl_setopt($ch, CURLOPT_POST, true);
if($this->isJsonStr){
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{
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postFieldsBuild($this->post));
}
......@@ -233,6 +237,13 @@ class Curl
// 检查错误
$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) {
$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!