码迷,mamicode.com
首页 > 其他好文 > 详细

支付宝刷脸认证

时间:2019-08-19 19:21:00      阅读:530      评论:0      收藏:0      [点我收藏+]

标签:sap   date   key   aop   data   eth   return   public   nap   

去支付宝下载sdk  这里引用我就不多说了

 

Loader::import(‘ali.wappay.service.AlipayTradeService‘,EXTEND_PATH,‘.php‘);
Loader::import(‘ali.wappay.buildermodel.AlipayTradeWapPayContentBuilder‘,EXTEND_PATH,‘.php‘);

//扫脸身份验证
public function idyanz(){
$idnumber =input(‘idnumber‘);//身份证号
$name = input(‘name‘);//姓名
Loader::import(‘ali.aop.request.AlipayTradeAppPayRequest‘,EXTEND_PATH,‘.php‘);
Loader::import(‘ali.aop.AopClient‘,EXTEND_PATH,‘.php‘);
Loader::import(‘ali.aop.request.AlipayUserCertifyOpenInitializeRequest ‘,EXTEND_PATH,‘.php‘);
Loader::import(‘ali.aop.request.AlipayUserCertifyOpenCertifyRequest ‘,EXTEND_PATH,‘.php‘);
$aop = new \AopClient ();
$aop->gatewayUrl = ‘https://openapi.alipay.com/gateway.do‘;
$aop->appId = ‘appid‘;
$aop->rsaPrivateKey = ‘公钥‘;
$aop->alipayrsaPublicKey=‘私钥‘;
$aop->apiVersion = ‘1.0‘;
$aop->signType = ‘RSA2‘;
$aop->postCharset=‘utf-8‘;
$aop->format=‘json‘;
$request = new \AlipayUserCertifyOpenInitializeRequest ();
$str = date(‘Ymd‘) . str_pad(mt_rand(1, 99999), 5, ‘0‘, STR_PAD_LEFT);
$data = array(
‘outer_order_no‘=>$str,
‘biz_code‘=>‘FACE‘,
‘identity_param‘=>array(
‘identity_type‘=>‘CERT_INFO‘,
‘cert_type‘=>‘IDENTITY_CARD‘,
‘cert_name‘=>$name,
‘cert_no‘=>$idnumber,
),
‘merchant_config‘=>array(
‘return_url‘=>‘http://www.yuming.cn/index?id=‘.$id[‘id‘],
),
);
$request->setBizContent(json_encode($data));
$result = $aop->execute ($request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
if(!empty($resultCode)&&$resultCode == 10000){
$certify_id = $result->$responseNode->certify_id;
$requests = new \AlipayUserCertifyOpenCertifyRequest();
$datas =array(
‘certify_id‘=>$certify_id,
);
$requests->setBizContent(json_encode($datas));
$results = $aop->pageExecute ( $requests);
return $results;
}
}

 


//查询扫脸是否验证
public function shualia($id){
Loader::import(‘ali.aop.request.AlipayTradeAppPayRequest‘,EXTEND_PATH,‘.php‘);
Loader::import(‘ali.aop.AopClient‘,EXTEND_PATH,‘.php‘);
Loader::import(‘ali.aop.request.AlipayUserCertifyOpenInitializeRequest ‘,EXTEND_PATH,‘.php‘);
Loader::import(‘ali.aop.request.AlipayUserCertifyOpenQueryRequest ‘,EXTEND_PATH,‘.php‘);
$aop = new \AopClient ();
$certify_id=DB::table(‘certifyid‘)->where(array(‘uid‘=>$id))->order(‘id desc‘)->find();

$aop->gatewayUrl = ‘https://openapi.alipay.com/gateway.do‘;
$aop->appId = ‘4444‘;
$aop->rsaPrivateKey = ‘公钥‘;
$aop->alipayrsaPublicKey=‘私钥‘;
$aop->apiVersion = ‘1.0‘;
$aop->signType = ‘RSA2‘;
$aop->postCharset=‘utf-8‘;
$aop->format=‘json‘;
$request = new \AlipayUserCertifyOpenQueryRequest ();
$datas =array(
‘certify_id‘=>$certify_id[‘certifyid‘],
);
$request->setBizContent(json_encode($datas));
$result = $aop->execute ( $request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;

if(!empty($resultCode)&&$resultCode == 10000){
$resultpassed = $result->$responseNode->passed;

if($resultpassed == ‘T‘){
//认证成功业务逻辑
}
}
}

 基本上改一改就能用支付宝扫脸认证了 里边引用的就都是支付宝扫码的sdk了

 

  

  

 

支付宝刷脸认证

标签:sap   date   key   aop   data   eth   return   public   nap   

原文地址:https://www.cnblogs.com/qgzr/p/11378734.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!