Merge pull request 'feature/1211' (#1) from feature/1211 into master
Reviewed-on: http://8.136.139.249:3000/wmtx/sdk/pulls/1master
commit
87b07823f2
@ -0,0 +1,84 @@
|
||||
<?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']);//商户订单号
|
||||
$result = $orderQuery->getResult();
|
||||
Log::write("wechatQUERYFAIL->".serialize($result), Log::DEBUG);
|
||||
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;
|
||||
}*/
|
||||
Log::write("yeeQUERYFAIL->".serialize($ret), Log::DEBUG);
|
||||
if ($ret['result'] && $ret['result']['code'] == "OPR00000" && $ret['result']['status'] == "SUCCESS") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue