实名认证

This commit is contained in:
“wanyongkang”
2022-09-28 18:27:13 +08:00
parent 482d71699a
commit e993b0ea00
5 changed files with 185 additions and 7 deletions

View File

@@ -8,6 +8,10 @@ require_once APP_PATH . 'alipay/aop/request/AlipayUserCertifyOpenInitializeReque
require_once APP_PATH . 'alipay/aop/request/AlipayUserCertifyOpenCertifyRequest.php';
require_once APP_PATH . 'alipay/aop/request/AlipayUserCertifyOpenQueryRequest.php';
require_once APP_PATH . 'alipay/aop/AopClient.php';
require_once APP_PATH . 'alipay/aop/request/AlipayOpenPublicTemplateMessageIndustryModifyRequest.php';
/**
* 证书类型AopClient功能方法使用测试
* 1、execute 调用示例
@@ -77,6 +81,7 @@ class Aliverify
}
}
public static function getResult($certify_id)
{
global $config;
@@ -113,5 +118,86 @@ class Aliverify
}
public static function initVerify2($temp)
{
global $config;
$res = [];
$res['name'] = $temp['name'];
$res['id_code'] = $temp['id_code'];
$c = new \AopClient;
$c->gatewayUrl = "https://openapi.alipay.com/gateway.do";
$c->appId = $config['alipay2']['app_id'];
$c->rsaPrivateKey = $config['alipay2']['private_key'] ;
$c->format = "json";
$c->charset= "utf-8";
$c->signType= "RSA2";
$c->alipayrsaPublicKey = $config['alipay2']['public_key'];
//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称alipay.open.public.template.message.industry.modify
$request = new \AlipayOpenPublicTemplateMessageIndustryModifyRequest();
//SDK已经封装掉了公共参数这里只需要传入业务参数
//此次只是参数展示,未进行字符串转义,实际情况下请转义
$newsigndata=array();
$newsigndata['outer_order_no']=md5(time());
$newsigndata['biz_code']="FACE";
$newsigndata['identity_param']['identity_type']="CERT_INFO";
$newsigndata['identity_param']['cert_type']="IDENTITY_CARD";
$newsigndata['identity_param']['cert_name']=$res['name'];
$newsigndata['identity_param']['cert_no']= $res['id_code'];
$newsigndata['merchant_config']['return_url']="http://www.juip.com/User/Index?realname=true";
$newsigndata['face_contrast_picture']="xydasf==";
$tosign=json_encode($newsigndata);
$request->setBizContent($tosign);
$result= $c->execute($request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
$certify_id = $result->$responseNode->certify_id;
if(!empty($resultCode)&&$resultCode == 10000){
$request = new \AlipayUserCertifyOpenCertifyRequest ();
$data['certify_id'] = $certify_id;
$tosign=json_encode($data);
$request->setBizContent($tosign);
$result = $c->pageExecute($request,"GET");
$res['certifyId'] = $certify_id;
$res['url'] = $result;
return $res;
} else {
return false;
}
}
public static function getResult2($certify_id)
{
//--------------------------------
global $config;
$aop = new \AopClient ();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = $config['alipay2']['app_id'];;
$aop->rsaPrivateKey = $config['alipay2']['private_key'] ;
$aop->format = "json";
$aop->charset= "utf-8";
$aop->signType= "RSA2";
$aop->alipayrsaPublicKey = $config['alipay2']['public_key'];
$aop->format='json';
$request = new \AlipayUserCertifyOpenCertifyRequest ();
$data['certify_id'] = $certify_id;
$tosign=json_encode($data);
$request->setBizContent($tosign);
$result = $aop->execute ( $request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->passed;
if($resultCode == 'T'){
return true;
} else {
return false;
}
}
}

View File

@@ -8,6 +8,10 @@ require_once APP_PATH . 'alipay/aop/request/AlipayUserCertifyOpenInitializeReque
require_once APP_PATH . 'alipay/aop/request/AlipayUserCertifyOpenCertifyRequest.php';
require_once APP_PATH . 'alipay/aop/request/AlipayUserCertifyOpenQueryRequest.php';
require_once APP_PATH . 'alipay/aop/AopClient.php';
require_once APP_PATH . 'alipay/aop/request/AlipayOpenPublicTemplateMessageIndustryModifyRequest.php';
/**
* 证书类型AopClient功能方法使用测试
* 1、execute 调用示例
@@ -77,6 +81,7 @@ class AliverifyPublic
}
}
public static function getResult($certify_id)
{
global $config;
@@ -113,5 +118,86 @@ class AliverifyPublic
}
public static function initVerify2($temp)
{
global $config;
$res = [];
$res['name'] = $temp['name'];
$res['id_code'] = $temp['id_code'];
$c = new \AopClient;
$c->gatewayUrl = "https://openapi.alipay.com/gateway.do";
$c->appId = $config['alipay2']['app_id'];
$c->rsaPrivateKey = $config['alipay2']['private_key'] ;
$c->format = "json";
$c->charset= "utf-8";
$c->signType= "RSA2";
$c->alipayrsaPublicKey = $config['alipay2']['public_key'];
//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称alipay.open.public.template.message.industry.modify
$request = new \AlipayOpenPublicTemplateMessageIndustryModifyRequest();
//SDK已经封装掉了公共参数这里只需要传入业务参数
//此次只是参数展示,未进行字符串转义,实际情况下请转义
$newsigndata=array();
$newsigndata['outer_order_no']=md5(time());
$newsigndata['biz_code']="FACE";
$newsigndata['identity_param']['identity_type']="CERT_INFO";
$newsigndata['identity_param']['cert_type']="IDENTITY_CARD";
$newsigndata['identity_param']['cert_name']=$res['name'];
$newsigndata['identity_param']['cert_no']= $res['id_code'];
$newsigndata['merchant_config']['return_url']="http://www.juip.com/User/Index?realname=true";
$newsigndata['face_contrast_picture']="xydasf==";
$tosign=json_encode($newsigndata);
$request->setBizContent($tosign);
$result= $c->execute($request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
$certify_id = $result->$responseNode->certify_id;
if(!empty($resultCode)&&$resultCode == 10000){
$request = new \AlipayUserCertifyOpenCertifyRequest ();
$data['certify_id'] = $certify_id;
$tosign=json_encode($data);
$request->setBizContent($tosign);
$result = $c->pageExecute($request,"GET");
$res['certifyId'] = $certify_id;
$res['url'] = $result;
return $res;
} else {
return false;
}
}
public static function getResult2($certify_id)
{
//--------------------------------
global $config;
$aop = new \AopClient ();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = $config['alipay2']['app_id'];;
$aop->rsaPrivateKey = $config['alipay2']['private_key'] ;
$aop->format = "json";
$aop->charset= "utf-8";
$aop->signType= "RSA2";
$aop->alipayrsaPublicKey = $config['alipay2']['public_key'];
$aop->format='json';
$request = new \AlipayUserCertifyOpenCertifyRequest ();
$data['certify_id'] = $certify_id;
$tosign=json_encode($data);
$request->setBizContent($tosign);
$result = $aop->execute ( $request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->passed;
if($resultCode == 'T'){
return true;
} else {
return false;
}
}
}

View File

@@ -179,7 +179,7 @@ class Index
public function aliverify($temp)
{
$info = Aliverify::initVerify($temp);
$info = Aliverify::initVerify2($temp);
$user = new UserModel;
$data = [];
if($info){
@@ -211,7 +211,7 @@ class Index
$user_phone = $_GET['user'];
$user = new UserModel;
$user_one_info = $user->getOne(['LoginCode'=>$user_phone]);
$info = Aliverify::getResult($user_one_info['certify_id']);
$info = Aliverify::getResult2($user_one_info['certify_id']);
$data = [];
if($info){
$user_data['is_verify'] = 1;
@@ -241,7 +241,7 @@ class Index
$user_phone = $_GET['user'];
$user = new UserModel;
$user_one_info = $user->getOne(['LoginCode'=>$user_phone]);
$info = Aliverify::getResult($user_one_info['certify_id']);
$info = Aliverify::getResult2($user_one_info['certify_id']);
dump($info);
$data = [];
if($info){

View File

@@ -12,7 +12,7 @@ class Test extends Controller
public function aliverify()
{
$temp = json_decode(file_get_contents("php://input"),true);
$info = Aliverify::initVerify($temp);
$info = Aliverify::initVerify2($temp);
$user = new User;
$data = [];
$user_one_info = $user->getOne(['Id'=>$this->userinfo['UserId']]);
@@ -67,7 +67,7 @@ class Test extends Controller
{
$user = new User;
$user_one_info = $user->getOne(['Id'=>$this->userinfo['UserId']]);
$info = Aliverify::getResult($user_one_info['certify_id']);
$info = Aliverify::getResult2($user_one_info['certify_id']);
$data = [];
if($info){
$user_data['is_verify'] = 1;

View File

@@ -4,8 +4,8 @@
* @version:
* @Author: kangkang
* @Date: 2020-09-30 17:32:46
* @LastEditors: Please set LastEditors
* @LastEditTime: 2022-03-22 14:41:49
* @LastEditors: “wanyongkang” “937888580@qq.com”
* @LastEditTime: 2022-09-28 17:52:32
*/
return [
@@ -69,4 +69,10 @@ return [
'root_crt' => APP_PATH . 'config/alicrts/alipayRootCert.crt',
'public_crt' => APP_PATH . 'config/alicrts/alipayCertPublicKey_RSA2.crt',
],
//支付宝
'alipay2' => [
'app_id' => '2019022163283262',
'public_key' => 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAksDNAevies+/JyIvTagC6IAHTIDdCd2uNbjDn2ez7TV2A3LAH9DEk53vwDX+mCPE+v5KFkeAXsWJ+Hcvz3cbTbQj2hqStiYKZdu8DjK2YlilPBWm8SoKR64WtMxT91PH0w5gRT7++6HH7H9p+ctlSyV4VKbVfyh0lnv9BsnNAiIoSDSgf4cUXQy5WP8OMecUeF39vYctzd6KOJN/TlD7zeHfECD/+cGO68t2rANiQLewso7O0LwIfGqsAmbzhAn8pQ82JjVIYfVGOVo/dtxlG67G1QzaVgrAEvM8kovflltm+xPElnwjixblsD4v9OHqhPohCfIdSb4yJpxlxnsCOQIDAQAB',
'private_key' => 'MIIEogIBAAKCAQEAjpCuxQ62JjainDiQFIJxYg/ZxseOtrVrLhwN/UT/RY5le17AfewGVs3iJiwD1s2K4oBqQaXDXLiKFACHrhSGMEGAStfjzDgFgYpscKXwbJpmisJuDuxdMHbrXJydFEEzF8L1MM/gvUKE7Ke8TBC1ue0Vc3czEAaQbNwpB/hrm9S+CiLk5jJhQWGJvUKqrSiRvMVPU2Wq0VCRpehgpZJ8EZ/1o/ylkQvRMpw702vyz3C2DEeK/T71LbNJBmLIB+UOZl/12xawJrx0nA874pZz0I+ObOt6TizHYpg3uU4npbrbyeC+KDWYgcZHVM7d9Aw2zPgotmTBs+eD9/GTZOKErQIDAQABAoIBAC0DGWs2XeRq06SnZzZSiSIBBy1vzGt7lD+WtAQHSOHZN8lf/T7EyquVjZWnx/6GHxesm9/mSmx4B4CROkWITWXnCG6ZA19zQKnJ3rsiaWqgxUeCY+VqU3H92gn/mMjQXSVfdLLYr4iR/A4MV7Ncg0QUyvUN6Z1htS/pwzq1AKTOaMKCINbFMr2O2FxrqZ0keN0f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