微淘
This commit is contained in:
@@ -24,54 +24,6 @@ class UnionPayController extends Controller
|
||||
|
||||
}
|
||||
|
||||
//签名
|
||||
public function toSign($sign_data)
|
||||
{
|
||||
//签名字段
|
||||
// $sign_data['msg_type'] = $array['msg_type'];
|
||||
// $sign_data['msg_txn_code'] = $array['msg_txn_code'];
|
||||
// $sign_data['msg_crrltn_id'] = $array['msg_crrltn_id'];
|
||||
// $sign_data['msg_flg'] = $array['msg_flg'];
|
||||
// $sign_data['msg_sender'] = $array['msg_sender'];
|
||||
// $sign_data['msg_time'] = $array['msg_time'];
|
||||
// $sign_data['msg_sys_sn'] = $array['msg_sys_sn'];
|
||||
// $sign_data['msg_ver'] = $array['msg_ver'];
|
||||
|
||||
// if (isset($array['msg_rsp_code'])) {
|
||||
// $sign_data['msg_rsp_code'] = $array['msg_rsp_code'];
|
||||
// }
|
||||
|
||||
// if (isset($array['msg_rsp_desc'])) {
|
||||
// $sign_data['msg_rsp_desc'] = $array['msg_rsp_desc'];
|
||||
// }
|
||||
|
||||
//将字段名按字母表顺序排序
|
||||
ksort($sign_data);
|
||||
|
||||
//将post的数据utf-8编码
|
||||
$str_data = utf8_encode(http_build_query($sign_data));
|
||||
//获取私钥资源ID
|
||||
$private = config('unionpay.check.self.private');
|
||||
|
||||
if (!file_exists($private)) {
|
||||
throw new \Exception('缺少私钥文件');
|
||||
}
|
||||
|
||||
$private_key = file_get_contents($private);
|
||||
$pkeyid = openssl_get_privatekey($private_key);
|
||||
|
||||
//签名赋值sign
|
||||
if (openssl_sign($str_data, $sign, $pkeyid)) {
|
||||
$sign_data = bin2hex($sign);
|
||||
} else {
|
||||
$sign_data = '';
|
||||
}
|
||||
//释放ssl资源
|
||||
openssl_free_key($pkeyid);
|
||||
|
||||
return $sign_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 银联接口
|
||||
* @Author: 玄尘
|
||||
@@ -86,10 +38,10 @@ class UnionPayController extends Controller
|
||||
unset($inputs['sign']);
|
||||
$action = new UnionPay($inputs, $sign);
|
||||
|
||||
// $action->addLog();
|
||||
$action->addLog();
|
||||
$action->start();
|
||||
|
||||
// $action->updateLog();
|
||||
$action->updateLog();
|
||||
|
||||
return $action->respond();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user