支付宝实名认证

This commit is contained in:
wyongk
2020-12-18 21:04:48 +08:00
parent 9bd9d96cb1
commit 648d0c0283
2 changed files with 65 additions and 70 deletions

View File

@@ -6,6 +6,7 @@ require_once APP_PATH . 'alipay/aop/AopCertClient.php';
require_once APP_PATH . 'alipay/aop/AopCertification.php';
require_once APP_PATH . 'alipay/aop/request/AlipayUserCertifyOpenInitializeRequest.php';
require_once APP_PATH . 'alipay/aop/request/AlipayUserCertifyOpenCertifyRequest.php';
require_once APP_PATH . 'alipay/aop/request/AlipayUserCertifyOpenQueryRequest.php';
/**
* 证书类型AopClient功能方法使用测试
@@ -17,10 +18,13 @@ require_once APP_PATH . 'alipay/aop/request/AlipayUserCertifyOpenCertifyRequest.
class Aliverify
{
public static function initVerify()
public static function initVerify($temp)
{
global $config;
$aop = new \AopCertClient();
$res = [];
$res['name'] = $temp['name'];
$res['id_code'] = $temp['id_code'];
$appCertPath = $config['alipay']['app_crt'];
$alipayCertPath = $config['alipay']['public_crt'];
@@ -46,9 +50,9 @@ class Aliverify
$newsigndata['biz_code']="FACE";
$newsigndata['identity_param']['identity_type']="CERT_INFO";
$newsigndata['identity_param']['cert_type']="IDENTITY_CARD";
$newsigndata['identity_param']['cert_name']="万永康";
$newsigndata['identity_param']['cert_no']="410325199810129916";
$newsigndata['merchant_config']['return_url']="http://www.juip.com";
$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";
$newsigndata['face_contrast_picture']="xydasf==";
$tosign=json_encode($newsigndata);
$request->setBizContent($tosign);
@@ -70,63 +74,11 @@ class Aliverify
$res['url'] = $result;
return $res;
} else {
echo "失败";
return false;
}
}
/**
*
* web 付款
* $param = [
* 'body' => '123',
* 'subject' => 'test',
* 'total_amount' => '0.01',
* 'out_trade_no' => '1231313123123',
* 'product_code' => "FAST_INSTANT_TRADE_PAY",//QUICK_WAP_PAY
* 'timeout_express'=>"15m"
*];
*
*
*/
public static function pay($param)
{
global $config;
$aop = new \AopClient();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = $config['alipay']['app_id'];
$aop->rsaPrivateKey = $config['alipay']['private_key'];
$aop->alipayrsaPublicKey = $config['alipay']['public_key'];
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset = 'utf-8';
$aop->format = 'json';
$request = new \AlipayTradePagePayRequest();
$param = json_encode($param);
$request->setBizContent($param);
$result = $aop->pageExecute($request);
echo $result;
}
/**
* @description: 转帐到支付宝账户
* @param {type}$param
* [
* 'out_biz_no'=>'201806300001',
* 'trans_amount' => '0.01',
* 'product_code' => 'TRANS_ACCOUNT_NO_PWD',
* 'payee_info' => [
* 'identity' => '208812*****41234',
* 'identity_type' => 'ALIPAY_LOGON_ID',
* 'name' => 'peter'
* ],
* 'remark' => '提现-单笔转帐'
* ]
* @return {type}
*/
public static function transfer($param)
public function getResult($certify_id)
{
global $config;
$aop = new \AopCertClient();
@@ -147,19 +99,19 @@ class Aliverify
$aop->appCertSN = $aop->getCertSN($appCertPath);//调用getCertSN获取证书序列号
$aop->alipayRootCertSN = $aop->getRootCertSN($rootCertPath);//调用getRootCertSN获取支付宝根证书序列号
$request = new \AlipayFundTransUniTransferRequest();
$param = json_encode($param);
$request->setBizContent($param);
$result = $aop->execute($request);
$request = new AlipayUserCertifyOpenQueryRequest ();
$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->code;
if (!empty($resultCode) && $resultCode == 10000) {
return $result;
if(!empty($resultCode)&&$resultCode == 10000){
return true;
} else {
return false;
}
}
}

View File

@@ -11,10 +11,53 @@ class Test
public function aliverify()
{
$data = Aliverify::initVerify();
$data = $data;
$temp = json_decode(file_get_contents("php://input"),true);
$info = Aliverify::initVerify($temp);
$user = new User;
$data = [];
$user_one_info = $user->getOne(['Id'=>7875]);
if ($user_one_info['is_verify'] == 1){
$data = [
'Code'=>10000
];
echo json_encode($data);
die;
}
if($info){
$update_one['certify_id'] = $info['certifyId'];
$update_one['Name'] = $temp['Name'];
$update_one['id_code'] = $temp['id_code'];
$data['certify_id'] = $info['certifyId'];
$data['url'] = $info['url'];
if($user->updateOne(['Id'=>7875],$update_one)){
$data['Code'] = 10000;
} else {
$data = [
'Code'=>-10000
];
}
} else {
$data = [
'Code'=>-10000
];
}
echo json_encode($data);
}
public function getResult()
{
$user = new User;
$user_one_info = $user->getOne(['Id'=>7875]);
$info = Aliverify::getResult($user_one_info['certify_id']);
if($info){
$data['Code'] = 10000;
} else {
$data = [
'Code'=>-10000
];
}
echo json_encode($data);
die;
}
}