支付宝刷脸认证

Posted qgzr

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了支付宝刷脸认证相关的知识,希望对你有一定的参考价值。

去支付宝下载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了

 

  

  

 

以上是关于支付宝刷脸认证的主要内容,如果未能解决你的问题,请参考以下文章

支付宝刷脸——我们进入了一个怎样的刷脸时代

支付宝刷脸——我们进入了一个怎样的刷脸时代

iOS开发(OC)——支付宝支付

刷脸认证怎么操作?

thinkphp有没有集成支付宝双功能付款的详细教程呢,在网上找了好多,出现好多问题,求大神指点。

面部识别科普(刷脸支付)