) ) : null; $nonce = !empty($_POST[‘nonce’]) ? $_POST[‘nonce’] : null; if ($nonce && !wp_verify_nonce($nonce, ‘caoclick-‘ . $uid)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘非法请求’));exit; } // 验证长度 if ($cdkcode && strlen($cdkcode) != 12) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘卡密错误’));exit; } // 实例化卡密 $CaoCdk = new CaoCdk(); $cdk_money = sprintf(‘%0.2f’, $cdk_money); $cdk_money = $CaoCdk->checkCdk($cdkcode); if (!$cdk_money) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘卡密无效’));exit; } // 卡密有效 进行换算 $CaoUser = new CaoUser($uid); $old_money = $CaoUser->get_balance(); if (!$CaoUser->update_balance($cdk_money)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘兑换失败’));exit; } // 充值余额成功 废弃卡密 updataCdk if (!$CaoCdk->updataCdk($cdkcode)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘卡密异常’));exit; } // 添加纪录 if ($uid) { $Caolog = new Caolog(); $new_money = $old_money + $cdk_money; $note = ‘卡密充值 [‘ . $cdkcode . ‘] +’ . $cdk_money; $Caolog->addlog($uid, $old_money, $cdk_money, $new_money, ‘cdk’, $note); } echo json_encode(array(‘status’ => ‘1’, ‘msg’ => ‘卡密充值成功’)); if (_cao(‘is_mail_nitfy_cdk’)) { _sendMail($current_user->user_email, ‘卡密充值成功’, $note); } exit; } add_action(‘wp_ajax_cdk_pay’, ‘cdk_pay’); add_action(‘wp_ajax_nopriv_cdk_pay’, ‘cdk_pay’); // 提现申请 function add_reflog() { header(‘Content-type:application/json; Charset=utf-8’); if (_cao(‘is_ref_to_rmb’)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘RMB提现功能未开启’));exit; } global $current_user; $uid = $current_user->ID; isLoginCheck(); //检测登录 $money = !empty($_POST[‘money’]) ? (int)$_POST[‘money’] : 0; $nonce = !empty($_POST[‘nonce’]) ? $_POST[‘nonce’] : null; if ($nonce && !wp_verify_nonce($nonce, ‘caoclick-‘ . $uid)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘非法请求’));exit; } $site_min_tixian_num = _cao(‘site_min_tixian_num’); $Reflog = new Reflog($uid); // 验证长度 if ($money [LT] $site_min_tixian_num) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘提现金额最低’.$site_min_tixian_num.’元起’));exit; } if ($money > $Reflog->get_ke_bonus()) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘可提现金额不足’));exit; } $note = ‘用户ID:’.$uid.’ 申请提现’; if ($Reflog->addlog($money,$note)) { echo json_encode(array(‘status’ => ‘1’, ‘msg’ => ‘提现申请成功,将尽快为您转账’));exit; }else{ echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘申请失败,稍后再试’));exit; } } add_action(‘wp_ajax_add_reflog’, ‘add_reflog’); add_action(‘wp_ajax_nopriv_add_reflog’, ‘add_reflog’); // 提现站内余额申请 function add_reflog2() { header(‘Content-type:application/json; Charset=utf-8’); global $current_user; $uid = $current_user->ID; isLoginCheck(); //检测登录 $money = !empty($_POST[‘money’]) ? (int)$_POST[‘money’] : 0; $nonce = !empty($_POST[‘nonce’]) ? $_POST[‘nonce’] : null; if ($nonce && !wp_verify_nonce($nonce, ‘caoclick-‘ . $uid)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘非法请求’));exit; } $site_min_tixian_num = _cao(‘site_min_tixian_num’); $Reflog = new Reflog($uid); // 验证长度 if ($money [LT] $site_min_tixian_num) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘提现金额最低’.$site_min_tixian_num.’元起’));exit; } if ($money > $Reflog->get_ke_bonus()) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘可提现金额不足’));exit; } $note = ‘用户ID:’.$uid.’ 提现到站内余额’; if ($Reflog->addlog($money,$note)) { // $money 兑换 $charge_rate = (int) _cao(‘site_change_rate’); //充值比例 $CaoUser = new CaoUser($uid); $old_money = $CaoUser->get_balance(); $add_money = $money*$charge_rate; if (!$CaoUser->update_balance($add_money)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘佣金兑换失败’));exit; } // 兑换成功 添加纪录 if ($uid) { $Caolog = new Caolog(); $new_money = $old_money + $add_money; $note = ‘佣金提现兑换 [¥’ . $money . ‘] +’ . $add_money; $Caolog->addlog($uid, $old_money, $add_money, $new_money, ‘other’, $note); } echo json_encode(array(‘status’ => ‘1’, ‘msg’ => ‘提现成功,已经自动兑换到您的可用余额’));exit; }else{ echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘申请失败,稍后再试’));exit; } } add_action(‘wp_ajax_add_reflog2’, ‘add_reflog2’); add_action(‘wp_ajax_nopriv_add_reflog2’, ‘add_reflog2’); /** * [charge_pay 在线付款支付] * @Author Dadong2g * @DateTime 2019-06-03T22:28:59+0800 * @return [type] [JOSN] */ function charge_pay() { header(‘Content-type:application/json; Charset=utf-8’); $ip = (isset($_SERVER[‘REMOTE_ADDR’])) ? $_SERVER[‘REMOTE_ADDR’] : ‘127.0.0.1’; //客户端IP global $current_user; $uid = $current_user->ID; isLoginCheck(); //检测登录 $nonce = !empty($_POST[‘nonce’]) ? $_POST[‘nonce’] : null; $charge_num = !empty($_POST[‘charge_num’]) ? (int)$_POST[‘charge_num’] : null; $pay_type = !empty($_POST[‘pay_type’]) ? (int) $_POST[‘pay_type’] : null; //1支付宝;2微信 if ($nonce && !wp_verify_nonce($nonce, ‘caoclick-‘ . $uid)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘非法请求’));exit; } // 基础验证通过 验证前台表单数据 充值数量和支付方式 $min_cahrge_num =_cao(‘min_cahrge_num’,’1′); $max_cahrge_num =_cao(‘max_cahrge_num’,’1000′); if (!$charge_num || $charge_num [LT] 0) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘请输入充值数量’));exit; } if ($charge_num [LT] $min_cahrge_num) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘最低充值数量限额:’.$min_cahrge_num));exit; } if ($charge_num > $max_cahrge_num) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘最高充值数量限额:’.$max_cahrge_num));exit; } if (!isset($pay_type) || $pay_type == 0) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘请选择支付方式’));exit; } // 实例化订单 $ShopOrder = new ShopOrder(); /////////商品属性START/////// $charge_rate = (int) _cao(‘site_change_rate’); //充值比例 $order_price = sprintf(‘%0.2f’, $charge_num / $charge_rate); // 订单价格 换算人民币,保留两位小数点 $order_trade_no = date(“ymdhis”) . mt_rand(100, 999) . mt_rand(100, 999) . mt_rand(100, 999); // 订单号 if (_cao(‘is_ripro_diy_shop_name’)) { $order_name = _cao(‘ripro_diy_shop_name_charge’); //自定义订单名称 }else{ $order_name = get_bloginfo(‘name’) . ‘-余额充值’; //订单名称 } $order_type = ‘charge’; //类型 充值 /////////商品属性END///////// // 判断支付方式 1 支付宝 START if ($pay_type == 1) { // 获取后台支付宝配置 $aliPayConfig = _cao(‘alipay’); // 判断是否开启手机版跳转 if (wp_is_mobile() && $aliPayConfig[‘is_mobile’]) { // 添加订单 ShopOrder if (!$ShopOrder->add($uid, $order_trade_no, $order_type, $order_price, $pay_type)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘订单创建失败’));exit; } // 支付宝公共配置 $params = new YurunPaySDKAlipayParamsPublicParams; $params->appID = $aliPayConfig[‘pid’]; $params->md5Key = $aliPayConfig[‘md5Key’]; // SDK实例化,传入公共配置 $pay = new YurunPaySDKAlipaySDK($params); // 支付接口 $request = new YurunPaySDKAlipayParamsWapPayRequest; $request->notify_url = get_template_directory_uri() . ‘/shop/alipay/notify.php’; $request->return_url = get_template_directory_uri() . ‘/shop/alipay/return.php’; // 支付后跳转返回地址 $request->businessParams->seller_id = $aliPayConfig[‘pid’]; // 卖家支付宝用户号 $request->businessParams->out_trade_no = $order_trade_no; // 商户订单号 $request->businessParams->total_fee = $order_price; // 价格 $request->businessParams->subject = $order_name; // 商品标题 $request->businessParams->show_url = get_permalink($post_id); // 用户付款中途退出返回商户网站的地址。 $payurl = $pay->redirectExecuteUrl($request); $_SESSION[‘ali_session_order_trade_no’] = $order_trade_no; // type 1 = 扫码支付 2 跳转支付 echo json_encode(array(‘status’ => ‘1’, ‘type’ => ‘2’, ‘rurl’ => $payurl, ‘qrcode’ => ”, ‘msg’ => $order_trade_no)); exit; } elseif (!$aliPayConfig[‘is_pcqr’]) { // 支付宝-电脑网站支付 // 添加订单 ShopOrder if (!$ShopOrder->add($uid, $order_trade_no, $order_type, $order_price, $pay_type)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘订单创建失败’));exit; } // 支付宝公共配置 $params = new YurunPaySDKAlipayParamsPublicParams; $params->appID = $aliPayConfig[‘pid’]; $params->md5Key = $aliPayConfig[‘md5Key’]; // SDK实例化,传入公共配置 $pay = new YurunPaySDKAlipaySDK($params); // 支付接口 $request = new YurunPaySDKAlipayParamsPayRequest; $request->notify_url = get_template_directory_uri() . ‘/shop/alipay/notify.php’; $request->return_url = get_template_directory_uri() . ‘/shop/alipay/return.php’; // 支付后跳转返回地址 $request->businessParams->seller_id = $aliPayConfig[‘pid’]; // 卖家支付宝用户号 $request->businessParams->out_trade_no = $order_trade_no; // 商户订单号 $request->businessParams->total_fee = $order_price; // 价格 $request->businessParams->subject = $order_name; // 商品标题 // 跳转到支付宝页面 $payurl = $pay->redirectExecuteUrl($request); // var_dump($payurl); // type 1 = 扫码支付 2 跳转支付 echo json_encode(array(‘status’ => ‘1’, ‘type’ => ‘2’, ‘rurl’ => $payurl, ‘qrcode’ => ”, ‘msg’ => $order_trade_no)); exit; } else { // 应用模式公共配置-当面付 // 添加订单 ShopOrder if (!$ShopOrder->add($uid, $order_trade_no, $order_type, $order_price, $pay_type)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘订单创建失败’));exit; } // 更换公共配置文件 $params = new YurunPaySDKAlipayAppParamsPublicParams; $params->appID = $aliPayConfig[‘appid’]; $params->appPrivateKey = $aliPayConfig[‘privateKey’]; $params->appPublicKey = $aliPayConfig[‘publicKey’]; // SDK实例化,传入公共配置 $pay = new YurunPaySDKAlipayAppSDK($params); // 支付接口 $request = new YurunPaySDKAlipayAppFTFParamsQRRequest; $request->notify_url = get_template_directory_uri() . ‘/shop/alipay/notify2.php’; // 支付后通知地址 $request->businessParams->out_trade_no = $order_trade_no; // 商户订单号 $request->businessParams->total_amount = $order_price; // 价格 $request->businessParams->subject = $order_name; // 商品标题 // 调用接口 try{ $data = $pay->execute($request); } catch(Exception $e){ var_dump($pay->response->body()); } // QR内容 $qrimg = getQrcode($data[‘alipay_trade_precreate_response’][‘qr_code’]); $iconstr = ‘[LT]img src=”‘.get_template_directory_uri()%20.%20’/assets/icons/alipay.png” class=”qr-pay”>’; $html_str = ‘[LT]div class=”qrcon”> [LT]h5> ‘.$iconstr.’ [LT]/h5> [LT]div class=”title”>支付宝扫码支付 ‘.$order_price.’ 元[LT]/div> [LT]div align=”center” class=”qrcode”> [LT]img src=”‘.$qrimg.'”/> [LT]/div> [LT]div class=”bottom alipay”> 请使用支付宝扫一扫支付[LT]br>提示:若扫码支付失败,请重试[LT]br>或添加站长微信:1256069585 办理[LT]/br> [LT]/div> [LT]/div>’; echo json_encode(array(‘status’ => ‘1’, ‘type’ => ‘1’, ‘msg’ => $html_str, ‘img’ => $qrimg, ‘num’ => $order_trade_no)); exit; } } //END ALIPAY // 2 微信 if ($pay_type == 2) { // 获取后台支付配置 $wxPayConfig = _cao(‘weixinpay’); // 公共配置 $params = new YurunPaySDKWeixinParamsPublicParams; $params->appID = $wxPayConfig[‘appid’]; $params->mch_id = $wxPayConfig[‘mch_id’]; $params->key = $wxPayConfig[‘key’]; // SDK实例化,传入公共配置 $pay = new YurunPaySDKWeixinSDK($params); $the_openid = get_user_meta($uid, ‘open_mpweixin_openid’, true); // 判断是否开启手机版跳转 if (wp_is_mobile() && $wxPayConfig[‘is_mobile’] && !is_weixin_view()) { // 添加订单 ShopOrder if (!$ShopOrder->add($uid, $order_trade_no, $order_type, $order_price, $pay_type)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘订单创建失败’));exit; } // 支付接口H5 $request = new YurunPaySDKWeixinH5ParamsPayRequest; $request->body = $order_name; // 商品描述 $request->out_trade_no = $order_trade_no; // 订单号 $request->total_fee = $order_price*100; // 订单总金额,单位为:分 $request->spbill_create_ip = $ip; // 客户端ip,必须传正确的用户ip,否则会报错 $request->notify_url = get_template_directory_uri() . ‘/shop/weixin/notify.php’; // 异步通知地址 $request->scene_info = new YurunPaySDKWeixinH5ParamsSceneInfo; $request->scene_info->type = ‘Wap’; // 可选值:IOS、Android、Wap // 下面参数根据type不同而不同 $request->scene_info->wap_url = get_template_directory_uri() . ‘/shop/weixin/return.php’; $request->scene_info->wap_name = get_bloginfo(‘name’); // 调用接口 $result = $pay->execute($request); if($pay->checkResult()){ $_SESSION[‘wx_session_order_trade_no’] = $order_trade_no; echo json_encode(array(‘status’ => ‘1’, ‘type’ => ‘2’, ‘rurl’ => $result[‘mweb_url’], ‘qrcode’ => ‘h5’, ‘num’ => $order_trade_no)); exit; }else{ $error_msg = $pay->getErrorCode() . ‘:’ . $pay->getError(); echo json_encode(array(‘status’ => ‘0’, ‘msg’ => $error_msg)); exit; } }elseif (_cao(‘is_oauth_mpweixin’) && $wxPayConfig[‘is_jsapi’] && is_weixin_view() && is_user_logged_in() && !empty($the_openid)) { // 添加订单 ShopOrder if (!$ShopOrder->add($uid, $order_trade_no, $order_type, $order_price, $pay_type)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘订单创建失败’));exit; } # JSAPI 模式 $request = new YurunPaySDKWeixinJSAPIParamsPayRequest; $request->body = $order_name; // 商品描述 $request->out_trade_no = $order_trade_no; // 订单号 $request->total_fee = $order_price*100; // 订单总金额,单位为:分 $request->spbill_create_ip = $ip; // 客户端ip $request->notify_url = get_template_directory_uri() . ‘/shop/weixin/notify.php’; // 异步通知地址 $request->openid = $the_openid; // 必须设置openid // 调用接口 $result = $pay->execute($request); if($pay->checkResult()) { $request = new YurunPaySDKWeixinJSAPIParamsJSParamsRequest; $request->prepay_id = $result[‘prepay_id’]; $jsapiParams = $pay->execute($request); // 最后需要将数据传给js,使用WeixinJSBridge进行支付 echo json_encode(array(‘status’ => ‘1’, ‘type’ => ‘3’, ‘msg’ => $jsapiParams, ‘img’ => ”, ‘num’ => $order_trade_no));exit; }else{ echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘未绑定公众号登录或网络错误’));exit; } } else { // PC使用当面付返回二维码 // 添加订单 ShopOrder if (!$ShopOrder->add($uid, $order_trade_no, $order_type, $order_price, $pay_type)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘订单创建失败’));exit; } // 支付接口 PC扫码 $request = new YurunPaySDKWeixinNativeParamsPayRequest; $request->body = $order_name; // 商品描述 $request->out_trade_no = $order_trade_no; // 订单号 $request->total_fee = $order_price*100; // 订单总金额,单位为:分 $request->spbill_create_ip = $ip; // 客户端ip $request->notify_url = get_template_directory_uri() . ‘/shop/weixin/notify.php’; // 异步通知地址 // 调用接口 $result = $pay->execute($request); $shortUrl = $result[‘code_url’]; if (is_array($result) && $shortUrl) { // 获取成功 返回QR内容 $qrimg = getQrcode($shortUrl); $iconstr = ‘[LT]img src=”‘.get_template_directory_uri()%20.%20’/assets/icons/weixin.png” class=”qr-pay”>’; $html_str = ‘[LT]div class=”qrcon”> [LT]h5> ‘.$iconstr.’ [LT]/h5> [LT]div class=”title”>微信扫码支付 ‘.$order_price.’ 元[LT]/div> [LT]div align=”center” class=”qrcode”> [LT]img src=”‘.$qrimg.'”/> [LT]/div> [LT]div class=”bottom weixinpay”> 请使用微信扫一扫支付[LT]br>提示:若扫码支付失败,请重试[LT]br>或添加站长微信:1256069585 办理[LT]/br> [LT]/div> [LT]/div>’; echo json_encode(array(‘status’ => ‘1’, ‘type’ => ‘1’, ‘msg’ => $html_str, ‘img’ => $qrimg, ‘num’ => $order_trade_no)); exit; }else{ echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘接口网络异常’));exit; } } } //PAYJS if ($pay_type == 4) { require_once get_template_directory() . ‘/inc/class/Payjs.class.php’; // 获取后台支付配置 $PayJsConfig = _cao(‘payjs’); // 配置通信参数 $config = [ ‘mchid’ => $PayJsConfig[‘mchid’], // 配置商户号 ‘key’ => $PayJsConfig[‘key’], // 配置通信密钥 ]; // 初始化 PAYJS $payjs = new Payjs($config); // 添加订单 ShopOrder if (!$ShopOrder->add($uid, $order_trade_no, $order_type, $order_price, $pay_type)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘订单创建失败’));exit; } if (false) { // 手机模式因openid获取问题 暂时未开放 }else{ // 构造订单基础信息 $data = [ ‘body’ => $order_name, // 订单标题 ‘total_fee’ => $order_price*100, // 订单金额 ‘out_trade_no’ => $order_trade_no, // 订单号 ‘attach’ => ‘payjs_order_attach’, // 订单附加信息(可选参数) ‘notify_url’ => get_template_directory_uri() . ‘/shop/payjs/notify.php’, // 异步通知地址(可选参数) ]; $result = $payjs->native($data); // var_dump($result);die; if (is_array($result) && $result[‘return_code’] == 1 ) { $iconstr = ‘[LT]img src=”‘.get_template_directory_uri()%20.%20’/assets/icons/weixin.png” class=”qr-pay”>’; $html_str = ‘[LT]div class=”qrcon”> [LT]h5> ‘.$iconstr.’ [LT]/h5> [LT]div class=”title”>微信扫码支付 ‘.$order_price.’ 元[LT]/div> [LT]div align=”center” class=”qrcode”> [LT]img src=”‘.$result[‘qrcode’].'”/> [LT]/div> [LT]div class=”bottom weixinpay”> 请使用微信扫一扫支付[LT]br>提示:若扫码支付失败,请重试[LT]br>或添加站长微信:1256069585 办理[LT]/br> [LT]/div> [LT]/div>’; echo json_encode(array(‘status’ => ‘1’, ‘type’ => ‘1’, ‘msg’ => $html_str, ‘img’ => $result[‘qrcode’], ‘num’ => $order_trade_no)); exit; }else{ echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘PAYJS接口异常’));exit; } } echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘请配置payjs参数’));exit; } //虎皮椒支付 讯虎支付 V3 微信 if ($pay_type == 5) { require_once get_template_directory() . ‘/inc/class/xunhupay.class.php’; // 获取后台支付配置 $XHpayConfig = _cao(‘xunhupay’); // 添加订单 ShopOrder if (!$ShopOrder->add($uid, $order_trade_no, $order_type, $order_price, $pay_type)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘订单创建失败’));exit; } $data=array( ‘version’ => ‘1.1’,//固定值,api 版本,目前暂时是1.1 ‘lang’ => ‘zh-cn’, //必须的,zh-cn或en-us 或其他,根据语言显示页面 ‘plugins’ => ‘ripro-xunhupay-v3’,//必须的,根据自己需要自定义插件ID,唯一的,匹配[a-zA-Zd-_]+ ‘appid’ => $XHpayConfig[‘appid’], //必须的,APPID ‘trade_order_id’=> $order_trade_no, //必须的,网站订单ID,唯一的,匹配[a-zA-Zd-_]+ ‘payment’ => ‘wechat’,//必须的,支付接口标识:wechat(微信接口)|alipay(支付宝接口) ‘total_fee’ => $order_price,//人民币,单位精确到分(测试账户只支持0.1元内付款) ‘title’ => $order_name, //必须的,订单标题,长度32或以内 ‘time’ => time(),//必须的,当前时间戳,根据此字段判断订单请求是否已超时,防止第三方攻击服务器 ‘notify_url’=> get_template_directory_uri() . ‘/shop/xunhupay/notify.php’, //必须的,支付成功异步回调接口 ‘return_url’=> get_template_directory_uri() . ‘/shop/xunhupay/return.php’,//必须的,支付成功后的跳转地址 ‘callback_url’=> esc_url(home_url(‘/user?action=charge’)),//必须的,支付发起地址(未支付或支付失败,系统会会跳到这个地址让用户修改支付信息) ‘modal’=>null, //可空,支付模式 ,可选值( full:返回完整的支付网页; qrcode:返回二维码; 空值:返回支付跳转链接) ‘nonce_str’ => str_shuffle(time())//必须的,随机字符串,作用:1.避免服务器缓存,2.防止安全密钥被猜测出来 ); $hashkey =$XHpayConfig[‘appsecret’]; $data[‘hash’] = XH_Payment_Api::generate_xh_hash($data,$hashkey); $url = $XHpayConfig[‘url_do’]; try { $response = XH_Payment_Api::http_post($url, json_encode($data)); /** * 支付回调数据 * @var array( * order_id,//支付系统订单ID * url//支付跳转地址 * ) */ $result = $response?json_decode($response,true):null; if(!$result){ throw new Exception(‘Internal server error’,500); } $hash = XH_Payment_Api::generate_xh_hash($result,$hashkey); if(!isset( $result[‘hash’])|| $hash!=$result[‘hash’]){ throw new Exception(__(‘Invalid sign!’,XH_Wechat_Payment),40029); } if($result[‘errcode’]!=0){ throw new Exception($result[‘errmsg’],$result[‘errcode’]); } if ($XHpayConfig[‘is_pop_qrcode’] && !is_weixin_view()) { //获取二维码地址 $RiProPay = new RiProPay; $pay_qrcode_url = $RiProPay->_cao_get_xunhupay_qrcode($result); $iconstr = ‘[LT]img src=”‘.get_template_directory_uri()%20.%20’/assets/icons/weixin.png” class=”qr-pay”>’; $html_str = ‘[LT]div class=”qrcon”> [LT]h5> ‘.$iconstr.’ [LT]/h5> [LT]div class=”title”>微信扫码支付 ‘.$order_price.’ 元[LT]/div> [LT]div align=”center” class=”qrcode”> [LT]img src=”‘.$pay_qrcode_url.'”/> [LT]/div> [LT]div class=”bottom weixinpay”> 请使用微信扫一扫支付[LT]br>提示:若扫码支付失败,请重试[LT]br>或添加站长微信:1256069585 办理[LT]/br> [LT]/div> [LT]/div>’; echo json_encode(array(‘status’ => ‘1’, ‘type’ => ‘1’, ‘msg’ => $html_str, ‘img’ => $pay_qrcode_url, ‘num’ => $order_trade_no)); exit; }else{ echo json_encode(array(‘status’ => ‘1’, ‘type’ => ‘2’, ‘rurl’ => $result[‘url’], ‘qrcode’ => ”, ‘msg’ => $order_trade_no));exit; } } catch (Exception $e) { echo “errcode:{$e->getCode()},errmsg:{$e->getMessage()}”;exit; //TODO:处理支付调用异常的情况 } exit; } //虎皮椒支付 讯虎支付 V3 支付宝 if ($pay_type == 6) { require_once get_template_directory() . ‘/inc/class/xunhupay.class.php’; // 获取后台支付配置 $XHpayConfig = _cao(‘xunhualipay’); // 添加订单 ShopOrder if (!$ShopOrder->add($uid, $order_trade_no, $order_type, $order_price, $pay_type)) { echo json_encode(array(‘status’ => ‘0’, ‘msg’ => ‘订单创建失败’));exit; } $data=array( ‘version’ => ‘1.1’,//固定值,api 版本,目前暂时是1.1 ‘lang’ => ‘zh-cn’, //必须的,zh-cn或en-us 或其他,根据语言显示页面 ‘plugins’ => ‘ripro-xunhupay-v3’,//必须的,根据自己需要自定义插件ID,唯一的,匹配[a-zA-Zd-_]+ ‘appid’ => $XHpayConfig[‘appid’], //必须的,APPID ‘trade_order_id’=> $order_trade_no, //必须的,网站订单ID,唯一的,匹配[a-zA-Zd-_]+ ‘payment’ => ‘alipay’,//必须的,支付接口标识:wechat(微信接口)|alipay(支付宝接口) ‘total_fee’ => $order_price,//人民币,单位精确到分(测试账户只支持0.1元内付款) ‘title’ => $order_name, //必须的,订单标题,长度32或以内 ‘time’ => time(),//必须的,当前时间戳,根据此字段判断订单请求是否已超时,防止第三方攻击服务器 ‘notify_url’=> get_template_directory_uri() . ‘/shop/xunhupay/notify2.php’, //必须的,支付成功异步回调接口 ‘return_url’=> get_template_directory_uri() . ‘/shop/xunhupay/return.php’,//必须的,支付成功后的跳转地址 ‘callback_url’=> esc_url(home_url(‘/user?action=charge’)),//必须的,支付发起地址(未支付或支付失败,系统会会跳到这个地址让用户修改支付信息) ‘modal’=>null, //可空,支付模式 ,可选值( full:返回完整的支付网页; qrcode:返回二维码; 空值:返回支付跳转链接) ‘nonce_str’ => str_shuffle(time())//必须的,随机字符串,作用:1.避免服务器缓存,2.防止安全密钥被猜测出来 ); $hashkey =$XHpayConfig[‘appsecret’]; $data[‘hash’] = XH_Payment_Api::generate_xh_hash($data,$hashkey); $url = $XHpayConfig[‘url_do’]; try { $response = XH_Payment_Api::http_post($url, json_encode($data)); /** * 支付回调数据 * @var array( * order_id,//支付系统订单ID * url//支付跳转地址 * ) */ $result = $response?json_decode($response,true):null; if(!$result){ throw new Exception(‘Internal server error’,500); } $hash = XH_Payment_Api::generate_xh_hash($result,$hashkey); if(!isset( $result[‘hash’])|| $hash!=$result[‘hash’]){ throw new Exception(__(‘Invalid sign!’,XH_Wechat_Payment),40029); } if($result[‘errcode’]!=0){
您身边的影视解说专家,做最全最好的影视解说文案网!
678解说文案网 » CHX30000