From e700c252e5d8dbb752161db04536c1dd30b9673e Mon Sep 17 00:00:00 2001 From: wyongk <937888580@qq.com> Date: Fri, 18 Dec 2020 14:02:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D=E5=AE=9E=E5=90=8D?= =?UTF-8?q?=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alipay/Aliverify.php | 147 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 alipay/Aliverify.php diff --git a/alipay/Aliverify.php b/alipay/Aliverify.php new file mode 100644 index 0000000..6fb42fa --- /dev/null +++ b/alipay/Aliverify.php @@ -0,0 +1,147 @@ +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 \AlipayUserCertifyOpenInitializeRequest(); + //$request = new AlipayUserCertifyOpenInitializeRequest (); //TODO 官方这个地方写错了,应该用下面的代码才能实现 + + $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']="万永康"; + $newsigndata['identity_param']['cert_no']="410325199810129916"; + $newsigndata['merchant_config']['return_url']="http://www.juip.com"; + $newsigndata['face_contrast_picture']="xydasf=="; + $tosign=json_encode($newsigndata); + $request->setBizContent($tosign); + + $result = $aop->execute ( $request); + + $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response"; + $resultCode = $result->$responseNode->code; + var_dump($result->$responseNode); + if(!empty($resultCode)&&$resultCode == 10000){ + echo "成功"; + } else { + echo "失败"; + } + } + + /** + * + * 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) + { + global $config; + $aop = new \AopCertClient(); + + $appCertPath = $config['alipay']['app_crt']; + $alipayCertPath = $config['alipay']['public_crt']; + $rootCertPath = $config['alipay']['root_crt']; + + $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do'; + $aop->appId = $config['alipay']['app_id']; + $aop->rsaPrivateKey = $config['alipay']['private_key']; + $aop->alipayrsaPublicKey = $aop->getPublicKey($alipayCertPath);//调用getPublicKey从支付宝公钥证书中提取公钥 + $aop->apiVersion = '1.0'; + $aop->signType = 'RSA2'; + $aop->postCharset='utf-8'; + $aop->format='json'; + $aop->isCheckAlipayPublicCert = true;//是否校验自动下载的支付宝公钥证书,如果开启校验要保证支付宝根证书在有效期内 + $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); + + $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response"; + $resultCode = $result->$responseNode->code; + if (!empty($resultCode) && $resultCode == 10000) { + return $result; + } else { + return false; + } + } +}