NEWS

技术文章

asp.net开发微信支付接口

编辑:
起点网络
发布时间:
2018-11-8
点击:
后台代码
创建支付应答对象
            RequestHandler packageReqHandler = new RequestHandler(Context);
            //初始化
            packageReqHandler.init();
            packageReqHandler.setKey(TenpayUtil.key);

            //设置package订单参数
            packageReqHandler.setParameter("partner", TenpayUtil.partner);          //商户号
            packageReqHandler.setParameter("bank_type", "WX");
            packageReqHandler.setParameter("fee_type", "1");                    //币种,1人民币
            packageReqHandler.setParameter("input_charset", "UTF-8");
            packageReqHandler.setParameter("out_trade_no", model.order_id);        //商家订单号
            packageReqHandler.setParameter("total_fee", (model.order_money * 100).ToString("f0"));                    //商品金额,以分为单位(money * 100).ToString()
            packageReqHandler.setParameter("notify_url", TenpayUtil.tenpay_notify);            //接收财付通通知的URL            
            packageReqHandler.setParameter("body", model.description.Replace(" ", ""));                        //商品描述    

            packageReqHandler.setParameter("spbill_create_ip", Page.Request.UserHostAddress);   //用户的公网ip,不是商户服务器IP

            //获取package包
            packageValue = packageReqHandler.getRequestURL();

            //调起微信支付签名
            timeStamp = TenpayUtil.getTimestamp();
            nonceStr = TenpayUtil.getNoncestr();

            //设置支付参数
            RequestHandler paySignReqHandler = new RequestHandler(Context);
            paySignReqHandler.setParameter("appid", appId);
            paySignReqHandler.setParameter("appkey", TenpayUtil.appkey);
            paySignReqHandler.setParameter("noncestr", nonceStr);
            paySignReqHandler.setParameter("timestamp", timeStamp);
            paySignReqHandler.setParameter("package", packageValue);
            paySign = paySignReqHandler.createSHA1Sign();


            string sign = PayOrderCommon.OrderHelper.CreateSign(payNo);

            successUrl = string.Format("{0}?sign={1}&payNo={2}", "payresult.ashx", sign, payNo);

前台代码
创建支付应答对象
            RequestHandler packageReqHandler = new RequestHandler(Context);
            //初始化
            packageReqHandler.init();
            packageReqHandler.setKey(TenpayUtil.key);

            //设置package订单参数
            packageReqHandler.setParameter("partner", TenpayUtil.partner);          //商户号
            packageReqHandler.setParameter("bank_type", "WX");
            packageReqHandler.setParameter("fee_type", "1");                    //币种,1人民币
            packageReqHandler.setParameter("input_charset", "UTF-8");
            packageReqHandler.setParameter("out_trade_no", model.order_id);        //商家订单号
            packageReqHandler.setParameter("total_fee", (model.order_money * 100).ToString("f0"));                    //商品金额,以分为单位(money * 100).ToString()
            packageReqHandler.setParameter("notify_url", TenpayUtil.tenpay_notify);            //接收财付通通知的URL            
            packageReqHandler.setParameter("body", model.description.Replace(" ", ""));                        //商品描述    

            packageReqHandler.setParameter("spbill_create_ip", Page.Request.UserHostAddress);   //用户的公网ip,不是商户服务器IP

            //获取package包
            packageValue = packageReqHandler.getRequestURL();

            //调起微信支付签名
            timeStamp = TenpayUtil.getTimestamp();
            nonceStr = TenpayUtil.getNoncestr();

            //设置支付参数
            RequestHandler paySignReqHandler = new RequestHandler(Context);
            paySignReqHandler.setParameter("appid", appId);
            paySignReqHandler.setParameter("appkey", TenpayUtil.appkey);
            paySignReqHandler.setParameter("noncestr", nonceStr);
            paySignReqHandler.setParameter("timestamp", timeStamp);
            paySignReqHandler.setParameter("package", packageValue);
            paySign = paySignReqHandler.createSHA1Sign();


            string sign = PayOrderCommon.OrderHelper.CreateSign(payNo);

            successUrl = string.Format("{0}?sign={1}&payNo={2}", "payresult.ashx", sign, payNo);
标签  asp.net开发
上一条新闻:H5中的JS手势编写
下一条新闻:apicloud开发api介绍
相关文章

Copyright@宁波起点网络. All rights reserved. Powered by 起点网络       备案号:浙ICP备 16017710号