实名认证

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;
}
}
}