基本信息
源码名称:微信支付源码
源码大小:2.39M
文件格式:.zip
开发语言:C#
更新时间:2016-01-12
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
WxPayAPI_CS_v3.zip
WxPayAPI_CS_v3.zip
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using System.Threading;
using LitJson;
using System.Web.Security;
namespace WxPayAPI
{
public partial class JsApiPayPage : System.Web.UI.Page
{
public static string wxJsApiParam {get;set;} //H5调起JS API参数
protected void Page_Load(object sender, EventArgs e)
{
Log.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>");
Log.Error(this.GetType().ToString(), "This page have not get params, cannot be inited, exit...");
submit.Visible = false;
return;
}
//若传递了相关参数,则调统一下单接口,获得后续相关接口的入口参数
JsApiPay jsApiPay = new JsApiPay(this);
jsApiPay.openid = openid;
jsApiPay.total_fee = int.Parse(total_fee);
//JSAPI支付预处理
try
{
WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult();
wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数
Log.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;
}
}
}
}
}