You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
3.1 KiB
PHP
88 lines
3.1 KiB
PHP
<?php
|
|
namespace Base\Service;
|
|
|
|
|
|
use Org\YeepaySDK\Yeepay;
|
|
use Think\Log;
|
|
|
|
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);
|
|
Log::write("ALIQUERYFAIL->".serialize($result), Log::DEBUG);
|
|
$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']);//商户订单号
|
|
|
|
if (C('SHARE_ID.'.$payConf['partner']) == 'y' || C('SHARE_ID.'.$payConf['partner']) == 'n') {
|
|
$orderQuery->setParameter("sub_mch_id", C('SHARE_PAIR.'.$payConf['partner']));
|
|
}
|
|
$result = $orderQuery->getResult();
|
|
if($result['trade_state']=='SUCCESS') {
|
|
return true;
|
|
}
|
|
Log::write("wechatQUERYFAIL->".serialize($result), Log::DEBUG);
|
|
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;
|
|
}*/
|
|
Log::write("yeeQUERYFAIL->".serialize($ret), Log::DEBUG);
|
|
if ($ret['result'] && $ret['result']['code'] == "OPR00000" && $ret['result']['status'] == "SUCCESS") {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
} |