微信支付 支付成功后不跳转 ecshop微信支付 如下操作即可

微信--订单处理页:

<?php
    include("WxPayPubHelper.php");
    //使用jsapi接口
    $jsApi = new JsApi_pub();
    //=========步骤1:网页授权获取用户openid============
    //通过code获得openid
    if (!isset($_GET[‘code‘]))
    {
        //触发微信返回code码
        $url = $jsApi->createOauthUrlForCode(WxPayConf_pub::JS_API_CALL_URL);
        ecs_header("Location: $url");
    }else
    {
    
        //获取code码,以获取openid
        
        $code = $_GET[‘code‘];
        
        $jsApi->setCode($code);
        $openid = $jsApi->getOpenId();
        if(!empty($openid))
        {
            goto获取到相应的订单参数
        }
    
        //=========步骤2:使用统一支付接口,获取prepay_id============
        //使用统一支付接口
        $unifiedOrder = new UnifiedOrder_pub();
        //设置统一支付接口参数
        //设置必填参数
        //appid已填,商户无需重复填写
        //mch_id已填,商户无需重复填写
        //noncestr已填,商户无需重复填写
        //spbill_create_ip已填,商户无需重复填写
        //sign已填,商户无需重复填写
        $unifiedOrder->setParameter("openid","$openid");//商品描述
        $out_trade_no = $order[‘order_sn‘];
        
        
        $unifiedOrder->setParameter("body","$goods_name");//商品描述
        //自定义订单号,此处仅作举例
        //$timeStamp = time();
        //$out_trade_no = WxPayConf_pub::APPID."$timeStamp";
        $total_fee    =    $total[‘amount‘]*100;
        $unifiedOrder->setParameter("out_trade_no","$out_trade_no");//商户订单号
        $unifiedOrder->setParameter("total_fee","$total_fee");//总金额
        $unifiedOrder->setParameter("notify_url",WxPayConf_pub::NOTIFY_URL);//通知地址
        $unifiedOrder->setParameter("trade_type","JSAPI");//交易类型
        //非必填参数,商户可根据实际情况选填
        //$unifiedOrder->setParameter("sub_mch_id","XXXX");//子商户号  
        //$unifiedOrder->setParameter("device_info","XXXX");//设备号
        //$unifiedOrder->setParameter("attach","XXXX");//附加数据
        //$unifiedOrder->setParameter("time_start","XXXX");//交易起始时间
        //$unifiedOrder->setParameter("time_expire","XXXX");//交易结束时间
        //$unifiedOrder->setParameter("goods_tag","XXXX");//商品标记
        //$unifiedOrder->setParameter("openid","XXXX");//用户标识
        //$unifiedOrder->setParameter("product_id","XXXX");//商品ID

$prepay_id = $unifiedOrder->getPrepayId();
        //=========步骤3:使用jsapi调起支付============
        $jsApi->setPrepayId($prepay_id);

$jsApiParameters = $jsApi->getParameters();
        //$jsApiParameters = json_encode($jsApiParameters);
        $smarty->assign(‘pay_online‘, $jsApiParameters);
        $smarty->assign(‘openid‘,$openid);
        $smarty->assign(‘order_id‘,$order_id);//订单id用于支付成功跳转订单页
        $smarty->display(‘order_done.dwt‘);
        //echo $jsApiParameters;

}

?>

微信支付页:请注意标红处。此处为支付成功后跳转

<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <title>微信安全支付</title>

<script type="text/javascript">

//调用微信JS api 支付
        function jsApiCall()
        {
            WeixinJSBridge.invoke(
                ‘getBrandWCPayRequest‘,
                {$pay_online},
                function(res){
                    WeixinJSBridge.log(res.err_msg);
                    if(res.err_msg == "get_brand_wcpay_request:ok"){
                    //alert(res.err_code+res.err_desc+res.err_msg);
                        window.location.href="http://xxxxxx";
                    }else{
                        //返回跳转到订单详情页面
                        alert(支付失败);
                        window.location.href="http://xxxxx/index.php?wxid={$openid}";
                           
                    }
                }
            );
        }

function callpay()
        {
            if (typeof WeixinJSBridge == "undefined"){
                if( document.addEventListener ){
                    document.addEventListener(‘WeixinJSBridgeReady‘, jsApiCall, false);
                }else if (document.attachEvent){
                    document.attachEvent(‘WeixinJSBridgeReady‘, jsApiCall);
                    document.attachEvent(‘onWeixinJSBridgeReady‘, jsApiCall);
                }
            }else{
                jsApiCall();
            }
        }

</script>
        
</head>
<body>
    </br></br></br></br>
    <div align="center">
        <button style="width:610px; height:160px; border:0px #FE6714 solid; cursor: pointer;  color:white;  font-size:64px;" type="button" onclick="callpay()" >给我一分钱</button>
    </div>
</body>
</html>

异步处理页:必须echo success

<?php
//使用log文件形式记录回调信息。

include("log_.php");
    include("WxPayPubHelper.php");

//使用通用通知接口
    $notify = new Notify_pub();

//存储微信的回调
    $xml = $GLOBALS[‘HTTP_RAW_POST_DATA‘];    
    $notify->saveData($xml);
    
    //验证签名,并回应微信。
    //对后台通知交互时,如果微信收到商户的应答不是成功或超时,微信认为通知失败,
    //微信会通过一定的策略(如30分钟共8次)定期重新发起通知,
    //尽可能提高通知的成功率,但微信不保证通知最终能成功。
    if($notify->checkSign() == FALSE){
        $notify->setReturnParameter("return_code","FAIL");//返回状态码
        $notify->setReturnParameter("return_msg","签名失败");//返回信息
    }else{
        $notify->setReturnParameter("return_code","SUCCESS");//设置返回码
    }
    $returnXml = $notify->returnXml();
    echo $returnXml;
    
    //==商户根据实际情况设置相应的处理流程,此处仅作举例=======
    
    //以log文件形式记录回调信息
    $log_ = new Log_();
    $log_name="./notify_url.log";//log文件路径
    $log_->log_result($log_name,"【接收到的notify通知】:\n".$xml."\n");

if($notify->checkSign() == TRUE)
    {
        //进行订单处理:
        //商户自行增加处理流程,
        //例如:更新订单状态
        //例如:数据库操作
        //例如:推送支付完成信息
    }

$fp = fopen(‘./a.txt‘, ‘a+b‘);
    fwrite($fp, var_export($xml, true));
    fclose($fp);

?>

时间: 2024-08-27 00:59:25

微信支付 支付成功后不跳转 ecshop微信支付 如下操作即可的相关文章

yourphp提交成功后的跳转地址

$this->assign('jumpUrl',U('Index/index')); $this->success(L('login_ok')); yourphp提交成功后的跳转地址

使用Shiro登录成功后,跳转到之前访问的页面实现

转:http://blog.csdn.net/lhacker/article/details/20450855 很多时候,我们需要做到,当用户登录成功后,跳转回登录前的页面.如果用户是点击"登录"链接去到登录页面进行登录的,我们很容易跟踪用户的登录前的页面.比如,在"登录"链接后加一个url参数,如:http://www.xxx.com/login.html?url=http://www.xxx.com/xx.html,这个url就是当前页面.用户浏览不同页面,&q

IdentityServer4 登录成功后,跳转到原来页面

IdentityServer4 登录成功后,默认会跳转到Config.Client配置的RedirectUris地址http://localhost:5003/callback.html,用于获取 Token,比如跳转后的地址: http://localhost:5003/callback.html#id_token=eyJhbGciOiJSUzI1NiIsImtpZCI6IjkwYWRmOTliMDhmODExMjBiMzdlMWI1NzVmMDliODcwIiwidHlwIjoiSldUIn

【涛舅舅独家教程】微信小游戏分享后自动跳转网址

在微信里之所以可以实现分享到朋友圈.分享给好友,完全依赖于微信浏览器内置的一个JS框架,也就是weixinJSBridge这个东西.这个东西是干啥的?简单来说,就是当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件,在这个事件中,可以定义一些信息在“分享到朋友圈”,“分享给好友”,“分享到腾讯微博”时直接调用. 要定义哪些信息呢? 1.title:分享时的标题 2.desc:分享时的短描述 3.link:分享的链接,等于游戏本身的链接 4.img_url:这是分享时

jfianl 登录状态验证,未登录打开登录页面,登录成功后跳转到请求页面

项目中的一个需求,1.当用户提交预约信息时,如果未登录跳装到用户登录(注册)界面. 2.当登录(注册)成功后,跳转到请求页面 思路:1.增加登录状态验证拦截器,验证登录状态,如果未登录,获取请求路径,并保存在requset中,跳转登录(注册)页面 2.前台form中 增加 hiddent  input  .value为request中的请求路径 3.后台登录controller中验证,如登录(注册)成功则跳转到 请求路径 代码:1. public class LoginInterceptor i

微信支付成功后(四)

官方API:https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_2 微信支付成功后,微信服务器端回调到/example/ResultNotifyPage.aspx页面. ResultNotify resultNotify = new ResultNotify(this); resultNotify.ProcessNotify(); //ProcessNotify支付回调结果,先查询订单号,订单号没有问题,返回return_cod

ectouch 微信支付成功后订单状态未改变的解决办法 (转载)

原文地址: 微信支付支付成功后,返回到mobile/wx_native_callback.php 之前代码 define('IN_ECS', true); require(dirname(__FILE__) . '/include/init.php'); require(ROOT_PATH . 'include/lib_payment.php'); require_once(ROOT_PATH .'include/modules/payment/wx_new_jspay.php'); $paym

微信支付完成 vue 页面不跳转问题

遇到的问题是 vue 调用微信支付 回调成功以后,页面路由不跳转. 解决的办法是用window.location.href /** * @method 支付费用方法 * @param data:后台返回的支付对象,(详情微信公众号支付API中H5提交支付); */onBridgeReady(params){ var vm = this; WeixinJSBridge.invoke( 'getBrandWCPayRequest',params, function(res){ // 使用以上方式判断

微信支付开发(APP)的各种坑,.net和iOS的各种陷阱,解决.net调用下单接口提示无权限,解决iOS跳转到微信支付页面中间只有一个确定按钮

直入主题之前,请容我吐槽一下微*的官方东西:ASDFQ%#$%$#$%^[email protected]#$%DSFQ#$%.......:吐槽玩了!大家心照就好. 要完成手机APP跳转到微信的APP进行微信支付,需要进行如下操作: 1.先去微信的开放平台(http://open.weixin.qq.com)进行开发者账号的注册. 2.新建一个APP应用,然后填写必填信息提交审核. 3.进入APP应用,在接口信息中,进行申请“获得微信支付能力”的功能,期间会提交相关的公司营业信息证明等. 通过