支付通知二次验证 配置实名配置

master
tping 4 years ago
parent f771f0be84
commit 85cf7d8e46

@ -0,0 +1,81 @@
<?php
namespace Base\Service;
use Org\YeepaySDK\Yeepay;
class PayService {
public function __construct()
{
}
// 支付宝查询订单号
public function alipayTradeQuery($payConf, $orderInfo) {
Vendor('Alipay.AopSdk');
$aop = new \AopClient ();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = $payConf['app_id'];
$aop->rsaPrivateKey = $payConf['private_key'];
$aop->alipayrsaPublicKey= $payConf['public_key'];
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='UTF-8';
$aop->format='json';
$request = new \AlipayTradeQueryRequest();
$request->setBizContent("{" .
"\"out_trade_no\":\"{$orderInfo['out_trade_no']}\"," .
"\"trade_no\":\"{$orderInfo['trade_no']}\"," .
// "\"org_pid\":\"2088101117952222\"," .
" \"query_options\":[" .
" \"trade_settle_info\"" .
" ]" .
" }");
$result = $aop->execute($request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
if(!empty($resultCode)&&$resultCode == 10000){
return true;
} else {
return false;
}
return false;
}
// 微信查询订单号
public function wechatTradeQuery($payConf, $orderInfo) {
header("Content-type:text/html;charset=utf-8");
Vendor("WxPayPubHelper.WxPayPubHelper");
$orderQuery = new \OrderQuery_pub($payConf['appid'], $payConf['partner'], $payConf['key']);
$orderQuery->setParameter('out_trade_no', $orderInfo['out_trade_no']);//商户订单号
$result = $orderQuery->getResult();
if($result['trade_state']=='SUCCESS') {
return true;
}
return false;
}
// 易宝查询订单号
public function yeeTradeQuery($payConf, $orderInfo) {
$yeepay = new Yeepay();
$data['appKey'] = $payConf['key'];
$data['privateKey'] = $payConf['private_key'];
$data['parentMerchantNo'] = $payConf['parent_merchant'];
$data['merchantNo'] = $payConf['partner'];
$data['orderId'] = $orderInfo['out_trade_no'];
$ret = $yeepay->orderQuery($data);
/* if ($yeeData['data']['result']['code'] != 'OPR00000') {
echo json_encode(['code'=>0, 'msg'=> '支付参数有误,请重试'.$yeeData['data']['result']['code']]);
exit;
}*/
if ($ret['result'] && $ret['result']['code'] == "OPR00000" && $ret['result']['status'] == "SUCCESS") {
return true;
}
return false;
}
}

@ -2,6 +2,7 @@
namespace Callback\Controller;
use Base\Service\PayService;
use Org\UcenterSDK\Ucservice;
use Think\Log;
@ -38,9 +39,7 @@ class Notify2Controller extends BaseController
if ($apitype == "swiftpass") {
$apitype = "weixin";
}
Vendor('Alipay.AopSdk');
$aop = new \AopClient();
Vendor('Alipay.AopSdk');
$aop = new \AopClient();
@ -67,6 +66,15 @@ class Notify2Controller extends BaseController
if (I('get.methodtype') == "notify") {
$order_info = $notify;
if($order_info['trade_status'] == 'TRADE_SUCCESS'){
$payService = new PayService();
if (!$payService->alipayTradeQuery($payConf, $notify)) {
sleep(1); // 延迟1s 在查一次
if (!$payService->alipayTradeQuery($payConf, $notify)) {
Log::write("ALIQUERYFAIL->".serialize($notify), Log::DEBUG);
echo 'fail';
exit();
}
}
$pay_where = substr($order_info['out_trade_no'], 0, 2);
$result = false;
switch ($pay_where) {
@ -160,7 +168,6 @@ class Notify2Controller extends BaseController
return false;
}
/**
* 支付宝退款回调
* @return [type] [description]
@ -198,11 +205,9 @@ class Notify2Controller extends BaseController
}
}
/**
*判断平台币充值是否存在
*/
protected function deposit_is_exist($out_trade_no)
{
@ -226,9 +231,7 @@ class Notify2Controller extends BaseController
}
//判断充值是否存在
public function recharge_is_exist($out_trade_no)
{
@ -252,9 +255,7 @@ class Notify2Controller extends BaseController
}
//判断代充是否存在
public function agent_is_exist($out_trade_no)
{
@ -279,5 +280,4 @@ class Notify2Controller extends BaseController
}
}

@ -2,6 +2,7 @@
namespace Callback\Controller;
use Base\Service\PayService;
use Org\UcenterSDK\Ucservice;
use Org\SwiftpassSDK\Swiftpass;
use Think\Log;
@ -276,7 +277,6 @@ class NotifyController extends BaseController
/**
*微信回调
*/
public function wxpay_callback()
{
Log::write("timeout".time(), Log::DEBUG);
@ -324,6 +324,17 @@ class NotifyController extends BaseController
$pay_where = substr($reqdata['out_trade_no'], 0, 2);
$data['trade_no'] = $reqdata['transaction_id'];
$data['out_trade_no'] = $reqdata['out_trade_no'];
$payService = new PayService();
if (!$payService->wechatTradeQuery($payConf, $data)) {
sleep(1); // 延迟1s 在查一次
if (!$payService->wechatTradeQuery($payConf, $data)) {
Log::write("WECHATQUERYFAIL->".serialize($data), Log::DEBUG);
echo 'fail';
exit();
}
}
switch ($pay_where) {
case 'SP'://充值游戏
if ($this->recharge_is_exist($reqdata['out_trade_no'])) {
@ -747,16 +758,9 @@ class NotifyController extends BaseController
}
/**
*判断平台币充值是否存在
*/
protected function deposit_is_exist($out_trade_no)
{
@ -781,7 +785,6 @@ class NotifyController extends BaseController
}
//判断订单是否存在
public function order_is_exist($out_trade_no)
{
@ -805,9 +808,7 @@ class NotifyController extends BaseController
}
//判断充值是否存在
public function recharge_is_exist($out_trade_no)
{
@ -831,9 +832,7 @@ class NotifyController extends BaseController
}
//判断代充是否存在
public function agent_is_exist($out_trade_no)
{
@ -864,7 +863,6 @@ class NotifyController extends BaseController
return "";
}
//判断余额币是否存在
public function balance_is_exist($out_trade_no){
$balance = M('balance', 'tab_');
@ -922,11 +920,21 @@ class NotifyController extends BaseController
$this->record_logs("sourceData返回数据错误");
exit();
} else {
$pay_where = substr($sourceData['orderId'], 0, 2);
$data['trade_no'] = $sourceData['uniqueOrderNo']; // 易宝流水号
$data['out_trade_no'] = $sourceData['orderId']; // 平台生成的订单号SP
$data['money'] = $sourceData['payAmount'];
$payService = new PayService();
if (!$payService->yeeTradeQuery($payConf, $data)) {
sleep(1); // 延迟1s 在查一次
if (!$payService->yeeTradeQuery($payConf, $data)) {
Log::write("YEEQUERYFAIL->".serialize($data), Log::DEBUG);
echo 'fail';
exit();
}
}
switch ($pay_where) {
case 'SP'://充值游戏
if ($this->recharge_is_exist($sourceData['out_trade_no'])) {

@ -1237,13 +1237,14 @@ function age_verify($cardno, $name, $user_id = '')
}
}
//根据配置向接口发送身份证号和姓名进行验证
//根据配置向接口发送身份证号和姓名进行验证 支付宝配置
function age($cardno, $name, &$info)
{
$host = "https://idcardcert.market.alicloudapi.com";
$path = "/idCardCert";
$method = "GET";
$appcode = "244181f0846541a19e24df409736d3b9";
$appcode = C('tool_age.appcode');
if (!$appcode) $appcode = "244181f0846541a19e24df409736d3b9";
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
@ -1273,7 +1274,7 @@ function age($cardno, $name, &$info)
return -1;//用完
}
$r = json_decode($output, true);
if ($r['status'] == "02") return 0;
if ($r['status'] == "02") return 0; // 实名认证不通过
return $r;
}

@ -69,6 +69,28 @@ class Yeepay
return array('url' => $url, 'data' => $ret);
}
public function orderQuery($data) {
include 'conf.php';
$appKey = $data['appKey'];
$privateKey = $data['privateKey'];
$parentMerchantNo = $data['parentMerchantNo'];
$merchantNo = $data['merchantNo'];
$request = new \YopRequest($appKey, $privateKey);
$request->addParam("parentMerchantNo", $parentMerchantNo);
$request->addParam("merchantNo", $merchantNo);
$request->addParam("orderId", $data['orderId']);
$response = \YopClient3::post("/rest/v1.0/std/trade/orderquery", $request);
if($response->validSign != 1){
return -1; // 签名验证失败
}
//取得返回结果
$ret = $this->object_array($response);
return $ret;
}
private function getString($response){

Loading…
Cancel
Save