public ActionResult JsApiPay(string openid, string total_fee) { WxPayLog.Info(this.GetType().ToString(), "JsApiPayPage load"); //检测是否给当前页面传递了相关参数 if (string.IsNullOrEmpty(openid) || string.IsNullOrEmpty(total_fee)) { WxPayLog.Error(this.GetType().ToString(), "This page have not get params, cannot be inited, exit..."); return(View(new AlertMsg("页面传参出错, 请返回重试"))); } var alertMsg = new AlertMsg(); //若传递了相关参数,则调统一下单接口,获得后续相关接口的入口参数 WxPayJsApi jsApiPay = new WxPayJsApi(Request); jsApiPay.openid = openid; jsApiPay.total_fee = int.Parse(total_fee); //JSAPI支付预处理 try { WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(); var wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数 WxPayLog.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam); //在页面上显示订单信息 alertMsg.IsSuccess = true; alertMsg.Message = ("订单详情:" + unifiedOrderResult.ToPrintStr()); ViewBag.WxJsApiParam = wxJsApiParam; } catch (Exception ex) { alertMsg.Message = $"下单失败,请返回重试,错误信息:{ex.Message}"; } return(View(alertMsg)); }
public ActionResult Product() { var alertMsg = new AlertMsg(); WxPayLog.Info(this.GetType().ToString(), "page load"); WxPayJsApi jsApiPay = new WxPayJsApi(Request); try { //调用【网页授权获取用户信息】接口获取用户的openid和access_token var url = jsApiPay.GetOpenidAndAccessToken(); if (url != null) { return(Redirect(url)); } //获取收货地址js函数入口参数 var wxEditAddrParam = jsApiPay.GetEditAddressParameters(); TempData["openid"] = jsApiPay.openid; alertMsg.IsSuccess = true; ViewBag.WxEditAddrParam = wxEditAddrParam; } catch (Exception ex) { alertMsg.Message = $"页面加载出错,请重试,错误信息:{ex.Message}"; } return(View(alertMsg)); }
protected void Page_Load(object sender, EventArgs e) { WxPayLog.Info(this.GetType().ToString(), "page load"); if (!IsPostBack) { var jsApiPay = new WxPayJsApi(this); try { //调用【网页授权获取用户信息】接口获取用户的openid和access_token jsApiPay.GetOpenidAndAccessToken(); //获取收货地址js函数入口参数 wxEditAddrParam = jsApiPay.GetEditAddressParameters(); ViewState["openid"] = jsApiPay.openid; } catch (Exception ex) { Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面加载出错,请重试" + "</span>"); Button1.Visible = false; Button2.Visible = false; Label1.Visible = false; Label2.Visible = false; } } }
public ActionResult NativePay() { WxPayLog.Info(this.GetType().ToString(), "page load"); //生成扫码支付模式一url ViewBag.QRCode1 = WxPayApiBiz.GetNativePrePayUrl("123456789"); //生成扫码支付模式二url ViewBag.QRCode2 = WxPayApiBiz.GetNativePayUrl("123456789"); return(View()); }
protected void Page_Load(object sender, EventArgs e) { WxPayLog.Info(this.GetType().ToString(), "page load"); //生成扫码支付模式一url string url1 = WxPayApiBiz.GetNativePrePayUrl("123456789"); //生成扫码支付模式二url string url2 = WxPayApiBiz.GetNativePayUrl("123456789"); //将url生成二维码图片 Image1.ImageUrl = "MakeQRCode.aspx?data=" + HttpUtility.UrlEncode(url1); Image2.ImageUrl = "MakeQRCode.aspx?data=" + HttpUtility.UrlEncode(url2); }
} //H5调起JS API参数 protected void Page_Load(object sender, EventArgs e) { WxPayLog.Info(this.GetType().ToString(), "page load"); if (!IsPostBack) { string openid = Request.QueryString["openid"]; string total_fee = Request.QueryString["total_fee"]; //检测是否给当前页面传递了相关参数 if (string.IsNullOrEmpty(openid) || string.IsNullOrEmpty(total_fee)) { Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面传参出错,请返回重试" + "</span>"); WxPayLog.Error(this.GetType().ToString(), "This page have not get params, cannot be inited, exit..."); submit.Visible = false; return; } //若传递了相关参数,则调统一下单接口,获得后续相关接口的入口参数 var jsApiPay = new WxPayJsApi(this); jsApiPay.openid = openid; jsApiPay.total_fee = int.Parse(total_fee); //JSAPI支付预处理 try { WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(); wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数 WxPayLog.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam); //在页面上显示订单信息 Response.Write("<span style='color:#00CD00;font-size:20px'>订单详情:</span><br/>"); Response.Write("<span style='color:#00CD00;font-size:20px'>" + unifiedOrderResult.ToPrintStr() + "</span>"); } catch (Exception ex) { Response.Write("<span style='color:#FF0000;font-size:20px'>" + "下单失败,请返回重试" + "</span>"); submit.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { WxPayLog.Info(this.GetType().ToString(), "page load"); }
public ActionResult OrderQuery() { WxPayLog.Info(this.GetType().ToString(), "page load"); return(View()); }