[更新] 网点增加门店号

This commit is contained in:
2021-02-19 10:51:21 +08:00
parent 2c33d82774
commit 480cd50ac6
3 changed files with 84 additions and 2 deletions

View File

@@ -2,10 +2,12 @@
namespace App\Http\Controllers;
use GuzzleHttp\Client;
use Illuminate\Http\Request;
use League\Flysystem\Sftp\SftpAdapter;
use League\Flysystem\Filesystem;
use XuanChen\UnionPay\Check;
use XuanChen\UnionPay\Models\UnionpayLog;
class SkyxuController extends Controller
{
@@ -70,4 +72,75 @@ class SkyxuController extends Controller
}
}
/**
* Notes: 获取sign
* @Author: 玄尘
* @Date : 2021/2/19 8:17
*/
public function checkUnionLog()
{
$url = 'http://pac.ysd-bs.com/api/V1/unionpay/query';
$info = UnionpayLog::find(177);
$in_source = $info->in_source;
$out_source = $info->out_source;
$res = $this->http($in_source, $url);
dd($res);
dump($info->in_source);
dump($info->out_source);
}
/**
* Notes: 校验签名
* @Author: 玄尘
* @Date : 2021/2/19 9:03
* @param $params
* @throws \Exception
*/
public function checkSign($params)
{
$sign = $params['sign'];
$signStr = $params['str'];
$app = app('xuanchen.unionpay');
$out = false;
if (isset($params['isout'])) {
$out = true;
}
$public_key = $app->getPublic($out);
$pub_key_id = openssl_get_publickey($public_key);
dump('sign: ' . $sign);
dump('signStr: ' . $signStr);
$sign = $app->hexXbin($sign);
if (!$sign) {
throw new \Exception('签名错误');
}
if ($pub_key_id) {
$result = (bool) openssl_verify($signStr, $sign, $pub_key_id);
openssl_free_key($pub_key_id);
} else {
throw new \Exception('私钥格式有误');
}
$res_str = ($result === true) ? '成功' : '失败';
dd('验签结果:' . $res_str);
}
public function http($data, $url)
{
$client = new Client();
$response = $client->request('POST', $url,
[
'form_params' => $data,
'http_errors' => false,
]);
$body = $response->getBody();
$content = $body->getContents();
$result = json_decode($content, true);
return $result;
}
}