微信扫码支付成功后,回调页面没有被执行

左手青春右手年华 左手青春右手年华 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
首先说明下,微信支付已经配置好相关的支付目录,扫码支付回调路径,现在的问题是扫码支付后,用户输入微信付款密码后弹出付款成功的微信推送信息后并没有按照我预期想法执行回调页面,求大神告知,总的就一共2个页面,2个类库文件就省略不展示出来了哈!
扫码页面一个文本框、一个标签、一个按钮

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Web.Security;
using System.Net;
using System.Xml;
using System.IO;

public partial class SaoMa : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Random rnd = new Random();
string n = rnd.Next(1000, 9999).ToString();
this.Label1.Text = DateTime.Now.ToString("yyyyMMddHHmmss")+n; //订单号
if (!IsPostBack)
{

}


}

protected void Button1_Click(object sender, EventArgs e)
{
WxPayHelper wxPayHelper = new WxPayHelper();
//先设置基本信息
string appid = "wx208736198e224c75";
string mch_id = "1419898802";
wxPayHelper.SetAppId("wx208736198e224c75");
wxPayHelper.SetAppKey("ddewxvrwaz561063793xzkwangka6841");
wxPayHelper.SetPartnerKey("ddewxvrwaz561063793xzkwangka6841");//商户key
wxPayHelper.SetMatchID("1419898802");
wxPayHelper.SetSignType("sha1");
string orderid = this.Label1.Text; //订单号
// string purl = wxPayHelper.CreateNativeUrl(orderid);
//生成与支付订单
//根据订单号获取订单信息数据 金额 等
string device_info = "1234"; //设备号
string nonce_str = CommonUtil.CreateNoncestr();
string body = "微网咖扫码支付"; //商品描述
string detail = "现场扫码付款";//商品详情
string attach = "1";//附加数据,原样返回;
string out_trade_no = orderid;//订单号
string total_fee = this.TextBox1.Text.Trim();
// string total_fee = (decimal.Parse(this.TextBox1.Text.Trim()) * 100).ToString(); //订单金额 以分为单位 1 即表示 0.01元
string fee_type = "1";//1 人民币
string notify_url = "http://xzk.abcd.com/Sm/nurl.aspx";//支付成功后返回执行订单操作的路径
string spbill_create_ip = Request.UserHostAddress.ToString();
string time_start = DateTime.Now.ToString("yyyyMMddHHmmss"); //交易时间
string time_expire = DateTime.Now.AddHours(12).ToString("yyyyMMddHHmmss");//交易结束时间
string goods_tag = "扫码"; //商品标记
string trade_type = "NATIVE"; //交易类型
string product_id = orderid;


Dictionary<string, string> dicArray = new Dictionary<string, string>();
dicArray.Add("appid", appid);
dicArray.Add("body", body);
dicArray.Add("attach", attach);
dicArray.Add("device_info", device_info);
dicArray.Add("out_trade_no", out_trade_no);
dicArray.Add("total_fee", total_fee);
dicArray.Add("notify_url", notify_url);
dicArray.Add("spbill_create_ip", spbill_create_ip);
dicArray.Add("time_start", time_start);
dicArray.Add("time_expire", time_expire);
dicArray.Add("nonce_str", CommonUtil.CreateNoncestr());
dicArray.Add("goods_tag", goods_tag);
dicArray.Add("product_id", product_id);
dicArray.Add("mch_id", mch_id);
dicArray.Add("trade_type", trade_type);
string bizString = CommonUtil.FormatBizQueryParaMap(dicArray, false);
string nwesign = wxPayHelper.Sign(bizString);
dicArray.Add("sign", nwesign);
string package = wxPayHelper.Getpostorderxml(dicArray);
string postorder = "https://api.mch.weixin.qq.com/pay/unifiedorder";
//Response.ContentType = "xml";
//Response.Write(package);
//Response.End();
string rexml = RequestUrl(postorder, package, "post", "xml", "utf-8");
XmlDocument xd = new XmlDocument();
xd.LoadXml(rexml);
XmlElement xe = xd.DocumentElement;
string return_code = "";
string return_msg = "";
string appid1 = "";
string mch_id1 = "";
string nonce_str1 = "";
string sign1 = "";
string result_code1 = "";
string prepay_id = "";
string trade_type1 = "";
string code_url = "";
foreach (XmlNode item in xe.ChildNodes)
{
if (item.LocalName == "return_code") return_code = item.InnerText;
if (item.LocalName == "return_msg") return_msg = item.InnerText;
if (item.LocalName == "appid") appid1 = item.InnerText;
if (item.LocalName == "mch_id") mch_id1 = item.InnerText;
if (item.LocalName == "nonce_str") nonce_str1 = item.InnerText;
if (item.LocalName == "sign") sign1 = item.InnerText;
if (item.LocalName == "result_code") result_code1 = item.InnerText;
if (item.LocalName == "prepay_id") prepay_id = item.InnerText;
if (item.LocalName == "trade_type") trade_type1 = item.InnerText;
if (item.LocalName == "trade_type") trade_type1 = item.InnerText;
if (item.LocalName == "code_url") code_url = item.InnerText;


}


/*第三方接口生成二维码*/
byte[] buffer = Encoding.Default.GetBytes(code_url);
string text = Encoding.GetEncoding("UTF-8").GetString(buffer);
Image1.ImageUrl = "http://qr.liantu.com/api.php?text=" + text.Replace("&", "%26");
}

protected string RequestUrl(string url, string data, string method, string contentType, string charset)
{
var request = WebRequest.Create(url);
request.Method = method;
request.ContentType = contentType;
request.Headers.Add("charset:" + charset);
var encoding = Encoding.GetEncoding(charset);
if (data != null)
{
byte[] buffer = encoding.GetBytes(data);
request.ContentLength = buffer.Length; request.GetRequestStream().Write(buffer, 0, buffer.Length);
}
else { request.ContentLength = 0; }
using (HttpWebResponse wr = request.GetResponse() as HttpWebResponse)
{
using (StreamReader reader = new StreamReader(wr.GetResponseStream(), encoding))
{ return reader.ReadToEnd(); }
}
}

}



...全文
评论 4
收藏 已收藏
分享
返回顶部
左手青春右手年华
C# 111,130 成员 642,541 内容