elf 2 weeks ago
parent fa4d15eca9
commit c6284089a3

@ -11,6 +11,7 @@ use Sdk\Controller\Ipa365Controller;
use Base\Tool\Redis; use Base\Tool\Redis;
use Org\Kudian\Response as KDResponse; use Org\Kudian\Response as KDResponse;
use Org\Kudian\Log as KDLog; use Org\Kudian\Log as KDLog;
use Org\Outer\OuterApi;
/** /**
* 支付回调控制器 * 支付回调控制器
@ -968,4 +969,38 @@ class NotifyController extends BaseController
} }
echo 'SUCCESS'; echo 'SUCCESS';
} }
public function outer_callback() {
$params = file_get_contents('php://input');
OuterApi::log('NOTIFY_INPUT:' . $params);
$data = json_decode($params, true);
if ($data['trade_status'] != 'SUCCESS') {
return;
}
$orderInfo['trade_no'] = $data['trade_no'];
$orderInfo['out_trade_no'] = $data['out_trade_no'];
$orderInfo['money'] = round($data['total_amount'] / 100, 2);
$payWhere = substr($orderInfo['out_trade_no'], 0, 2);
switch ($payWhere) {
case 'SP':
$result = $this->set_spend($orderInfo);
break;
case 'PF':
$result = $this->set_deposit($orderInfo);
break;
case 'AG':
$result = $this->set_agent($orderInfo);
break;
default:
exit('accident order data');
break;
}
echo 'success';
}
} }

@ -15,6 +15,7 @@ use Sdk\Model\PayLimitConfModel;
use Sdk\Model\PayChannelInterntionModel; use Sdk\Model\PayChannelInterntionModel;
use Sdk\Model\PayChannelIntentionModel; use Sdk\Model\PayChannelIntentionModel;
use Org\Kudian\Api as KDApi; use Org\Kudian\Api as KDApi;
use Org\Outer\OuterApi;
class PayH5Controller extends BaseController{ class PayH5Controller extends BaseController{
const ALI_PAY = 1; const ALI_PAY = 1;
@ -1609,6 +1610,43 @@ class PayH5Controller extends BaseController{
//0 官方 1威富通 2俊付通 //0 官方 1威富通 2俊付通
// if (get_wx_pay_type() == 0) { // if (get_wx_pay_type() == 0) {
if ($pay_info['channel'] == 2) { if ($pay_info['channel'] == 2) {
if ($pay_conf['partner'] == '1699330320') {
$params = [
'order_no' => $request['pay_order_number'],
'user_id' => $request['user_id'],
'user_account' => $request['user_account'],
'game_id' => $request['game_id'],
'game_name' => $request['game_name'],
'server_id' => $request['server_id'],
'server_name' => $request['server_name'],
'subject' => $request['title'] ? $request['title']: '充值',
'role_id' => $request['game_player_id'],
'role_name' => $request['game_player_name'],
'pay_amount' => (int)($pay_amount*100),
'notify_url' => "http://" . $_SERVER['HTTP_HOST'] . "/callback.php/Notify/outer_callback",
'return_url' => urlencode(C('PAY_DOMAIN')."sdk.php/Spend/paycallback/orderno/{$request['pay_order_number']}/game_id/{$request['game_id']}/paytype/weixinpay"),
'promote_id' => $request['promote_id'],
'promote_account' => $request['promote_account'],
'client_ip' => $request['spend_ip'],
'pay_type' => 'wxpay-h5'
];
$result = OuterApi::request($params);
if ($result['code'] == '0000') {
$request['pay_url'] = $result['data']['pay_url'] . "&tx_client=hideopen";
$request['merchant_id'] = $pay_info['id'];
$request['merchant_way'] = self::WX_PAY;
$request['main_id'] = $main_id;
if (C('SHARE_ID.'.$pay_conf['partner']) == 'y') {
$request['share_status'] = 1;
}
$this->add_spend($request,1);
} else {
echo json_encode(['code'=>0,'msg'=> '支付失败']);
Log::write("weixin_pay支付失败".serialize($is_pay));
exit;
}
}
$weixn = new Weixin(); $weixn = new Weixin();
$is_pay = json_decode($weixn->weixin_pay(!empty($request['title']) ? $request['title']: "充值", $request['pay_order_number'], $pay_amount, 'MWEB', 1, $pay_conf), true); $is_pay = json_decode($weixn->weixin_pay(!empty($request['title']) ? $request['title']: "充值", $request['pay_order_number'], $pay_amount, 'MWEB', 1, $pay_conf), true);
@ -1616,9 +1654,6 @@ class PayH5Controller extends BaseController{
if($request['code']==1){ if($request['code']==1){
$redirectBaseUri = C('PAY_DOMAIN'); $redirectBaseUri = C('PAY_DOMAIN');
if ($pay_conf['partner'] == '1699330320') {
$redirectBaseUri = 'https://wap.hexidongkeji.top/';
}
$json_data['url'] = $is_pay['mweb_url'].'&redirect_url='.urlencode($redirectBaseUri."sdk.php/Spend/paycallback/orderno/{$request['pay_order_number']}/game_id/{$request['game_id']}/paytype/weixinpay"); $json_data['url'] = $is_pay['mweb_url'].'&redirect_url='.urlencode($redirectBaseUri."sdk.php/Spend/paycallback/orderno/{$request['pay_order_number']}/game_id/{$request['game_id']}/paytype/weixinpay");
$request['pay_url'] = $json_data['url'] . "&tx_client=hideopen"; $request['pay_url'] = $json_data['url'] . "&tx_client=hideopen";
$request['merchant_id'] = $pay_info['id']; $request['merchant_id'] = $pay_info['id'];

@ -0,0 +1,49 @@
<?php
namespace Org\Outer;
use Base\Tool\Log;
use Exception;
use Think\Log as ThinkLog;
class OuterApi
{
public static function request($params)
{
try {
$response = self::post('http://wap.hexidongkeji.top/pay', $params);
self::log('REQUEST_RESPONSE: ' . $response);
return json_decode($response, true);
} catch (Exception $e) {
self::log('REQUEST_ERROR: ' . $e->getMessage());
return [
'code' => -999,
'message' => '网络错误',
'data' => null,
];
}
}
public static function post($url, $params)
{
self::log('REQUEST_URL: ' . $url);
self::log('REQUEST_DATA: ' . json_encode($params));
$curl = curl_init();
if (stripos($url, 'https://') !== false){
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, true);
$headers = ['Content-type: application/json'];
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params));
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
public static function log($content, $level = ThinkLog::INFO) {
Log::write($content, $level, 'outer_pay');
}
}
Loading…
Cancel
Save